Skip to content

Commit fc5dfe2

Browse files
authored
Fix crash when route starts/ends at manoeuvre relation via node (#7339)
* Fix assertion failure in collapseSegregatedTurnInstructions * Add test for routes starting/ending at manoeuvre=fork via node * Skip manoeuvre overrides on depart/arrive waypoint steps * Improve the log * Fix the format
1 parent 0a2edf8 commit fc5dfe2

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22
- Changes from 6.0.0
3+
- Routing:
4+
- FIXED: Crash when route starts or ends at `type=manoeuvre` relation via node [#7287](https://github.com/Project-OSRM/osrm-backend/issues/7287)
35
- Profiles:
46
- ADDED: Add exception for audible fences (`barrier=fence` with `sensory=audible` or `sensory=audio`) that deter livestock but do not block vehicles [#6964](https://github.com/Project-OSRM/osrm-backend/issues/6964)
57
- ADDED: Use `is_sidepath:of:name` and `street:name` as fallback names for unnamed sidewalks and sidepaths in foot and bicycle profiles [#7259](https://github.com/Project-OSRM/osrm-backend/issues/7259)

features/guidance/collapse-detail.feature

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,63 @@ Feature: Collapse
176176
When I route I should get
177177
| waypoints | route | turns |
178178
| c,e | road,,, | depart,turn right,turn right,arrive |
179+
180+
# Route starting at via node of manoeuvre=fork relation
181+
@manoeuvre-fork
182+
Scenario: Route starting at fork node with manoeuvre relation
183+
Given the node map
184+
"""
185+
c
186+
/
187+
a-----b
188+
\
189+
d-----e
190+
"""
191+
192+
And the ways
193+
| nodes | highway | name | oneway |
194+
| ab | motorway | main | yes |
195+
| bc | motorway | left | yes |
196+
| bd | motorway | right | yes |
197+
| de | motorway | right | yes |
198+
199+
And the relations
200+
| type | way:from | node:via | way:to | manoeuvre | direction |
201+
| manoeuvre | ab | b | bc | fork | slight_left |
202+
| manoeuvre | ab | b | bd | fork | slight_right |
203+
204+
When I route I should get
205+
| waypoints | route | turns |
206+
| a,c | main,left,left | depart,fork slight left,arrive |
207+
| a,e | main,right,right | depart,fork slight right,arrive |
208+
# Depart from fork via node - no fork instruction needed
209+
| b,c | left,left | depart,arrive |
210+
| b,e | right,right | depart,arrive |
211+
212+
# Route ending at via node of manoeuvre=fork relation
213+
@manoeuvre-fork
214+
Scenario: Route ending at fork node with manoeuvre relation
215+
Given the node map
216+
"""
217+
c
218+
/
219+
a-----b
220+
\
221+
d-----e
222+
"""
223+
224+
And the ways
225+
| nodes | highway | name | oneway |
226+
| ab | motorway | main | yes |
227+
| bc | motorway | left | yes |
228+
| bd | motorway | right | yes |
229+
| de | motorway | right | yes |
230+
231+
And the relations
232+
| type | way:from | node:via | way:to | manoeuvre | direction |
233+
| manoeuvre | ab | b | bc | fork | slight_left |
234+
| manoeuvre | ab | b | bd | fork | slight_right |
235+
236+
When I route I should get
237+
| waypoints | route | turns |
238+
| a,b | main,main | depart,arrive |

src/engine/guidance/collapse_turns.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,13 @@ void suppressStep(RouteStep &step_at_turn_location, RouteStep &step_after_turn_l
591591
[[nodiscard]] RouteSteps collapseSegregatedTurnInstructions(RouteSteps steps)
592592
{
593593
// make sure we can safely iterate over all steps (has depart/arrive with TurnType::NoTurn)
594+
// Return early if preconditions aren't met (can happen with certain manoeuvre relations)
595+
if (hasTurnType(steps.front()) || hasTurnType(steps.back()))
596+
return steps;
597+
598+
if (!hasWaypointType(steps.front()) || !hasWaypointType(steps.back()))
599+
return steps;
600+
594601
BOOST_ASSERT(!hasTurnType(steps.front()) && !hasTurnType(steps.back()));
595602
BOOST_ASSERT(hasWaypointType(steps.front()) && hasWaypointType(steps.back()));
596603

src/engine/guidance/post_processing.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,14 @@ void applyOverrides(const datafacade::BaseDataFacade &facade,
679679
// in its geometry
680680
if (step_to_update != route_iter)
681681
{
682-
// Don't update the last step (it's an arrive instruction)
682+
// Manoeuvre overrides apply to driving maneuvers, not waypoint steps.
683+
// Depart/arrive steps mark route endpoints and should keep NoTurn type.
684+
if (hasWaypointType(*step_to_update))
685+
{
686+
util::Log(logDEBUG)
687+
<< "Skipping maneuver override on waypoint step" << std::endl;
688+
continue;
689+
}
683690
util::Log(logDEBUG) << "Updating step "
684691
<< std::distance(steps.begin(), steps.end()) -
685692
std::distance(step_to_update, steps.end())

0 commit comments

Comments
 (0)