From 49ab05034687f55009cb03f9567abdfee24100d8 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 16 Feb 2018 11:43:48 +0100 Subject: [PATCH 1/2] Test case for a highway fork with a link --- features/guidance/motorway.feature | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/features/guidance/motorway.feature b/features/guidance/motorway.feature index 7717b612b71..cdc47885b7b 100644 --- a/features/guidance/motorway.feature +++ b/features/guidance/motorway.feature @@ -323,3 +323,25 @@ Feature: Motorway Guidance | a,c | ,, | depart,fork slight left,arrive | | a,e | ,,, | depart,fork slight right,fork slight left,arrive | | a,f | ,,, | depart,fork slight right,fork slight right,arrive | + + + # https://www.openstreetmap.org/#map=19/53.46186/-2.24509 + Scenario: Highway Fork with a Link + Given the node map + """ + /-----------d + a-b-c------------e + \-----------f + """ + + And the ways + | nodes | highway | + | abce | motorway | + | cf | motorway | + | cd | motorway_link | + + When I route I should get + | waypoints | route | turns | + | a,d | abce,cd,cd | depart,turn straight,arrive | + | a,e | abce,abce,abce | depart,fork slight left,arrive | + | a,f | abce,cf,cf | depart,fork slight right,arrive | From bf05ee0a4ce27caeaad99f0d7b141c41bc4a6137 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 16 Feb 2018 11:50:08 +0100 Subject: [PATCH 2/2] Handle motorway forks with links as a normal motorway ... passing some ramps or mering onto another motorway --- CHANGELOG.md | 1 + features/guidance/motorway.feature | 8 ++++---- src/guidance/motorway_handler.cpp | 20 ++++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be7976adf1..0c456a66e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - CHANGED #4835: MAXIMAL_ALLOWED_SEPARATION_WIDTH increased to 12 meters - CHANGED #4842: Lower priority links from a motorway now are used as motorway links [#4842](https://github.com/Project-OSRM/osrm-backend/pull/4842) - CHANGED #4895: Use ramp bifurcations as fork intersections [#4895](https://github.com/Project-OSRM/osrm-backend/issues/4895) + - CHANGED #4893: Handle motorway forks with links as normal motorway intersections[#4893](https://github.com/Project-OSRM/osrm-backend/issues/4893) - Profile: - FIXED: `highway=service` will now be used for restricted access, `access=private` is still disabled for snapping. - ADDED #4775: Exposes more information to the turn function, now being able to set turn weights with highway and access information of the turn as well as other roads at the intersection [#4775](https://github.com/Project-OSRM/osrm-backend/issues/4775) diff --git a/features/guidance/motorway.feature b/features/guidance/motorway.feature index cdc47885b7b..379b7382659 100644 --- a/features/guidance/motorway.feature +++ b/features/guidance/motorway.feature @@ -341,7 +341,7 @@ Feature: Motorway Guidance | cd | motorway_link | When I route I should get - | waypoints | route | turns | - | a,d | abce,cd,cd | depart,turn straight,arrive | - | a,e | abce,abce,abce | depart,fork slight left,arrive | - | a,f | abce,cf,cf | depart,fork slight right,arrive | + | waypoints | route | turns | + | a,d | abce,cd,cd | depart,off ramp slight left,arrive | + | a,e | abce,abce | depart,arrive | + | a,f | abce,cf,cf | depart,turn slight right,arrive | diff --git a/src/guidance/motorway_handler.cpp b/src/guidance/motorway_handler.cpp index 10889d5cf84..1e00b8a03c1 100644 --- a/src/guidance/motorway_handler.cpp +++ b/src/guidance/motorway_handler.cpp @@ -118,16 +118,6 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in node_data_container.GetAnnotation(node_based_graph.GetEdgeData(via_eid).annotation_data); BOOST_ASSERT(isMotorwayClass(via_eid, node_based_graph)); - const auto countExitingMotorways = [this](const Intersection &intersection) { - unsigned count = 0; - for (const auto &road : intersection) - { - if (road.entry_allowed && isMotorwayClass(road.eid, node_based_graph)) - ++count; - } - return count; - }; - // find the angle that continues on our current highway const auto getContinueAngle = [this, in_data](const Intersection &intersection) { for (const auto &road : intersection) @@ -219,7 +209,13 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in } else { - const unsigned exiting_motorways = countExitingMotorways(intersection); + const auto valid_exits = std::count_if(intersection.begin(), + intersection.end(), + [](const auto &road) { return road.entry_allowed; }); + const auto exiting_motorways = + std::count_if(intersection.begin(), intersection.end(), [this](const auto &road) { + return road.entry_allowed && isMotorwayClass(road.eid, node_based_graph); + }); if (exiting_motorways == 0) { @@ -233,7 +229,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in } } } - else if (exiting_motorways == 1) + else if (exiting_motorways == 1 || exiting_motorways != valid_exits) { // normal motorway passing some ramps or mering onto another motorway if (intersection.size() == 2)