diff --git a/features/guidance/collapse.feature b/features/guidance/collapse.feature index 6ccffc7fc..043240a0e 100644 --- a/features/guidance/collapse.feature +++ b/features/guidance/collapse.feature @@ -900,3 +900,27 @@ Feature: Collapse When I route I should get | waypoints | route | turns | | 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 | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 0671712e5..60bf7feb5 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -483,10 +483,12 @@ void collapseTurnAt(std::vector &steps, const auto next_step_index = step_index + 1; const bool continues_with_name_change = (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)); 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]); if (direct_u_turn || u_turn_with_name_change) @@ -842,7 +844,7 @@ std::vector collapseTurns(std::vector steps) } else { - //the sliproad turn is incompatible. So we handle it as a turn + // the sliproad turn is incompatible. So we handle it as a turn steps[one_back_index].maneuver.instruction.type = TurnType::Turn; } } @@ -1326,8 +1328,7 @@ std::vector collapseUseLane(std::vector steps) for (std::size_t step_index = 1; step_index < steps.size(); ++step_index) { const auto &step = steps[step_index]; - if (step.maneuver.instruction.type == TurnType::UseLane && - canCollapseUseLane(step)) + if (step.maneuver.instruction.type == TurnType::UseLane && canCollapseUseLane(step)) { const auto previous = getPreviousIndex(step_index); steps[previous] = elongate(std::move(steps[previous]), steps[step_index]);