diff --git a/features/guidance/collapse.feature b/features/guidance/collapse.feature index b5669ecaf..290575205 100644 --- a/features/guidance/collapse.feature +++ b/features/guidance/collapse.feature @@ -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 diff --git a/features/guidance/end-of-road.feature b/features/guidance/end-of-road.feature index b0bfac3e5..e05925e6a 100644 --- a/features/guidance/end-of-road.feature +++ b/features/guidance/end-of-road.feature @@ -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 | diff --git a/features/guidance/intersections.feature b/features/guidance/intersections.feature index 22ccac63d..78f3fdf7c 100644 --- a/features/guidance/intersections.feature +++ b/features/guidance/intersections.feature @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 | diff --git a/features/guidance/post-processing.feature b/features/guidance/post-processing.feature new file mode 100644 index 000000000..27e19b08f --- /dev/null +++ b/features/guidance/post-processing.feature @@ -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 | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 1bc104b0b..45da7ee37 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -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" @@ -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) { @@ -420,8 +421,7 @@ void collapseTurnAt(std::vector &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]; @@ -1064,6 +1064,22 @@ std::vector buildIntersections(std::vector 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; }