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

Function FindClusters

generator/place_processor.cpp:137–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137std::vector<std::vector<FeaturePlace const *>> FindClusters(std::vector<FeaturePlace> const & places)
138{
139 auto const & localityChecker = ftypes::IsLocalityChecker::Instance();
140
141 auto getRaduis = [&localityChecker](FeaturePlace const & fp)
142 { return GetRadiusM(localityChecker.GetType(fp.GetPlaceType())); };
143
144 auto isSamePlace = [&localityChecker](FeaturePlace const & lFP, FeaturePlace const & rFP)
145 {
146 if (lFP.m_rect.IsIntersect(rFP.m_rect))
147 return true;
148
149 // If we have "true" boundaries and they are not intersecting - return false.
150 // IsEmptyInterior() == true for Point FB.
151 if (!lFP.m_rect.IsEmptyInterior() && !rFP.m_rect.IsEmptyInterior())
152 return false;
153
154 /// @todo Small hack here. Need to check enclosing/parent region.
155 /// @see https://github.com/organicmaps/organicmaps/issues/2035 for more details.
156 // Do not merge places with different ranks (population). See https://www.openstreetmap.org/#map=15/33.0145/-92.7249
157 // Junction City in Arkansas and Louisiana.
158 if (lFP.GetRank() > 0 && rFP.GetRank() > 0 && lFP.GetRank() != rFP.GetRank())
159 return false;
160
161 // Assume that equal-type localities within some fixed radius (GetRadiusM) are the same.
162 return localityChecker.GetType(lFP.GetPlaceType()) == localityChecker.GetType(lFP.GetPlaceType());
163 };
164
165 return GetClusters(places, std::move(getRaduis), std::move(isSamePlace));
166}
167
168PlaceProcessor::PlaceProcessor(std::string const & filename) : m_logTag("PlaceProcessor")
169{

Callers 1

ProcessPlacesMethod · 0.85

Calls 7

GetRadiusMFunction · 0.85
GetClustersFunction · 0.85
GetPlaceTypeMethod · 0.80
IsEmptyInteriorMethod · 0.80
GetTypeMethod · 0.45
IsIntersectMethod · 0.45
GetRankMethod · 0.45

Tested by

no test coverage detected