diff --git a/features/guidance/turn-angles.feature b/features/guidance/turn-angles.feature index e1559fc2d..b94a7c4f0 100644 --- a/features/guidance/turn-angles.feature +++ b/features/guidance/turn-angles.feature @@ -1286,3 +1286,34 @@ Feature: Simple Turns When I route I should get | waypoints | route | | a,d | ab,ab | + + Scenario: Sharp Turn Onto A Bridge + Given the node map + """ + e + | + | + | + | + | + | + | + | + | + | + | + | + | + g a - - -b + f / + d -c + """ + + And the ways + | nodes | oneway | lanes | + | gaf | yes | 1 | + | abcde | yes | 1 | + + When I route I should get + | waypoints | route | + | g,e | abcde,abcde | diff --git a/src/extractor/guidance/coordinate_extractor.cpp b/src/extractor/guidance/coordinate_extractor.cpp index 213e330f3..1ea3d77d2 100644 --- a/src/extractor/guidance/coordinate_extractor.cpp +++ b/src/extractor/guidance/coordinate_extractor.cpp @@ -427,12 +427,24 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate( } } - // We use the locations on the regression line to offset the regression line onto the - // intersection. const auto result = ExtractCoordinateAtLength(LOOKAHEAD_DISTANCE_WITHOUT_LANES, coordinates, segment_distances); - BOOST_ASSERT(not_same_as_start(result)); - return result; + // there are cases that loop back to the original node (e.g. a tiny circle travelling on steps). + // To compensate for these, we check if we got back to the start and, if so, return the first + // valid result + if (not_same_as_start(result)) + { + return result; + } + else + { + const auto result_itr = + std::find_if(coordinates.begin(), coordinates.end(), not_same_as_start); + if (result_itr != coordinates.end()) + return *result_itr; + else + return result; + } } util::Coordinate