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

Method FillVillageLocalities

libs/search/geocoder.cpp:823–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821}
822
823void Geocoder::FillVillageLocalities(BaseContext const & ctx)
824{
825 vector<Locality> preLocalities;
826 FillLocalityCandidates(ctx, ctx.m_villages, kMaxNumVillages, preLocalities);
827
828 for (auto & l : preLocalities)
829 {
830 auto ft = m_context->GetFeature(l.GetFeatureIndex());
831 if (!ft)
832 continue;
833
834 if (m_model.GetType(*ft) != Model::TYPE_VILLAGE)
835 continue;
836
837 ASSERT_EQUAL(ft->GetGeomType(), feature::GeomType::Point, (ft->GetID()));
838
839 auto const center = ft->GetCenter();
840
841 // Always grab top kMaxNumVillages, despite of the distance.
842 /*
843 vector<m2::PointD> pivotPoints = {m_params.m_pivot.Center()};
844 if (m_params.m_position)
845 pivotPoints.push_back(*m_params.m_position);
846 if (!m_context->GetType().m_containsMatchedState &&
847 all_of(pivotPoints.begin(), pivotPoints.end(), [&](auto const & p) {
848 return mercator::DistanceOnEarth(center, p) > m_params.m_filteringParams.m_villageSearchRadiusM;
849 }))
850 {
851 continue;
852 }
853 */
854
855 City village(std::move(l), Model::TYPE_VILLAGE);
856
857 auto const population = ftypes::GetPopulation(*ft);
858 auto const radius = ftypes::GetRadiusByPopulation(population);
859 village.m_rect = mercator::RectByCenterXYAndSizeInMeters(center, radius);
860
861 LOG(LDEBUG, ("Village =", ft->GetName(localisation::kDefaultNameIndex), "ll =", mercator::ToLatLon(center),
862 "radius =", radius));
863
864 m_cities[village.m_tokenRange].push_back(std::move(village));
865 }
866}
867
868bool Geocoder::CityHasPostcode(BaseContext const & ctx) const
869{

Callers

nothing calls this directly

Calls 12

GetRadiusByPopulationFunction · 0.85
GetFeatureIndexMethod · 0.80
GetPopulationFunction · 0.50
ToLatLonFunction · 0.50
GetFeatureMethod · 0.45
GetTypeMethod · 0.45
GetGeomTypeMethod · 0.45
GetIDMethod · 0.45
GetCenterMethod · 0.45
GetNameMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected