Skip to content

Commit

Permalink
do not change fork directions when combining turns
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Aug 16, 2017
1 parent 37c941d commit 196ed9e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 4 additions & 2 deletions features/guidance/perception.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
26 changes: 25 additions & 1 deletion src/engine/guidance/collapse_turns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 196ed9e

Please sign in to comment.