From ceaf065d0e86f72bb720d497de4016113a9a467d Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Tue, 23 May 2017 11:42:23 +0200 Subject: [PATCH] don't collapse highway ramps into uturns (#4074) --- CHANGELOG.md | 1 + features/car/summaries.feature | 4 +- features/guidance/turn.feature | 40 +++++++++++++++++++ include/util/guidance/name_announcements.hpp | 5 ++- .../guidance/collapse_scenario_detection.cpp | 6 +++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a461f0d45..022516a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - #4075 Changed counting of exits on service roundabouts - Bugfixes - Fixed a copy/paste issue assigning wrong directions in similar turns (left over right) + - #4074: fixed a bug that would announce entering highway ramps as u-turns # 5.7.1 - Bugfixes diff --git a/features/car/summaries.feature b/features/car/summaries.feature index 27cb406e7..688f203b0 100644 --- a/features/car/summaries.feature +++ b/features/car/summaries.feature @@ -60,8 +60,8 @@ Feature: Basic Routing | bc | | 101 | When I route I should get - | waypoints | route | summary | - | a,c | road, | road, 101 | + | waypoints | route | summary | + | a,c | road,, | road, 101 | Scenario: Only Refs Given the node map diff --git a/features/guidance/turn.feature b/features/guidance/turn.feature index cc39956f8..f002d67e3 100644 --- a/features/guidance/turn.feature +++ b/features/guidance/turn.feature @@ -1279,3 +1279,43 @@ Feature: Simple Turns When I route I should get | waypoints | route | turns | | a,d | foo,bar,bar | depart,turn slight right,arrive | + + Scenario: UTurn onto ramp + Given the node map + """ + a - - - b - c + .| + _________________ de + h-g-----------------------f + """ + And the ways + | nodes | name | ref | oneway | highway | + | abc | Road | | yes | primary | + | ce | other | | yes | primary | + | cdg | | | yes | motorway_link | + | fgh | | C 42 | yes | motorway | + + + When I route I should get + | waypoints | route | ref | turns | + | a,h | Road,,, | ,,C 42,C 42 | depart,on ramp right,merge slight left,arrive | + + Scenario: UTurn onto ramp (same ref) + Given the node map + """ + a - - - b - c + .| + _________________ de + h-g-----------------------f + """ + And the ways + | nodes | name | ref | oneway | highway | + | abc | Road | C 42 | yes | primary | + | ce | other | | yes | primary | + | cdg | | | yes | motorway_link | + | fgh | | C 42 | yes | motorway | + + + When I route I should get + | waypoints | route | ref | turns | + | a,h | Road,,, | C 42,,C 42,C 42 | depart,on ramp right,merge slight left,arrive | diff --git a/include/util/guidance/name_announcements.hpp b/include/util/guidance/name_announcements.hpp index 098a7b80a..a43706cb8 100644 --- a/include/util/guidance/name_announcements.hpp +++ b/include/util/guidance/name_announcements.hpp @@ -123,8 +123,9 @@ inline bool requiresNameAnnounced(const std::string &from_name, (names_are_equal && ref_is_removed) || is_suffix_change; const auto needs_announce = - // " (Ref)" -> "Name " - (from_name.empty() && !from_ref.empty() && !to_name.empty() && to_ref.empty()); + // " (Ref)" -> "Name " and reverse + (from_name.empty() && !from_ref.empty() && !to_name.empty() && to_ref.empty()) || + (!from_name.empty() && from_ref.empty() && to_name.empty() && !to_ref.empty()); const auto pronunciation_changes = from_pronunciation != to_pronunciation; diff --git a/src/engine/guidance/collapse_scenario_detection.cpp b/src/engine/guidance/collapse_scenario_detection.cpp index 2f26ed190..530d353ff 100644 --- a/src/engine/guidance/collapse_scenario_detection.cpp +++ b/src/engine/guidance/collapse_scenario_detection.cpp @@ -147,6 +147,12 @@ bool isUTurn(const RouteStepIterator step_prior_to_intersection, step_prior_to_intersection, step_entering_intersection, step_leaving_intersection)) return false; + // uturns only allowed on turns + if (!hasTurnType(*step_entering_intersection, TurnType::Turn) && + !hasTurnType(*step_entering_intersection, TurnType::Continue) && + !hasTurnType(*step_entering_intersection, TurnType::EndOfRoad)) + return false; + // the most basic condition for a uturn is that we actually turn around const bool takes_u_turn = bearingsAreReversed( util::bearing::reverse(step_entering_intersection->intersections.front()