Skip to content

Commit

Permalink
reduce number of end-of-road instructions in unnecessary cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch authored and TheMarex committed Jun 26, 2016
1 parent 8693e68 commit 2a05b70
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 87 deletions.
6 changes: 3 additions & 3 deletions features/guidance/collapse.feature
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,9 @@ Feature: Collapse
| cf | secondary | bottom |

When I route I should get
| waypoints | turns | route |
| a,d | depart,continue right,end of road right,arrive | road,road,road,road |
| d,a | depart,continue left,end of road left,arrive | road,road,road,road |
| waypoints | turns | route |
| a,d | depart,continue right,turn right,arrive | road,road,road,road |
| d,a | depart,continue left,turn left,arrive | road,road,road,road |

Scenario: Forking before a turn
Given the node map
Expand Down
91 changes: 49 additions & 42 deletions features/guidance/end-of-road.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,116 +8,123 @@ Feature: End Of Road Instructions
Scenario: End of Road with through street
Given the node map
| | | c |
| a | | b |
| | | d |
| a | e | b |
| | f | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| cbd | primary |
| ef | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cbd,cbd | depart,end of road left,arrive |
| a,d | ab,cbd,cbd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cbd,cbd | depart,end of road left,arrive |
| a,d | aeb,cbd,cbd | depart,end of road right,arrive |

Scenario: End of Road with three streets
Given the node map
| | | c |
| a | | b |
| | | d |
| a | e | b |
| | f | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| cb | primary |
| bd | primary |
| ef | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cb,cb | depart,end of road left,arrive |
| a,d | ab,bd,bd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cb,cb | depart,end of road left,arrive |
| a,d | aeb,bd,bd | depart,end of road right,arrive |

Scenario: End of Road with three streets, slightly angled
Given the node map
| a | | | | | c |
| | | | | | b |
| a | e | | | | c |
| | f | | | | b |
| | | | | | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| cb | primary |
| bd | primary |
| ef | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cb,cb | depart,end of road left,arrive |
| a,d | ab,bd,bd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cb,cb | depart,end of road left,arrive |
| a,d | aeb,bd,bd | depart,end of road right,arrive |

Scenario: End of Road with three streets, slightly angled
Given the node map
| | | | | | c |
| | | | | | b |
| a | | | | | d |
| | f | | | | b |
| a | e | | | | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| ef | primary |
| cb | primary |
| bd | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cb,cb | depart,end of road left,arrive |
| a,d | ab,bd,bd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cb,cb | depart,end of road left,arrive |
| a,d | aeb,bd,bd | depart,end of road right,arrive |

Scenario: End of Road with through street, slightly angled
Given the node map
| a | | | | | c |
| | | | | | b |
| a | e | | | | c |
| | f | | | | b |
| | | | | | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| ef | primary |
| cbd | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cbd,cbd | depart,end of road left,arrive |
| a,d | ab,cbd,cbd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cbd,cbd | depart,end of road left,arrive |
| a,d | aeb,cbd,cbd | depart,end of road right,arrive |

Scenario: End of Road with through street, slightly angled
Given the node map
| | | | | | c |
| | | | | | b |
| a | | | | | d |
| | f | | | | b |
| a | e | | | | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| ef | primary |
| cbd | primary |

When I route I should get
| waypoints | route | turns |
| a,c | ab,cbd,cbd | depart,end of road left,arrive |
| a,d | ab,cbd,cbd | depart,end of road right,arrive |
| waypoints | route | turns |
| a,c | aeb,cbd,cbd | depart,end of road left,arrive |
| a,d | aeb,cbd,cbd | depart,end of road right,arrive |

Scenario: End of Road with two ramps - prefer ramp over end of road
Given the node map
| | | c |
| a | | b |
| | | d |
| a | e | b |
| | f | d |

And the ways
| nodes | highway |
| ab | primary |
| aeb | primary |
| ef | primary |
| bc | motorway_link |
| bd | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,c | ab,bc,bc | depart,on ramp left,arrive |
| a,d | ab,bd,bd | depart,on ramp right,arrive |
| waypoints | route | turns |
| a,c | aeb,bc,bc | depart,on ramp left,arrive |
| a,d | aeb,bd,bd | depart,on ramp right,arrive |

59 changes: 20 additions & 39 deletions features/guidance/intersections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Feature: Intersections Data
| bd | corner |

When I route I should get
| waypoints | route | turns | intersections |
| a,c | through,through | depart,arrive | true:90,true:90 true:180 false:270;true:270 |
| waypoints | route | intersections |
| a,c | through,through | true:90,true:90 true:180 false:270;true:270 |

Scenario: Passing Three Way North
Given the node map
Expand All @@ -32,8 +32,8 @@ Feature: Intersections Data
| bd | corner |

When I route I should get
| waypoints | route | turns | intersections |
| a,c | through,through | depart,arrive | true:90,true:0 true:90 false:270;true:270 |
| waypoints | route | intersections |
| a,c | through,through | true:90,true:0 true:90 false:270;true:270 |

Scenario: Passing Oneway Street In
Given the node map
Expand All @@ -47,8 +47,8 @@ Feature: Intersections Data
| db | corner | yes |

When I route I should get
| waypoints | route | turns | intersections |
| a,c | through,through | depart,arrive | true:90,false:0 true:90 false:270;true:270 |
| waypoints | route | intersections |
| a,c | through,through | true:90,false:0 true:90 false:270;true:270 |

Scenario: Passing Oneway Street Out
Given the node map
Expand All @@ -62,8 +62,8 @@ Feature: Intersections Data
| bd | corner | yes |

When I route I should get
| waypoints | route | turns | intersections |
| a,c | through,through | depart,arrive | true:90,true:0 true:90 false:270;true:270 |
| waypoints | route | intersections |
| a,c | through,through | true:90,true:0 true:90 false:270;true:270 |

Scenario: Passing Two Intersections
Given the node map
Expand All @@ -80,27 +80,8 @@ Feature: Intersections Data
| cf | corner |

When I route I should get
| waypoints | route | turns | intersections |
| a,d | through,through | depart,arrive | true:90,true:0 true:90 false:270,true:90 true:180 false:270;true:270 |

Scenario: Regression test #2424
Given the node map
| | | e | | | | | | i | | | | |
| a | | b | | c | | d | | h | | k | | m |
| | | | | f | | | | | | l | | |

And the ways
| nodes | name |
| abcd | Fritz-Elsas-Straße |
| hkm | Fritz-Elsas-Straße |
| dhi | Martin-Luther-Straße |
| be | corner |
| kl | corner |
| cf | corner |

When I route I should get
| waypoints | route | turns |
| a,m | Fritz-Elsas-Straße,Fritz-Elsas-Straße| depart,arrive |
| waypoints | route | intersections |
| a,d | through,through | true:90,true:0 true:90 false:270,true:90 true:180 false:270;true:270 |

Scenario: Passing Two Intersections, Collapsing
Given the node map
Expand All @@ -117,9 +98,9 @@ Feature: Intersections Data
| cf | corner |

When I route I should get
| waypoints | route | turns | intersections |
| a,d | through,through | depart,arrive | true:90,true:0 true:90 false:270,true:90 true:180 false:270;true:270 |
| f,a | corner,through,through | depart,end of road left,arrive | true:0;true:90 false:180 true:270,true:0 false:90 true:270;true:90 |
| waypoints | route | intersections |
| a,d | through,through | true:90,true:0 true:90 false:270,true:90 true:180 false:270;true:270 |
| f,a | corner,through,through | true:0;true:90 false:180 true:270,true:0 false:90 true:270;true:90 |

Scenario: Roundabouts
Given the node map
Expand All @@ -144,10 +125,10 @@ Feature: Intersections Data
| hd | |

When I route I should get
| waypoints | route | turns | intersections |
| e,f | ea,fb,fb | depart,abcda-exit-1,arrive | true:180;false:0 false:150 true:210,false:30 true:150 true:270;true:90 |
| e,g | ea,gc,gc | depart,abcda-exit-2,arrive | true:180;false:0 false:150 true:210,false:30 true:150 true:270,true:30 true:180 false:330;true:0 |
| e,h | ea,hd,hd | depart,abcda-exit-3,arrive | true:180;false:0 false:150 true:210,false:30 true:150 true:270,true:30 true:180 false:330,true:90 false:210 true:330;true:270 |
| e,2 | ea,abcda,abcda | depart,abcda-exit-undefined,arrive | true:180;false:0 false:150 true:210,false:30 true:150 true:270;true:327 +-1 |
| 1,g | abcda,gc,gc | depart,abcda-exit-2,arrive | true:214;false:30 true:150 true:270,true:30 true:180 false:330;true:0 |
| 1,3 | abcda,abcda | depart,arrive | true:214,false:30 true:150 true:270,true:30 true:180 false:330;true:214 |
| waypoints | route | intersections |
| e,f | ea,fb,fb | true:180;false:0 false:150 true:210,false:30 true:150 true:270;true:90 |
| e,g | ea,gc,gc | true:180;false:0 false:150 true:210,false:30 true:150 true:270,true:30 true:180 false:330;true:0 |
| e,h | ea,hd,hd | true:180;false:0 false:150 true:210,false:30 true:150 true:270,true:30 true:180 false:330,true:90 false:210 true:330;true:270 |
| e,2 | ea,abcda,abcda | true:180;false:0 false:150 true:210,false:30 true:150 true:270;true:327 +-1 |
| 1,g | abcda,gc,gc | true:214;false:30 true:150 true:270,true:30 true:180 false:330;true:0 |
| 1,3 | abcda,abcda | true:214,false:30 true:150 true:270,true:30 true:180 false:330;true:214 |
22 changes: 22 additions & 0 deletions features/guidance/post-processing.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@routing @guidance @post-processing
Feature: General Post-Processing related features

Background:
Given the profile "car"
Given a grid size of 10 meters

# this testcase used to crash geometry generation (at that time handled during intersection generation)
Scenario: Regression test #2424
Given the node map
| | | e | | | | | | i | | | | |
| a | | b | | c | | d | | h | | k | | m |
| | | | | f | | | | | | l | | |

And the ways
| nodes | name |
| abcd | Fritz-Elsas-Straße |
| hkm | Fritz-Elsas-Straße |
| dhi | Martin-Luther-Straße |
| be | corner |
| kl | corner |
| cf | corner |
22 changes: 19 additions & 3 deletions src/engine/guidance/post_processing.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "engine/guidance/post_processing.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/guidance/post_processing.hpp"

#include "engine/guidance/assemble_steps.hpp"
#include "engine/guidance/toolkit.hpp"
Expand Down Expand Up @@ -32,6 +32,7 @@ namespace guidance
namespace
{
const constexpr double MAX_COLLAPSE_DISTANCE = 25;
const constexpr std::size_t MIN_END_OF_ROAD_INTERSECTIONS = std::size_t{2};

inline bool choiceless(const RouteStep &step, const RouteStep &previous)
{
Expand Down Expand Up @@ -420,8 +421,7 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
{
steps[one_back_index].maneuver.instruction.type = TurnType::Continue;

const auto getBearing = [](bool in, const RouteStep &step)
{
const auto getBearing = [](bool in, const RouteStep &step) {
const auto index =
in ? step.intersections.front().in : step.intersections.front().out;
return step.intersections.front().bearings[index];
Expand Down Expand Up @@ -1064,6 +1064,22 @@ std::vector<RouteStep> buildIntersections(std::vector<RouteStep> steps)
}
else if (!isSilent(instruction))
{

// End of road is a turn that helps to identify the location of a turn. If the turn does
// not pass by any oter intersections, the end-of-road characteristic does not improve
// the instructions.
// Here we reduce the verbosity of our output by reducing end-of-road emissions in cases
// where no intersections have been passed in between.
// Since the instruction is located at the beginning of a step, we need to check the
// previous instruction.
if (instruction.type == TurnType::EndOfRoad)
{
BOOST_ASSERT(step_index > 0 && step_index < step_index + 1 < steps.size());
const auto &previous_step = steps[last_valid_instruction];
if (previous_step.intersections.size() < MIN_END_OF_ROAD_INTERSECTIONS)
step.maneuver.instruction.type = TurnType::Turn;
}

// Remember the last non silent instruction
last_valid_instruction = step_index;
}
Expand Down

0 comments on commit 2a05b70

Please sign in to comment.