| 721 | } |
| 722 | |
| 723 | void Geocoder::FillLocalitiesTable(BaseContext const & ctx) |
| 724 | { |
| 725 | auto addRegionMaps = [this](FeatureType & ft, Locality && l, Region::Type type) |
| 726 | { |
| 727 | if (ft.GetGeomType() != feature::GeomType::Point) |
| 728 | return; |
| 729 | |
| 730 | string affiliation; |
| 731 | if (!GetAffiliationName(ft, affiliation)) |
| 732 | return; |
| 733 | |
| 734 | Region region(std::move(l), type); |
| 735 | region.m_center = ft.GetCenter(); |
| 736 | |
| 737 | LOG(LDEBUG, ("Region =", ft.GetName(localisation::kDefaultNameIndex))); |
| 738 | |
| 739 | m_infoGetter.GetMatchedRegions(affiliation, region.m_ids); |
| 740 | m_regions[type][region.m_tokenRange].push_back(std::move(region)); |
| 741 | }; |
| 742 | |
| 743 | vector<Locality> preLocalities; |
| 744 | |
| 745 | CBV filter = m_localitiesCaches.m_countries.Get(*m_context); |
| 746 | FillLocalityCandidates(ctx, filter, kMaxNumCountries, preLocalities); |
| 747 | for (auto & l : preLocalities) |
| 748 | { |
| 749 | auto ft = m_context->GetFeature(l.GetFeatureIndex()); |
| 750 | if (!ft) |
| 751 | { |
| 752 | LOG(LWARNING, ("Failed to get country", l.m_featureId)); |
| 753 | continue; |
| 754 | } |
| 755 | |
| 756 | addRegionMaps(*ft, std::move(l), Region::TYPE_COUNTRY); |
| 757 | } |
| 758 | |
| 759 | filter = m_localitiesCaches.m_states.Get(*m_context); |
| 760 | FillLocalityCandidates(ctx, filter, kMaxNumStates, preLocalities); |
| 761 | for (auto & l : preLocalities) |
| 762 | { |
| 763 | auto ft = m_context->GetFeature(l.GetFeatureIndex()); |
| 764 | if (!ft) |
| 765 | { |
| 766 | LOG(LWARNING, ("Failed to get state", l.m_featureId)); |
| 767 | continue; |
| 768 | } |
| 769 | |
| 770 | addRegionMaps(*ft, std::move(l), Region::TYPE_STATE); |
| 771 | } |
| 772 | |
| 773 | filter = m_localitiesCaches.m_citiesTownsOrVillages.Get(*m_context); |
| 774 | FillLocalityCandidates(ctx, filter, kMaxNumCities, preLocalities); |
| 775 | for (auto & l : preLocalities) |
| 776 | { |
| 777 | auto ft = m_context->GetFeature(l.GetFeatureIndex()); |
| 778 | if (!ft) |
| 779 | { |
| 780 | LOG(LWARNING, ("Failed to get city", l.m_featureId)); |
nothing calls this directly
no test coverage detected