From fb72c121528ecb0939a19d908663b19584e0cb35 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Mon, 27 Jun 2022 11:18:26 +0300 Subject: [PATCH] [generator][routing] Ignore access=destination for motorway/trunk/primary. Signed-off-by: Viktor Govako --- generator/road_access_generator.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/generator/road_access_generator.cpp b/generator/road_access_generator.cpp index 6820b52aa7..e653951f97 100644 --- a/generator/road_access_generator.cpp +++ b/generator/road_access_generator.cpp @@ -155,6 +155,7 @@ TagMapping const kDefaultTagMapping = { {OsmElement::Tag("access", "forestry"), RoadAccess::Type::Private}, }; +/// @todo Looks controversial especially for primary/secondary. std::set const kHighwaysWhereIgnoreBarriersWithoutAccess = { {OsmElement::Tag("highway", "motorway")}, {OsmElement::Tag("highway", "motorway_link")}, @@ -175,6 +176,15 @@ std::set const kIgnoreAccess = { {OsmElement::Tag("highway", "motorway_junction")} }; +std::set const kHighwaysWhereIgnoreAccessDestination = { + {OsmElement::Tag("highway", "motorway")}, + {OsmElement::Tag("highway", "motorway_link")}, + {OsmElement::Tag("highway", "primary")}, + {OsmElement::Tag("highway", "primary_link")}, + {OsmElement::Tag("highway", "trunk")}, + {OsmElement::Tag("highway", "trunk_link")} +}; + auto const kEmptyAccess = RoadAccess::Type::Count; bool ParseRoadAccess(string const & roadAccessPath, OsmIdToFeatureIds const & osmIdToFeatureIds, @@ -492,12 +502,20 @@ void RoadAccessTagProcessor::Process(OsmElement const & elem) if (op == RoadAccess::Type::Yes) return; - switch (elem.m_type) + if (op == RoadAccess::Type::Destination) { - case OsmElement::EntityType::Node: m_barriersWithAccessTag.emplace(elem.m_id, op); return; - case OsmElement::EntityType::Way: m_wayToAccess.emplace(elem.m_id, op); return; - default: return; + for (auto const & tag : elem.m_tags) + { + if (kHighwaysWhereIgnoreAccessDestination.count(tag)) + return; + } } + + if (elem.IsNode()) + m_barriersWithAccessTag.emplace(elem.m_id, op); + else if (elem.IsWay()) + m_wayToAccess.emplace(elem.m_id, op); + return; } if (!elem.IsNode()) @@ -613,10 +631,11 @@ std::shared_ptr RoadAccessWriter::Clone( void RoadAccessWriter::CollectFeature(FeatureBuilder const & fb, OsmElement const & elem) { for (auto const & tag : elem.m_tags) + { if (kIgnoreAccess.count(tag)) return; + } - /// @todo Hm, should we process elem (access candidates) for non-roads? for (auto & p : m_tagProcessors) { p.Process(elem);