diff --git a/features/guidance/dedicated-turn-roads.feature b/features/guidance/dedicated-turn-roads.feature index 114822b2e..65f02ea6a 100644 --- a/features/guidance/dedicated-turn-roads.feature +++ b/features/guidance/dedicated-turn-roads.feature @@ -892,3 +892,40 @@ Feature: Slipways and Dedicated Turn Lanes When I route I should get | waypoints | route | turns | locations | | z,t | through,,out,out | depart,off ramp slight right,round-exit-3,arrive | z,s,c,t | + + Scenario: Sliproad before a roundabout + Given the node map + """ + e + a - b - - c - d + 'f|l' + m + g + | + .h-_ + k - i | + '.j.' + + """ + + And the ways + | nodes | junction | oneway | highway | name | + | ab | | yes | primary | road | + | bc | | yes | primary | road | + | cd | | yes | primary | road | + | ec | | yes | secondary | | + | cm | | yes | secondary | | + | mg | | yes | primary | | + | gh | | no | primary | | + | hijh | roundabout | yes | primary | | + | ik | | yes | primary | | + | bfm | | yes | primary | | + | gld | | yes | primary | | + + And the relations + | type | way:from | way:to | node:via | restriction | + | restriction | bc | cd | c | only_straight | + + When I route I should get + | waypoints | route | turns | locations | + | a,k | road,,, | depart,continue right,roundabout turn right exit-1,arrive | a,b,h,k | diff --git a/include/extractor/guidance/intersection.hpp b/include/extractor/guidance/intersection.hpp index 8886aedc7..5a45e93e4 100644 --- a/include/extractor/guidance/intersection.hpp +++ b/include/extractor/guidance/intersection.hpp @@ -37,6 +37,14 @@ struct IntersectionShapeData }; inline auto makeCompareShapeDataByBearing(const double base_bearing) +{ + return [base_bearing](const auto &lhs, const auto &rhs) { + return util::angularDeviation(lhs.bearing, base_bearing) < + util::angularDeviation(rhs.bearing, base_bearing); + }; +} + +inline auto makeCompareShapeDataAngleToBearing(const double base_bearing) { return [base_bearing](const auto &lhs, const auto &rhs) { return util::bearing::angleBetween(lhs.bearing, base_bearing) < diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index bc9502d1f..463e3389d 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -998,7 +998,8 @@ std::vector collapseTurns(std::vector steps) if (one_back_step.maneuver.instruction.type == TurnType::Sliproad) { if (current_step.maneuver.instruction.type == TurnType::Suppressed && - compatible(one_back_step, current_step)) + compatible(one_back_step, current_step) && current_step.intersections.size() == 1 && + current_step.intersections.front().entry.size() == 2) { // Traffic light on the sliproad, the road itself will be handled in the next // iteration, when one-back-index again points to the sliproad. diff --git a/src/extractor/guidance/intersection_generator.cpp b/src/extractor/guidance/intersection_generator.cpp index c2f114b21..339f0287f 100644 --- a/src/extractor/guidance/intersection_generator.cpp +++ b/src/extractor/guidance/intersection_generator.cpp @@ -140,8 +140,9 @@ IntersectionGenerator::ComputeIntersectionShape(const NodeID node_at_center_of_i } return util::bearing::reverse(intersection.begin()->bearing); }(); - std::sort( - intersection.begin(), intersection.end(), makeCompareShapeDataByBearing(base_bearing)); + std::sort(intersection.begin(), + intersection.end(), + makeCompareShapeDataAngleToBearing(base_bearing)); } return intersection; }