From 378322f6e3ea0bb29dbfd5109873c5a20570278d Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Wed, 5 Oct 2016 10:44:41 +0200 Subject: [PATCH] don't provide turn-straight next to suppress-straight --- features/guidance/turn.feature | 70 +++++++++++++++++++++++++ src/extractor/guidance/turn_handler.cpp | 22 ++++++-- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/features/guidance/turn.feature b/features/guidance/turn.feature index 078353475..73b23ae99 100644 --- a/features/guidance/turn.feature +++ b/features/guidance/turn.feature @@ -1080,3 +1080,73 @@ Feature: Simple Turns | f,a | depart,arrive | Hermannstr,Hermannstr | | y,f | depart,arrive | Hermannstr,Hermannstr | | f,y | depart,arrive | Hermannstr,Hermannstr | + + # http://www.openstreetmap.org/#map=18/39.28158/-76.62291 + @3002 + Scenario: Obvious Index wigh very narrow turn to the right + Given the node map + | a | | b | | | | | | c | + | | | | | | | | | d | + + And the ways + | nodes | highway | name | + | abc | primary | road | + | bd | primary_link | | + + When I route I should get + | waypoints | turns | route | + | a,c | depart,arrive | road,road | + | a,d | depart,turn slight right,arrive | road,, | + + # http://www.openstreetmap.org/#map=18/39.28158/-76.62291 + @3002 + Scenario: Obvious Index wigh very narrow turn to the right + Given the node map + | a | | b | | | | | | c | | + | | | | | e | | | | d | f | + + And the ways + | nodes | highway | name | + | abc | primary | road | + | bd | primary_link | | + | edf | primary_link | | + + When I route I should get + | waypoints | turns | route | + | a,c | depart,arrive | road,road | + | a,f | depart,turn slight right,arrive | road,, | + + # http://www.openstreetmap.org/#map=18/39.28158/-76.62291 + @3002 + Scenario: Obvious Index wigh very narrow turn to the left + Given the node map + | | | | | | | | | d | + | a | | b | | | | | | c | + + And the ways + | nodes | highway | name | + | abc | primary | road | + | bd | primary_link | | + + When I route I should get + | waypoints | turns | route | + | a,c | depart,arrive | road,road | + | a,d | depart,turn slight left,arrive | road,, | + + # http://www.openstreetmap.org/#map=18/39.28158/-76.62291 + @3002 + Scenario: Obvious Index wigh very narrow turn to the left + Given the node map + | | | | | e | | | | d | f | + | a | | b | | | | | | c | | + + And the ways + | nodes | highway | name | + | abc | primary | road | + | bd | primary_link | | + | edf | primary_link | | + + When I route I should get + | waypoints | turns | route | + | a,f | depart,turn slight left,arrive | road,, | + | a,c | depart,arrive | road,road | diff --git a/src/extractor/guidance/turn_handler.cpp b/src/extractor/guidance/turn_handler.cpp index 593c3c85c..0b81f1377 100644 --- a/src/extractor/guidance/turn_handler.cpp +++ b/src/extractor/guidance/turn_handler.cpp @@ -1,7 +1,7 @@ -#include "extractor/guidance/turn_handler.hpp" #include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_scenario_three_way.hpp" #include "extractor/guidance/toolkit.hpp" +#include "extractor/guidance/turn_handler.hpp" #include "util/guidance/toolkit.hpp" @@ -166,6 +166,8 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection } else { + const auto direction_at_one = getTurnDirection(intersection[1].turn.angle); + const auto direction_at_two = getTurnDirection(intersection[2].turn.angle); if (obvious_index == 1) { intersection[1].turn.instruction = getInstructionForObvious( @@ -173,8 +175,13 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection } else { - intersection[1].turn.instruction = {findBasicTurnType(via_edge, intersection[1]), - getTurnDirection(intersection[1].turn.angle)}; + if (obvious_index != 0 && direction_at_one == direction_at_two && + direction_at_one == DirectionModifier::Straight) + intersection[1].turn.instruction = {findBasicTurnType(via_edge, intersection[1]), + DirectionModifier::SlightRight}; + else + intersection[1].turn.instruction = {findBasicTurnType(via_edge, intersection[1]), + direction_at_one}; } if (obvious_index == 2) @@ -184,8 +191,13 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection } else { - intersection[2].turn.instruction = {findBasicTurnType(via_edge, intersection[2]), - getTurnDirection(intersection[2].turn.angle)}; + if (obvious_index != 0 && direction_at_one == direction_at_two && + direction_at_two == DirectionModifier::Straight) + intersection[2].turn.instruction = {findBasicTurnType(via_edge, intersection[2]), + DirectionModifier::SlightLeft}; + else + intersection[2].turn.instruction = {findBasicTurnType(via_edge, intersection[2]), + direction_at_two}; } } return intersection;