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

Function GetAffiliations

generator/affiliation.cpp:79–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77// An implementation for CountriesFilesAffiliation class.
78template <typename T>
79std::vector<std::string> GetAffiliations(T const & t, borders::CountryPolygonsCollection const & countryPolygonsTree,
80 bool haveBordersForWholeWorld)
81{
82 std::vector<std::string> countries;
83 std::vector<std::reference_wrapper<borders::CountryPolygons const>> countriesContainer;
84 countryPolygonsTree.ForEachCountryInRect(
85 GetLimitRect(t), [&](auto const & countryPolygons) { countriesContainer.emplace_back(countryPolygons); });
86
87 // todo(m.andrianov): We need to explore this optimization better. There is a hypothesis: some
88 // elements belong to a rectangle, but do not belong to the exact boundary.
89 if (haveBordersForWholeWorld && countriesContainer.size() == 1)
90 {
91 borders::CountryPolygons const & countryPolygons = countriesContainer.front();
92 countries.emplace_back(countryPolygons.GetName());
93 return countries;
94 }
95
96 for (borders::CountryPolygons const & countryPolygons : countriesContainer)
97 {
98 auto const need = ForAnyPoint(t, [&](auto const & point) { return countryPolygons.Contains(point); });
99
100 if (need)
101 countries.emplace_back(countryPolygons.GetName());
102 }
103
104 return countries;
105}
106
107// An implementation for CountriesFilesIndexAffiliation class.
108using IndexSharedPtr = std::shared_ptr<CountriesFilesIndexAffiliation::Tree>;

Callers 2

AppendToMwmTmpFunction · 0.70
GetAffiliationsMethod · 0.70

Calls 10

ForAnyPointFunction · 0.85
IsOneCountryForLimitRectFunction · 0.85
GetHonestAffiliationsFunction · 0.85
ForEachCountryInRectMethod · 0.80
frontMethod · 0.80
GetLimitRectFunction · 0.70
emplace_backMethod · 0.45
sizeMethod · 0.45
GetNameMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected