forked from organicmaps/organicmaps
[geocoder] Fix for review
This commit is contained in:
parent
faeee82dd6
commit
d4dee5663c
3 changed files with 17 additions and 17 deletions
|
@ -302,9 +302,9 @@ void Geocoder::FillBuildingsLayer(Context & ctx, Tokens const & subquery, Layer
|
|||
// let's stay on the safer side and set the house number bit.
|
||||
ctx.SetHouseNumberBit();
|
||||
|
||||
for (auto const & streetDocId : layer.m_entries)
|
||||
for (auto const & docId : layer.m_entries)
|
||||
{
|
||||
m_index.ForEachBuildingOnStreet(streetDocId, [&](Index::DocId const & buildingDocId) {
|
||||
m_index.ForEachRelatedBuilding(docId, [&](Index::DocId const & buildingDocId) {
|
||||
auto const & bld = m_index.GetDoc(buildingDocId);
|
||||
auto const bt = static_cast<size_t>(Type::Building);
|
||||
auto const & realHN = MakeHouseNumber(bld.m_address[bt]);
|
||||
|
|
|
@ -102,21 +102,21 @@ void Index::AddHouses()
|
|||
auto const & street = buildingDoc.m_address[static_cast<size_t>(Type::Street)];
|
||||
auto const & locality = buildingDoc.m_address[static_cast<size_t>(Type::Locality)];
|
||||
|
||||
Tokens const * buildingPlace = nullptr;
|
||||
Tokens const * relationName = nullptr;
|
||||
|
||||
if (!street.empty())
|
||||
buildingPlace = &street;
|
||||
relationName = &street;
|
||||
else if (!locality.empty())
|
||||
buildingPlace = &locality;
|
||||
relationName = &locality;
|
||||
|
||||
if (!buildingPlace)
|
||||
if (!relationName)
|
||||
continue;
|
||||
|
||||
ForEachDocId(*buildingPlace, [&](DocId const & placeCandidate) {
|
||||
auto const & streetDoc = GetDoc(placeCandidate);
|
||||
if (streetDoc.IsParentTo(buildingDoc))
|
||||
ForEachDocId(*relationName, [&](DocId const & candidate) {
|
||||
auto const & candidateDoc = GetDoc(candidate);
|
||||
if (candidateDoc.IsParentTo(buildingDoc))
|
||||
{
|
||||
m_buildingsOnStreet[placeCandidate].emplace_back(docId);
|
||||
m_relatedBuildings[candidate].emplace_back(docId);
|
||||
|
||||
++numIndexed;
|
||||
if (numIndexed % kLogBatch == 0)
|
||||
|
|
|
@ -41,12 +41,12 @@ public:
|
|||
}
|
||||
|
||||
// Calls |fn| for DocIds of buildings that are located on the
|
||||
// street whose DocId is |streetDocId|.
|
||||
// street/locality whose DocId is |docId|.
|
||||
template <typename Fn>
|
||||
void ForEachBuildingOnStreet(DocId const & streetDocId, Fn && fn) const
|
||||
void ForEachRelatedBuilding(DocId const & docId, Fn && fn) const
|
||||
{
|
||||
auto const it = m_buildingsOnStreet.find(streetDocId);
|
||||
if (it == m_buildingsOnStreet.end())
|
||||
auto const it = m_relatedBuildings.find(docId);
|
||||
if (it == m_relatedBuildings.end())
|
||||
return;
|
||||
|
||||
for (DocId const & docId : it->second)
|
||||
|
@ -65,14 +65,14 @@ private:
|
|||
// with and without synonyms of the word "street".
|
||||
void AddStreet(DocId const & docId, Doc const & e);
|
||||
|
||||
// Fills the |m_buildingsOnStreet| field.
|
||||
// Fills the |m_relatedBuildings| field.
|
||||
void AddHouses();
|
||||
|
||||
std::vector<Doc> const & m_docs;
|
||||
|
||||
std::unordered_map<std::string, std::vector<DocId>> m_docIdsByTokens;
|
||||
|
||||
// Lists of houses grouped by the streets they belong to.
|
||||
std::unordered_map<DocId, std::vector<DocId>> m_buildingsOnStreet;
|
||||
// Lists of houses grouped by the streets/localities they belong to.
|
||||
std::unordered_map<DocId, std::vector<DocId>> m_relatedBuildings;
|
||||
};
|
||||
} // namespace geocoder
|
||||
|
|
Loading…
Add table
Reference in a new issue