Skip to content

Commit ada0a1e

Browse files
Moritz KobitzschTheMarex
authored andcommitted
fix coordinate assertion for walking profile with steps
1 parent 74611f9 commit ada0a1e

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

features/guidance/turn-angles.feature

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,3 +1286,34 @@ Feature: Simple Turns
12861286
When I route I should get
12871287
| waypoints | route |
12881288
| a,d | ab,ab |
1289+
1290+
Scenario: Sharp Turn Onto A Bridge
1291+
Given the node map
1292+
"""
1293+
e
1294+
|
1295+
|
1296+
|
1297+
|
1298+
|
1299+
|
1300+
|
1301+
|
1302+
|
1303+
|
1304+
|
1305+
|
1306+
|
1307+
g a - - -b
1308+
f /
1309+
d -c
1310+
"""
1311+
1312+
And the ways
1313+
| nodes | oneway | lanes |
1314+
| gaf | yes | 1 |
1315+
| abcde | yes | 1 |
1316+
1317+
When I route I should get
1318+
| waypoints | route |
1319+
| g,e | abcde,abcde |

src/extractor/guidance/coordinate_extractor.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,24 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
427427
}
428428
}
429429

430-
// We use the locations on the regression line to offset the regression line onto the
431-
// intersection.
432430
const auto result =
433431
ExtractCoordinateAtLength(LOOKAHEAD_DISTANCE_WITHOUT_LANES, coordinates, segment_distances);
434-
BOOST_ASSERT(not_same_as_start(result));
435-
return result;
432+
// there are cases that loop back to the original node (e.g. a tiny circle travelling on steps).
433+
// To compensate for these, we check if we got back to the start and, if so, return the first
434+
// valid result
435+
if (not_same_as_start(result))
436+
{
437+
return result;
438+
}
439+
else
440+
{
441+
const auto result_itr =
442+
std::find_if(coordinates.begin(), coordinates.end(), not_same_as_start);
443+
if (result_itr != coordinates.end())
444+
return *result_itr;
445+
else
446+
return result;
447+
}
436448
}
437449

438450
util::Coordinate

0 commit comments

Comments
 (0)