| 207 | namespace matcher |
| 208 | { |
| 209 | pugi::xml_node GetBestOsmNode(pugi::xml_document const & osmResponse, ms::LatLon const & latLon) |
| 210 | { |
| 211 | double bestScore = geometry::kPenaltyScore; |
| 212 | pugi::xml_node bestMatchNode; |
| 213 | |
| 214 | for (auto const & xNode : osmResponse.select_nodes("osm/node")) |
| 215 | { |
| 216 | try |
| 217 | { |
| 218 | XMLFeature const xmlFeature(xNode.node()); |
| 219 | |
| 220 | double const nodeScore = ScoreLatLon(xmlFeature, latLon); |
| 221 | if (nodeScore < 0) |
| 222 | continue; |
| 223 | |
| 224 | if (bestScore < nodeScore) |
| 225 | { |
| 226 | bestScore = nodeScore; |
| 227 | bestMatchNode = xNode.node(); |
| 228 | } |
| 229 | } |
| 230 | catch (editor::NoLatLon const & ex) |
| 231 | { |
| 232 | LOG(LWARNING, ("No lat/lon attribute in osm response node.", ex.Msg())); |
| 233 | continue; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | // TODO(mgsergio): Add a properly defined threshold when more fields will be compared. |
| 238 | // if (bestScore < kMiniScoreThreshold) |
| 239 | // return pugi::xml_node; |
| 240 | |
| 241 | return bestMatchNode; |
| 242 | } |
| 243 | |
| 244 | pugi::xml_node GetBestOsmWayOrRelation(pugi::xml_document const & osmResponse, std::vector<m2::PointD> const & geometry) |
| 245 | { |