MCPcopy Create free account
hub / github.com/comaps/comaps / FindPaths

Method FindPaths

libs/search/geocoder.cpp:1628–1745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1626}
1627
1628void Geocoder::FindPaths(BaseContext & ctx)
1629{
1630 auto const & layers = ctx.m_layers;
1631 if (layers.empty())
1632 return;
1633
1634 FeaturesLayer cityLayer;
1635 vector<uint32_t> cityFeature;
1636
1637 if (ctx.m_city)
1638 {
1639 bool hasBuilding = false;
1640 bool hasStreetOrSuburb = false;
1641 for (auto const & l : layers)
1642 {
1643 switch (l.m_type)
1644 {
1645 case Model::TYPE_BUILDING:
1646 // Same condition as in MatchPOIsAndBuildings.
1647 hasBuilding = l.m_sortedFeatures->empty() || house_numbers::LooksLikeHouseNumberStrict(l.m_subQuery);
1648 break;
1649 case Model::TYPE_STREET:
1650 case Model::TYPE_SUBURB: hasStreetOrSuburb = true; break;
1651 case Model::TYPE_CITY:
1652 case Model::TYPE_COMPLEX_POI:
1653 case Model::TYPE_COUNT:
1654 case Model::TYPE_COUNTRY:
1655 case Model::TYPE_STATE:
1656 case Model::TYPE_SUBPOI:
1657 case Model::TYPE_UNCLASSIFIED:
1658 case Model::TYPE_VILLAGE:
1659 // TODO: These types could be processed in a different way in the future...
1660 break;
1661 }
1662 }
1663
1664 if (hasBuilding && !hasStreetOrSuburb)
1665 {
1666 InitLayer(Model::TYPE_CITY, ctx.m_city->m_tokenRange, cityLayer);
1667
1668 // Convert Feature's index, because a city maybe from World, but should match with Country MWM index.
1669 if (uint32_t fid = MatchWorld2Country(ctx.m_city->m_featureId); fid != kInvalidFeatureId)
1670 cityFeature.push_back(fid);
1671 cityLayer.m_sortedFeatures = &cityFeature;
1672 cityLayer.m_getFeatures = [this, &ctx]()
1673 { return RetrieveGeometryFeatures(*m_context, ctx.m_city->m_rect, RectId::Locality); };
1674 }
1675 }
1676
1677 // Layers ordered by search type.
1678 vector<FeaturesLayer const *> sortedLayers;
1679 sortedLayers.reserve(layers.size() + 1);
1680 for (auto const & layer : layers)
1681 sortedLayers.push_back(&layer);
1682
1683 if (!cityFeature.empty())
1684 sortedLayers.push_back(&cityLayer);
1685

Callers

nothing calls this directly

Calls 15

LessByFunction · 0.85
ASSERTFunction · 0.85
frontMethod · 0.80
SetPostcodesMethod · 0.80
HasBitMethod · 0.80
InnermostResultMethod · 0.80
AllTokensUsedMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected