| 36 | } |
| 37 | |
| 38 | std::optional<m2::PointD> FeatureMakerSimple::GetOrigin(OsmElement const & e) const |
| 39 | { |
| 40 | if (e.IsNode()) |
| 41 | { |
| 42 | CHECK(e.m_lat != 0 || e.m_lon != 0, (e.m_id)); |
| 43 | return mercator::FromLatLon(e.m_lat, e.m_lon); |
| 44 | } |
| 45 | else if (e.IsWay()) |
| 46 | { |
| 47 | CHECK(!e.m_nodes.empty(), (e.m_id)); |
| 48 | return ReadNode(e.m_nodes.front()); |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | if (e.m_members.empty()) |
| 53 | { |
| 54 | // Such relations are considered invalid but could be present in OSM data still, |
| 55 | // see https://wiki.openstreetmap.org/wiki/Empty_relations |
| 56 | LOG(LWARNING, ("Invalid relation with no members", e.m_id)); |
| 57 | return {}; |
| 58 | } |
| 59 | for (auto const & m : e.m_members) |
| 60 | if (m.m_type == OsmElement::EntityType::Node) |
| 61 | return ReadNode(m.m_ref); |
| 62 | |
| 63 | for (auto const & m : e.m_members) |
| 64 | { |
| 65 | if (m.m_type == OsmElement::EntityType::Way) |
| 66 | { |
| 67 | WayElement way(m.m_ref); |
| 68 | if (m_cache->GetWay(m.m_ref, way)) |
| 69 | { |
| 70 | CHECK(!way.m_nodes.empty(), (m.m_ref)); |
| 71 | return ReadNode(way.m_nodes.front()); |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | LOG(LWARNING, ("No geometry members for relation", e.m_id)); |
| 77 | return {}; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | bool FeatureMakerSimple::BuildFromNode(OsmElement & p, FeatureBuilderParams const & params) |
| 82 | { |