Skip to content

Commit

Permalink
Emit a notification when turning on a ferry and don't merge step
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarex committed Apr 7, 2017
1 parent 402ceae commit 976f874
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
28 changes: 15 additions & 13 deletions features/guidance/roundabout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -687,21 +687,23 @@ Feature: Basic Roundabout
Scenario: Only Enter
Given the node map
"""
a
b
c e ~ ~ ~ f - h
d
g
a
b
i c e ~ ~ ~ f - h
j d
k g
"""

And the ways
| nodes | junction | route |
| ab | | |
| ef | | ferry |
| fh | | |
| dg | | |
| bcdeb | roundabout | |
| nodes | junction | route |
| ab | | |
| ef | | ferry |
| fh | | |
| dg | | |
| ic | | |
| jk | | |
| bcjdeb | roundabout | |

When I route I should get
| waypoints | route | turns |
| a,h | ab,ef,fh | depart,roundabout-exit-2,arrive |
| waypoints | route | turns |
| a,h | ab,ef,ef,fh,fh | depart,roundabout-exit-4,notification slight right,notification straight,arrive |
34 changes: 26 additions & 8 deletions src/engine/guidance/post_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ bool setUpRoundabout(RouteStep &step)

void closeOffRoundabout(const bool on_roundabout,
std::vector<RouteStep> &steps,
const std::size_t step_index)
std::size_t step_index)
{
auto &step = steps[step_index];
step.maneuver.exit += 1;
if (!on_roundabout)
{
BOOST_ASSERT(steps.size() >= 2);

// We reached a special case that requires the addition of a special route step in the
// beginning. We started in a roundabout, so to announce the exit, we move use the exit
// instruction and move it right to the beginning to make sure to immediately announce the
Expand Down Expand Up @@ -160,6 +162,23 @@ void closeOffRoundabout(const bool on_roundabout,
}
}

if (step_index > 1)
{
auto &exit_step = steps[step_index];
auto &prev_step = steps[step_index - 1];
// In case the step with the roundabout exit instruction cannot be merged with the
// previous step we change the instruction to a normal turn
if (!guidance::haveSameMode(exit_step, prev_step))
{
BOOST_ASSERT(leavesRoundabout(exit_step.maneuver.instruction));
prev_step.maneuver.instruction = exit_step.maneuver.instruction;
if (!entersRoundabout(prev_step.maneuver.instruction))
prev_step.maneuver.exit = exit_step.maneuver.exit;
exit_step.maneuver.instruction.type = TurnType::Notification;
step_index--;
}
}

// Normal exit from the roundabout, or exit from a previously fixed roundabout. Propagate the
// index back to the entering location and prepare the current silent set of instructions for
// removal.
Expand All @@ -170,15 +189,19 @@ void closeOffRoundabout(const bool on_roundabout,
const auto exit_intersection = steps[step_index].intersections.front();
const auto exit_bearing = exit_intersection.bearings[exit_intersection.out];
const auto destination_copy = step;

if (step_index > 1)
{
// The very first route-step is head, so we cannot iterate past that one
for (std::size_t propagation_index = step_index - 1; propagation_index > 0;
--propagation_index)
{
auto &propagation_step = steps[propagation_index];
propagation_step.ElongateBy(steps[propagation_index + 1]);
propagation_step.maneuver.exit = steps[propagation_index + 1].maneuver.exit;
auto &next_step = steps[propagation_index + 1];
propagation_step.ElongateBy(next_step);
propagation_step.maneuver.exit = next_step.maneuver.exit;
next_step.Invalidate();

if (entersRoundabout(propagation_step.maneuver.instruction))
{
const auto entry_intersection = propagation_step.intersections.front();
Expand Down Expand Up @@ -206,13 +229,8 @@ void closeOffRoundabout(const bool on_roundabout,
}

propagation_step.AdaptStepSignage(destination_copy);
steps[propagation_index + 1].Invalidate();
break;
}
else
{
steps[propagation_index + 1].Invalidate();
}
}
// remove exit
}
Expand Down

0 comments on commit 976f874

Please sign in to comment.