From 4629a20fe4899d2668ea43403b558a6028ed8ba5 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Wed, 15 Jun 2016 11:59:10 +0200 Subject: [PATCH] improve handling of obvious for end-of-road situations --- features/guidance/merge.feature | 24 ++++++++++++++++++++++++ features/guidance/turn.feature | 20 ++++++++++++++++++++ src/engine/guidance/post_processing.cpp | 14 ++++++++++++++ src/extractor/guidance/turn_handler.cpp | 4 +++- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/features/guidance/merge.feature b/features/guidance/merge.feature index 0736e8f7c..0190c8b89 100644 --- a/features/guidance/merge.feature +++ b/features/guidance/merge.feature @@ -50,3 +50,27 @@ Feature: Merging | waypoints | route | turns | | d,c | db,abc,abc | depart,merge slight left,arrive | + Scenario: Merge onto a turning road + Given the node map + | | | | | | | e | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | d | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | c | | | + | | | | b | | | | + | a | | | | | | f | + + And the ways + | nodes | highway | name | + | abcde | primary | road | + | fd | residential | in | + + When I route I should get + | waypoints | turns | route | + | f,e | depart,merge slight left,arrive | in,road,road | + | f,a | depart,turn sharp left,arrive | in,road,road | diff --git a/features/guidance/turn.feature b/features/guidance/turn.feature index d82b84928..0585ee1f1 100644 --- a/features/guidance/turn.feature +++ b/features/guidance/turn.feature @@ -833,3 +833,23 @@ Feature: Simple Turns | a,d | road,road | depart,arrive | | d,i | road,cross,cross | depart,turn left,arrive | | d,g | road,road | depart,arrive | + + Scenario: Go onto turning major road + Given the node map + | | | | c | + | | | | | + | | | | | + | a | | | b | + | | | | | + | | | | d | + + And the ways + | nodes | highway | name | + | abc | primary | road | + | bd | residential | in | + + When I route I should get + | waypoints | turns | route | + | a,c | depart,arrive | road,road | + | d,a | depart,turn left,arrive | in,road,road | + | d,c | depart,new name straight,arrive | in,road,road | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index eff6d93f5..1bc104b0b 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -419,6 +419,20 @@ void collapseTurnAt(std::vector &steps, current_step.name_id == steps[two_back_index].name_id) { steps[one_back_index].maneuver.instruction.type = TurnType::Continue; + + const auto getBearing = [](bool in, const RouteStep &step) + { + const auto index = + in ? step.intersections.front().in : step.intersections.front().out; + return step.intersections.front().bearings[index]; + }; + + // If we Merge onto the same street, we end up with a u-turn in some cases + if (bearingsAreReversed( + util::bearing::reverseBearing(getBearing(true, one_back_step)), + getBearing(false, current_step))) + steps[one_back_index].maneuver.instruction.direction_modifier = + DirectionModifier::UTurn; } else if (TurnType::Merge == one_back_step.maneuver.instruction.type && current_step.maneuver.instruction.type != diff --git a/src/extractor/guidance/turn_handler.cpp b/src/extractor/guidance/turn_handler.cpp index 1c770e236..44b4b61de 100644 --- a/src/extractor/guidance/turn_handler.cpp +++ b/src/extractor/guidance/turn_handler.cpp @@ -180,7 +180,9 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection I I */ - else if (isEndOfRoad(intersection[0], intersection[1], intersection[2])) + else if (isEndOfRoad(intersection[0], intersection[1], intersection[2]) && + !isObviousOfTwo(intersection[1], intersection[2]) && + !isObviousOfTwo(intersection[2], intersection[1])) { if (intersection[1].entry_allowed) {