Skip to content

Commit 196ed9e

Browse files
author
Moritz Kobitzsch
committed
do not change fork directions when combining turns
1 parent 37c941d commit 196ed9e

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

features/guidance/perception.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,7 @@ Feature: Simple Turns
9797
| ei | left | yes |
9898

9999
When I route I should get
100-
| waypoints | route | turns |
101-
| g,a | in,road,road | depart,fork right,arrive |
100+
| waypoints | route | turns |
101+
| g,a | in,road,road | depart,fork slight right,arrive |
102+
| g,h | in,right,right | depart,fork straight,arrive |
103+
| g,i | in,left,left | depart,fork slight left,arrive |

src/engine/guidance/collapse_turns.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ void TransferTurnTypeStrategy::operator()(RouteStep &step_at_turn_location,
158158
void AdjustToCombinedTurnAngleStrategy::operator()(RouteStep &step_at_turn_location,
159159
const RouteStep &transfer_from_step) const
160160
{
161+
// Forks point to left/right. By doing a combined angle, we would risk ending up with
162+
// unreasonable fork instrucitons. The direction of a fork only depends on the forking location,
163+
// not further angles coming up
164+
//
165+
// d
166+
// . c
167+
// a - b
168+
//
169+
// could end up as `fork left` for `a-b-c`, instead of fork-right
170+
if (hasTurnType(step_at_turn_location, TurnType::Fork))
171+
return;
172+
161173
// TODO assert transfer_from_step == step_at_turn_location + 1
162174
const auto angle = findTotalTurnAngle(step_at_turn_location, transfer_from_step);
163175
step_at_turn_location.maneuver.instruction.direction_modifier = getTurnDirection(angle);
@@ -173,7 +185,19 @@ void AdjustToCombinedTurnStrategy::operator()(RouteStep &step_at_turn_location,
173185
const RouteStep &transfer_from_step) const
174186
{
175187
const auto angle = findTotalTurnAngle(step_at_turn_location, transfer_from_step);
176-
const auto new_modifier = getTurnDirection(angle);
188+
189+
// Forks point to left/right. By doing a combined angle, we would risk ending up with
190+
// unreasonable fork instrucitons. The direction of a fork only depends on the forking location,
191+
// not further angles coming up
192+
//
193+
// d
194+
// . c
195+
// a - b
196+
//
197+
// could end up as `fork left` for `a-b-c`, instead of fork-right
198+
const auto new_modifier = hasTurnType(step_at_turn_location, TurnType::Fork)
199+
? step_at_turn_location.maneuver.instruction.direction_modifier
200+
: getTurnDirection(angle);
177201

178202
// a turn that is a new name or straight (turn/continue)
179203
const auto is_non_turn = [](const RouteStep &step) {

0 commit comments

Comments
 (0)