From 4d0fb894891cb2a40f4a50b5a5364f047ef70fd9 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 25 Feb 2018 10:49:52 +0100 Subject: [PATCH] Adjust Straight direction modifiers of side roads in driveway handler --- features/guidance/driveway.feature | 20 ++++++++++++++++++++ src/guidance/driveway_handler.cpp | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/features/guidance/driveway.feature b/features/guidance/driveway.feature index c7e7504eb..7bc3b2605 100644 --- a/features/guidance/driveway.feature +++ b/features/guidance/driveway.feature @@ -46,3 +46,23 @@ Feature: Driveways intersections When I route I should get | waypoints | route | turns | locations | | a,d | ,second | depart,arrive | a,d | + + + Scenario: Road with a turn to service road + Given the node map + """ + /-----------------e + a---b------------------c + `-----------------d + """ + + And the ways + | nodes | highway | name | oneway | + | abc | trunk | road | yes | + | bd | service | serv | yes | + | be | service | serv | yes | + + When I route I should get + | waypoints | route | turns | locations | + | a,d | road,serv,serv | depart,turn slight right,arrive | a,b,d | + | a,e | road,serv,serv | depart,turn slight left,arrive | a,b,e | diff --git a/src/guidance/driveway_handler.cpp b/src/guidance/driveway_handler.cpp index 8b48a340a..3c37ae262 100644 --- a/src/guidance/driveway_handler.cpp +++ b/src/guidance/driveway_handler.cpp @@ -78,6 +78,18 @@ operator()(const NodeID nid, const EdgeID source_edge_id, Intersection intersect road->instruction.type = isSameName(source_edge_id, road->eid) ? TurnType::NoTurn : TurnType::NewName; + if (road->instruction.direction_modifier == DirectionModifier::Straight) + { + std::for_each(intersection.begin() + 1, road, [](auto &side_road) { + if (side_road.instruction.direction_modifier == DirectionModifier::Straight) + side_road.instruction.direction_modifier = DirectionModifier::SlightRight; + }); + std::for_each(road + 1, intersection.end(), [](auto &side_road) { + if (side_road.instruction.direction_modifier == DirectionModifier::Straight) + side_road.instruction.direction_modifier = DirectionModifier::SlightLeft; + }); + } + return intersection; }