Skip to content

Commit

Permalink
Added post process logic to collapse segregated turn instructions (#4925
Browse files Browse the repository at this point in the history
)

* Added post process logic to collapse segregated turn instructions

* format updates

* Fixed coordinates to reflect reality
Updated left turn road name

* fixed coordinates to fix test

* Skip last step when processing segregated steps

* updated segregated turn test

* Updated segregated test

* Updated test: Segregated Intersection, Cross Belonging to Correct Street - features/guidance/collapse.feature:79

* Fixed all but one for features/guidance/collapse.feature:124

* Fixed Scenario: Partly Segregated Intersection, Two Segregated Roads, Intersection belongs to Second - features/guidance/collapse.feature:219

* Fixed 7 of th 9 failures for Scenario: Partly Segregated Intersection, Two Segregated Roads, Intersection belongs to Second - features/guidance/collapse.feature:219

* Fixed 7 of the 9 failures for Scenario: Segregated Intersection, Cross Belonging to Mixed Streets - Slight Angles (2) - features/guidance/collapse.feature:318

* Fixed Scenario: Segregated Intersection into Slight Turn - features/guidance/collapse.feature:581

* Updated Scenario: U-turn after a traffic light - features/guidance/turn-lanes.feature:1220

* Updated how we combine segregated steps

* Added test to Verify end of road left turn across divided roads

* Fixed divided highwat tests

* Fixed test failure

* fixed Scenario: Partitioned turn, Slight Curve - maxspeed - features/guidance/turn-lanes.feature:936

* Fixed Scenario: Partitioned turn, Slight Curve - features/guidance/turn-lanes.feature:961

* Added strategies to combine segrgated intersections

* Added setModifier alias for readability

* Added strategies to combine segrgated intersections

* Format updates

* Fixes segregated indentification to not mark `circular` edge as segregated

* Added intersection prior to turn so we still call out end of road

* updated expectation to be turn instead of continue

* Confirmed with @oxidase that the lane information if correct - updated the expectation

* Added logic to handle wider straights
Fixed tests

* Update CHANGELOG.md

Added #4925

* Removed TODO

* Process straight step prior to wider straight step
  • Loading branch information
dgearhart authored Mar 30, 2018
1 parent 0d9f18f commit 8a63ad9
Show file tree
Hide file tree
Showing 11 changed files with 449 additions and 121 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
- Guidance:
- CHANGED #4929: Don't use obviousness for links bifurcations [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
- FIXED #4929: Adjust Straight direction modifiers of side roads in driveway handler [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
- CHANGED #4925: Added post process logic to collapse segregated turn instructions [#4925](https://github.com/Project-OSRM/osrm-backend/pull/4925)
- Tools:
- `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk.
- NodeJS:
- `OSRM` object accepts a new option `memory_file` that stores the memory in a file on disk.
- Internals
- CHANGED #4845 #4968: Updated segregated intersection identification
- CHANGED #4845 #4968: Updated segregated intersection identification [#4845](https://github.com/Project-OSRM/osrm-backend/pull/4845) [#4968](https://github.com/Project-OSRM/osrm-backend/pull/4968)
- REMOVED: Remove `.timestamp` file since it was unused.
- Documentation:
- ADDED: Add documentation about OSM node ids in nearest service response [#4436](https://github.com/Project-OSRM/osrm-backend/pull/4436)
Expand Down
36 changes: 18 additions & 18 deletions features/car/conditional_restrictions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,14 @@ Feature: Car - Turn restrictions
# """
Given the node locations
| node | lat | lon |
| a | 38.9113 | -77.0091 |
| b | 38.9108 | -77.0091 |
| c | 38.9104 | -77.0091 |
| d | 38.9110 | -77.0096 |
| e | 38.9106 | -77.0086 |
| f | 38.9105 | -77.0090 |
| g | 38.9108 | -77.0090 |
| h | 38.9113 | -77.0090 |
| a | 38.91124 | -77.00909 |
| b | 38.91080 | -77.00909 |
| c | 38.91038 | -77.00909 |
| d | 38.91105 | -77.00967 |
| e | 38.91037 | -77.00807 |
| f | 38.91036 | -77.00899 |
| g | 38.91076 | -77.00901 |
| h | 38.91124 | -77.00900 |

And the ways
| nodes | oneway | name |
Expand All @@ -719,7 +719,7 @@ Feature: Car - Turn restrictions
When I route I should get
| from | to | route | turns |
| a | e | cap south,florida nw,florida nw,florida ne | depart,turn right,continue uturn,arrive |
| f | d | cap north,florida,florida nw | depart,turn left,arrive |
| f | d | cap north,florida nw,florida nw | depart,turn left,arrive |
| e | c | florida ne,florida nw,cap south,cap south | depart,continue uturn,turn right,arrive |

@no_turning @conditionals
Expand All @@ -738,14 +738,14 @@ Feature: Car - Turn restrictions
# """
Given the node locations
| node | lat | lon |
| a | 38.9113 | -77.0091 |
| b | 38.9108 | -77.0091 |
| c | 38.9104 | -77.0091 |
| d | 38.9110 | -77.0096 |
| e | 38.9106 | -77.0086 |
| f | 38.9105 | -77.0090 |
| g | 38.9108 | -77.0090 |
| h | 38.9113 | -77.0090 |
| a | 38.91124 | -77.00909 |
| b | 38.91080 | -77.00909 |
| c | 38.91038 | -77.00909 |
| d | 38.91105 | -77.00967 |
| e | 38.91037 | -77.00807 |
| f | 38.91036 | -77.00899 |
| g | 38.91076 | -77.00901 |
| h | 38.91124 | -77.00900 |

And the ways
| nodes | oneway | name |
Expand All @@ -765,7 +765,7 @@ Feature: Car - Turn restrictions

When I route I should get
| from | to | route | turns |
| a | e | cap south,florida,florida ne | depart,turn left,arrive |
| a | e | cap south,florida ne,florida ne | depart,turn left,arrive |
| f | d | cap north,florida ne,florida ne,florida nw | depart,turn sharp right,continue uturn,arrive |
| e | c | florida ne,cap south,cap south | depart,turn left,arrive |

Expand Down
106 changes: 54 additions & 52 deletions features/guidance/collapse.feature

Large diffs are not rendered by default.

63 changes: 50 additions & 13 deletions features/guidance/divided-highways.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ Feature: Divided road entry
d-------e-----f
|
|
g
i---g---j
|
|
h
"""

And the ways
| nodes | name | highway | oneway |
| abc | main st | residential | -1 |
| def | main st | residential | yes |
| be | main st | residential | |
| eg | side st | residential | |
| nodes | name | highway | oneway |
| abc | main st | residential | -1 |
| def | main st | residential | yes |
| be | main st | residential | |
| egh | side st | residential | |
| igj | maple st | residential | |

When I route I should get
| waypoints | route | turns |
| g,a | side st,main st,main st| depart,end of road left,arrive |
| h,a | side st,main st,main st| depart,end of road left,arrive |


# Similar to previous one, but the joining way is tagged with the side-street name
Expand All @@ -37,18 +41,22 @@ Feature: Divided road entry
d-------e-----f
|
|
g
i---g---j
|
|
h
"""

And the ways
| nodes | name | highway | oneway |
| abc | main st | residential | -1 |
| def | main st | residential | yes |
| beg | side st | residential | |
| nodes | name | highway | oneway |
| abc | main st | residential | -1 |
| def | main st | residential | yes |
| begh | side st | residential | |
| igj | maple st | residential | |

When I route I should get
| waypoints | route | turns |
| g,a | side st,main st,main st| depart,end of road left,arrive |
| h,a | side st,main st,main st| depart,end of road left,arrive |


# Center join named after crossroad
Expand Down Expand Up @@ -100,3 +108,32 @@ Feature: Divided road entry
When I route I should get
| waypoints | route | turns |
| g,a | side st,main st,main st| depart,turn left,arrive |

# Verify end of road left turn across divided roads
Scenario: Join on a divided road, named after the side street
Given the node map
"""
a-----h--b-----c
| |
d-----i--e-----f
| |
| |
m---j--g---n
| |
| |
k l
"""

And the ways
| nodes | name | highway | oneway |
| ahbc | main st | residential | -1 |
| dief | main st | residential | yes |
| begl | side st | residential | -1 |
| hijk | side st | residential | yes |
| mjgn | maple st| residential | no |

When I route I should get
| waypoints | route | turns |
| l,a | side st,main st,main st| depart,end of road left,arrive |


2 changes: 1 addition & 1 deletion features/guidance/obvious-turn-discovery.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ Feature: Simple Turns
When I route I should get
| from | to | route | turns |
| g | c | woll,brei,brei | depart,turn slight right,arrive |
| g | f | woll,scho,scho | depart,continue sharp left,arrive |
| g | f | woll,scho,scho | depart,turn sharp left,arrive |
| a | c | scho,brei | depart,arrive |
| d | f | brei,scho | depart,arrive |

Expand Down
42 changes: 23 additions & 19 deletions features/guidance/turn-lanes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Feature: Turn Lane Guidance
| e,l | road,cross,cross | depart,turn right,arrive | ,none:false straight:false straight;right:true, |
| i,h | cross,road,road | depart,turn right,arrive | ,, |
| i,j | cross,cross | depart,arrive | ;;left:false straight:true, |
| i,l | cross,cross,cross | depart,continue uturn,arrive | ;,left:true straight:false;left:true straight:false;left:false straight:true, |
| i,l | cross,cross,cross | depart,continue uturn,arrive | ,left:true straight:false;left:true straight:false;left:true straight:false;left:false straight:true, |

@partition-lanes
Scenario: Turn Lanes at Segregated Road
Expand Down Expand Up @@ -937,48 +937,52 @@ Feature: Turn Lane Guidance
Scenario: Partitioned turn, Slight Curve - maxspeed
Given the node map
"""
f e
| |
| |
| c
a - b ' |
g d
f e
| |
i | |
| | c
h - a - b ' |
j g d
"""

And the ways
| nodes | name | highway | oneway | turn:lanes:forward | maxspeed |
| ha | road | primary | yes | | 1 |
| ab | road | primary | yes | left\|right | 1 |
| bc | cross | primary | yes | | 1 |
| fbg | cross | primary | yes | | 1 |
| dce | cross | primary | yes | | 1 |
| iaj | kross | primary | no | | 1 |

When I route I should get
| waypoints | route | turns | lanes | locations |
| a,g | road,cross,cross | depart,turn right,arrive | ,left:false right:true, | a,b,g |
| a,e | road,cross,cross | depart,end of road left,arrive | ;left:true right:false,left:true right:false, | a,c,e |
| h,g | road,cross,cross | depart,turn right,arrive | ;,left:false right:true, | h,b,g |
| h,e | road,cross,cross | depart,end of road left,arrive | ;,left:true right:false;left:true right:false, | h,b,e |

Scenario: Partitioned turn, Slight Curve
Given the node map
"""
f e
| |
| |
| c
a - b ' |
g d
f e
| |
i | |
| | c
h - a - b ' |
j g d
"""

And the ways
| nodes | name | highway | oneway | turn:lanes:forward |
| ha | road | primary | yes | |
| ab | road | primary | yes | left\|right |
| bc | cross | primary | yes | |
| fbg | cross | primary | yes | |
| dce | cross | primary | yes | |
| iaj | kross | primary | no | |

When I route I should get
| waypoints | route | turns | lanes | locations |
| a,g | road,cross,cross | depart,turn right,arrive | ,left:false right:true, | a,b,g |
| a,e | road,cross,cross | depart,end of road left,arrive | ;left:true right:false,left:true right:false, | a,c,e |
| waypoints | route | turns | lanes | locations |
| h,g | road,cross,cross | depart,turn right,arrive | ;,left:false right:true, | h,b,g |
| h,e | road,cross,cross | depart,end of road left,arrive | ;,left:true right:false;left:true right:false, | h,b,e |

Scenario: Lane Parsing Issue #2694
Given the node map
Expand Down Expand Up @@ -1244,4 +1248,4 @@ Feature: Turn Lane Guidance

When I route I should get
| waypoints | route | turns | lanes | locations |
| a,f | road1,road1,road1 | depart,continue uturn,arrive | ;left:false straight:true straight;right:false,left:true straight:false straight;right:false;;, | a,d,f |
| a,f | road1,road1,road1 | depart,continue uturn,arrive | ,;left:true straight:false straight;right:false;;, | a,c,f |
3 changes: 3 additions & 0 deletions include/engine/api/route_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class RouteAPI : public BaseAPI
// processing is performed
guidance::applyOverrides(BaseAPI::facade, steps, leg_geometry);

// Collapse segregated steps before others
steps = guidance::collapseSegregatedTurnInstructions(std::move(steps));

/* Perform step-based post-processing.
*
* Using post-processing on basis of route-steps for a single leg at a time
Expand Down
26 changes: 24 additions & 2 deletions include/engine/guidance/collapse_turns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ namespace engine
namespace guidance
{

// Multiple possible reasons can result in unnecessary/confusing instructions
// Collapsing such turns into a single turn instruction, we give a clearer
// set of instructions that is not cluttered by unnecessary turns/name changes.
OSRM_ATTR_WARN_UNUSED
std::vector<RouteStep> collapseTurnInstructions(std::vector<RouteStep> steps);

// Multiple possible reasons can result in unnecessary/confusing instructions
// A prime example would be a segregated intersection. Turning around at this
// intersection would result in two instructions to turn left.
// Collapsing such turns into a single turn instruction, we give a clearer
// set of instructionst that is not cluttered by unnecessary turns/name changes.
// set of instructions that is not cluttered by unnecessary turns/name changes.
OSRM_ATTR_WARN_UNUSED
std::vector<RouteStep> collapseTurnInstructions(std::vector<RouteStep> steps);
std::vector<RouteStep> collapseSegregatedTurnInstructions(std::vector<RouteStep> steps);

// A combined turn is a set of two instructions that actually form a single turn, as far as we
// perceive it. A u-turn consisting of two left turns is one such example. But there are also lots
Expand Down Expand Up @@ -93,6 +99,22 @@ struct StaggeredTurnStrategy : CombineStrategy
const RouteStep &step_prior_to_intersection;
};

// Handling of consecutive segregated steps
struct CombineSegregatedStepsStrategy : CombineStrategy
{
void operator()(RouteStep &step_at_turn_location, const RouteStep &transfer_from_step) const;
};

// Handling of segregated intersections
struct SegregatedTurnStrategy : CombineStrategy
{
SegregatedTurnStrategy(const RouteStep &step_prior_to_intersection);

void operator()(RouteStep &step_at_turn_location, const RouteStep &transfer_from_step) const;

const RouteStep &step_prior_to_intersection;
};

// Signage Strategies

// Transfer the signage from the next step onto this step
Expand Down
Loading

0 comments on commit 8a63ad9

Please sign in to comment.