fix coordinate assertion for walking profile with steps

This commit is contained in:
Moritz Kobitzsch 2017-01-11 12:12:23 +01:00 committed by Patrick Niklaus
parent 9fa7e6c74f
commit 06ef3053de
2 changed files with 47 additions and 4 deletions

View File

@ -1340,3 +1340,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 |

View File

@ -422,12 +422,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));
// 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