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

Method GetMatchingAreaFeatureFromOSM

libs/editor/changeset_wrapper.cpp:192–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192editor::XMLFeature ChangesetWrapper::GetMatchingAreaFeatureFromOSM(std::vector<m2::PointD> const & geometry)
193{
194 auto constexpr kSamplePointsCount = 3;
195 bool hasRelation = false;
196 // Try several points in case of poor osm response.
197 for (auto const & pt : NaiveSample(geometry, kSamplePointsCount))
198 {
199 ms::LatLon const ll = mercator::ToLatLon(pt);
200 pugi::xml_document doc;
201 // Throws!
202 LoadXmlFromOSM(ll, doc);
203
204 if (doc.select_node("osm/relation"))
205 {
206 auto const rect = GetBoundingRect(geometry);
207 LoadXmlFromOSM(ms::LatLon(rect.minY(), rect.minX()), ms::LatLon(rect.maxY(), rect.maxX()), doc);
208 hasRelation = true;
209 }
210
211 pugi::xml_node const bestWayOrRelation = matcher::GetBestOsmWayOrRelation(doc, geometry);
212 if (!bestWayOrRelation)
213 {
214 if (hasRelation)
215 break;
216 continue;
217 }
218
219 if (!OsmFeatureHasTags(bestWayOrRelation))
220 {
221 std::ostringstream sstr;
222 bestWayOrRelation.print(sstr);
223 LOG(LDEBUG, ("The matched object has no tags", sstr.str()));
224 MYTHROW(EmptyFeatureException, ("The matched object has no tags"));
225 }
226
227 return {bestWayOrRelation};
228 }
229 MYTHROW(OsmObjectWasDeletedException, ("OSM does not have any matching way for feature"));
230}
231
232void ChangesetWrapper::Create(editor::XMLFeature node)
233{

Callers 1

Calls 11

NaiveSampleFunction · 0.85
GetBoundingRectFunction · 0.85
GetBestOsmWayOrRelationFunction · 0.85
OsmFeatureHasTagsFunction · 0.85
minYMethod · 0.80
minXMethod · 0.80
maxYMethod · 0.80
maxXMethod · 0.80
printMethod · 0.80
ToLatLonFunction · 0.50
LatLonClass · 0.50

Tested by

no test coverage detected