From 196ed9eb4616de940c2a890bb2d162c8612b391c Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Mon, 14 Aug 2017 13:48:43 +0200 Subject: [PATCH] do not change fork directions when combining turns --- features/guidance/perception.feature | 6 ++++-- src/engine/guidance/collapse_turns.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/features/guidance/perception.feature b/features/guidance/perception.feature index 1758dff6d57..0d008a48ff4 100644 --- a/features/guidance/perception.feature +++ b/features/guidance/perception.feature @@ -97,5 +97,7 @@ Feature: Simple Turns | ei | left | yes | When I route I should get - | waypoints | route | turns | - | g,a | in,road,road | depart,fork right,arrive | + | waypoints | route | turns | + | g,a | in,road,road | depart,fork slight right,arrive | + | g,h | in,right,right | depart,fork straight,arrive | + | g,i | in,left,left | depart,fork slight left,arrive | diff --git a/src/engine/guidance/collapse_turns.cpp b/src/engine/guidance/collapse_turns.cpp index 6b95a4bbae2..694194cb431 100644 --- a/src/engine/guidance/collapse_turns.cpp +++ b/src/engine/guidance/collapse_turns.cpp @@ -158,6 +158,18 @@ void TransferTurnTypeStrategy::operator()(RouteStep &step_at_turn_location, void AdjustToCombinedTurnAngleStrategy::operator()(RouteStep &step_at_turn_location, const RouteStep &transfer_from_step) const { + // Forks point to left/right. By doing a combined angle, we would risk ending up with + // unreasonable fork instrucitons. The direction of a fork only depends on the forking location, + // not further angles coming up + // + // d + // . c + // a - b + // + // could end up as `fork left` for `a-b-c`, instead of fork-right + if (hasTurnType(step_at_turn_location, TurnType::Fork)) + return; + // TODO assert transfer_from_step == step_at_turn_location + 1 const auto angle = findTotalTurnAngle(step_at_turn_location, transfer_from_step); step_at_turn_location.maneuver.instruction.direction_modifier = getTurnDirection(angle); @@ -173,7 +185,19 @@ void AdjustToCombinedTurnStrategy::operator()(RouteStep &step_at_turn_location, const RouteStep &transfer_from_step) const { const auto angle = findTotalTurnAngle(step_at_turn_location, transfer_from_step); - const auto new_modifier = getTurnDirection(angle); + + // Forks point to left/right. By doing a combined angle, we would risk ending up with + // unreasonable fork instrucitons. The direction of a fork only depends on the forking location, + // not further angles coming up + // + // d + // . c + // a - b + // + // could end up as `fork left` for `a-b-c`, instead of fork-right + const auto new_modifier = hasTurnType(step_at_turn_location, TurnType::Fork) + ? step_at_turn_location.maneuver.instruction.direction_modifier + : getTurnDirection(angle); // a turn that is a new name or straight (turn/continue) const auto is_non_turn = [](const RouteStep &step) {