fix u-turn collapsing onto empty name / in presence of turning use lane
This commit is contained in:
parent
2d13116487
commit
1f8ca2879f
@ -900,3 +900,27 @@ Feature: Collapse
|
|||||||
When I route I should get
|
When I route I should get
|
||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| k,j | on,ferry,,ferry,off,off | depart,notification straight,continue uturn,turn straight,notification straight,arrive |
|
| k,j | on,ferry,,ferry,off,off | depart,notification straight,continue uturn,turn straight,notification straight,arrive |
|
||||||
|
|
||||||
|
# http://www.openstreetmap.org/#map=19/37.78090/-122.41251
|
||||||
|
Scenario: U-Turn onto unnamed-road
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
d . _ h
|
||||||
|
' b . _ |
|
||||||
|
| ' e g
|
||||||
|
| f '
|
||||||
|
| 1 '
|
||||||
|
a '
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | turn:lanes | name | oneway |
|
||||||
|
| ab | secondary | | up | yes |
|
||||||
|
| gfa | secondary | | | yes |
|
||||||
|
| dbe | tertiary | | turn | no |
|
||||||
|
| he | secondary | through\|right | down | yes |
|
||||||
|
| ef | secondary | | down | yes |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns |
|
||||||
|
| a,1 | up,turn,down, | depart,turn right,turn right,arrive |
|
||||||
|
@ -483,10 +483,12 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
|
|||||||
const auto next_step_index = step_index + 1;
|
const auto next_step_index = step_index + 1;
|
||||||
const bool continues_with_name_change =
|
const bool continues_with_name_change =
|
||||||
(next_step_index < steps.size()) &&
|
(next_step_index < steps.size()) &&
|
||||||
(steps[next_step_index].maneuver.instruction.type == TurnType::UseLane ||
|
((steps[next_step_index].maneuver.instruction.type == TurnType::UseLane &&
|
||||||
|
steps[next_step_index].maneuver.instruction.direction_modifier ==
|
||||||
|
DirectionModifier::Straight) ||
|
||||||
isCollapsableInstruction(steps[next_step_index].maneuver.instruction));
|
isCollapsableInstruction(steps[next_step_index].maneuver.instruction));
|
||||||
const bool u_turn_with_name_change =
|
const bool u_turn_with_name_change =
|
||||||
continues_with_name_change &&
|
continues_with_name_change && steps[next_step_index].name_id != EMPTY_NAMEID &&
|
||||||
!isNoticeableNameChange(steps[two_back_index], steps[next_step_index]);
|
!isNoticeableNameChange(steps[two_back_index], steps[next_step_index]);
|
||||||
|
|
||||||
if (direct_u_turn || u_turn_with_name_change)
|
if (direct_u_turn || u_turn_with_name_change)
|
||||||
@ -1326,8 +1328,7 @@ std::vector<RouteStep> collapseUseLane(std::vector<RouteStep> steps)
|
|||||||
for (std::size_t step_index = 1; step_index < steps.size(); ++step_index)
|
for (std::size_t step_index = 1; step_index < steps.size(); ++step_index)
|
||||||
{
|
{
|
||||||
const auto &step = steps[step_index];
|
const auto &step = steps[step_index];
|
||||||
if (step.maneuver.instruction.type == TurnType::UseLane &&
|
if (step.maneuver.instruction.type == TurnType::UseLane && canCollapseUseLane(step))
|
||||||
canCollapseUseLane(step))
|
|
||||||
{
|
{
|
||||||
const auto previous = getPreviousIndex(step_index);
|
const auto previous = getPreviousIndex(step_index);
|
||||||
steps[previous] = elongate(std::move(steps[previous]), steps[step_index]);
|
steps[previous] = elongate(std::move(steps[previous]), steps[step_index]);
|
||||||
|
Loading…
Reference in New Issue
Block a user