| 190 | } |
| 191 | |
| 192 | editor::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 | |
| 232 | void ChangesetWrapper::Create(editor::XMLFeature node) |
| 233 | { |
no test coverage detected