Skip to content

Commit b7daa7e

Browse files
authored
Gracefully handle no-turn intersections in guidance processing. (#6382)
Badly constructed OSM intersections can create OSRM intersection views that have no valid turns. The guidance code for segregated intersections tries to look ahead to the second intersection to ensure lanes are announced intuitively. Currently, OSRM assumes there are always turns at the second intersection that we should consider. This commit corrects this assumption so that it can now handle badly constructed OSM intersections with no turns.
1 parent 2188833 commit b7daa7e

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- FIXED: Fix snapping target locations to ways used in turn restrictions. [#6339](https://github.com/Project-OSRM/osrm-backend/pull/6339)
6363
- ADDED: Support OSM traffic signal directions. [#6153](https://github.com/Project-OSRM/osrm-backend/pull/6153)
6464
- FIXED: Ensure u-turn exists in intersection view. [#6376](https://github.com/Project-OSRM/osrm-backend/pull/6376)
65+
- FIXED: Gracefully handle no-turn intersections in guidance processing. [#6382](https://github.com/Project-OSRM/osrm-backend/issues/6382)
6566
- Profile:
6667
- CHANGED: Bicycle surface speeds [#6212](https://github.com/Project-OSRM/osrm-backend/pull/6212)
6768
- Tools:

features/guidance/bugs.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,37 @@ Feature: Features related to bugs
6767
When I route I should get
6868
| waypoints | route | intersections |
6969
| a,c | Pear to Merrit,Merritt to Apricot,Merritt to Apricot | true:0;true:0 false:180;true:180 |
70+
71+
72+
# https://github.com/Project-OSRM/osrm-backend/issues/6373
73+
Scenario: Segregated intersection with no second intersection turns
74+
Given the node map
75+
"""
76+
a b
77+
| |
78+
c--d--e--f
79+
| |
80+
g--h--i--j
81+
82+
"""
83+
84+
And the ways
85+
| nodes | oneway | lanes | turn:lanes |
86+
| dc | yes | 4 | |
87+
| ed | yes | 4 | |
88+
| fe | yes | 3 | |
89+
| gh | yes | 4 | left\|left\|through\|through;right |
90+
| hi | yes | 2 | |
91+
| ij | yes | 3 | |
92+
| ie | yes | 4 | |
93+
| eb | yes | 2 | |
94+
| ad | yes | 4 | reverse\|right\|right\|right |
95+
| dh | yes | | |
96+
97+
And the relations
98+
| type | way:from | way:to | node:via | restriction |
99+
| restriction | dh | hi | h | no_left_turn |
100+
101+
And the data has been saved to disk
102+
When I try to run "osrm-extract {osm_file} --profile {profile_file}"
103+
Then it should exit successfully

src/guidance/turn_lane_handler.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ TurnLaneScenario TurnLaneHandler::deduceScenario(const NodeID at,
329329
intersection)
330330
.first;
331331

332-
// check if we were successfull in trimming
332+
// check if we were successful in trimming
333333
if (lane_data.size() == possible_entries &&
334334
isSimpleIntersection(lane_data, intersection))
335335
return TurnLaneScenario::PARTITION_LOCAL;
@@ -556,7 +556,7 @@ std::pair<LaneDataVector, LaneDataVector> TurnLaneHandler::partitionLaneData(
556556
* into two parts, one for the first and one for the second intersection.
557557
*/
558558

559-
// Try and maitch lanes to available turns. For Turns that are not directly matchable, check
559+
// Try and match lanes to available turns. For Turns that are not directly matchable, check
560560
// whether we can match them at the upcoming intersection.
561561

562562
const auto straightmost = intersection.findClosestTurn(STRAIGHT_ANGLE);
@@ -675,10 +675,11 @@ std::pair<LaneDataVector, LaneDataVector> TurnLaneHandler::partitionLaneData(
675675
first.push_back(turn_lane_data[lane]);
676676
}
677677

678-
if (straightmost_tag_index == turn_lane_data.size() &&
678+
std::size_t num_next_intersection_turns = getNumberOfTurns(next_intersection);
679+
if (straightmost_tag_index == turn_lane_data.size() && num_next_intersection_turns > 0 &&
679680
static_cast<std::size_t>(
680681
std::count(matched_at_second.begin(), matched_at_second.end(), true)) ==
681-
getNumberOfTurns(next_intersection))
682+
num_next_intersection_turns)
682683
{
683684
TurnLaneData data = {TurnLaneType::straight, 255, 0};
684685
augmentEntry(data);

0 commit comments

Comments
 (0)