fix coordinate extraction with less than 1 meters past lane distance
This commit is contained in:
parent
7753845f5c
commit
e8b947bca6
@ -1149,3 +1149,22 @@ Feature: Simple Turns
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,m | gato,hain,hain | depart,turn left,arrive |
|
||||
|
||||
Scenario: Segfaulting Regression
|
||||
Given the node map
|
||||
"""
|
||||
a - - - - - - - - - - - - - - b c
|
||||
|
|
||||
|
|
||||
|
|
||||
d--------------e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | lanes:forward |
|
||||
| ab | |
|
||||
| bcde | 6 |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route |
|
||||
| a,e | ab,bcde,bcde |
|
||||
|
@ -273,9 +273,10 @@ CoordinateExtractor::GetCoordinateAlongRoad(const NodeID intersection_node,
|
||||
{
|
||||
// skip over the first coordinates, in specific the assumed lane count. We add a small
|
||||
// safety factor, to not overshoot on the regression
|
||||
const auto trimmed_coordinates = TrimCoordinatesByLengthFront(
|
||||
coordinates, 0.8 * (considered_lanes * ASSUMED_LANE_WIDTH));
|
||||
if (trimmed_coordinates.size() >= 2)
|
||||
const auto trimming_length = 0.8 * (considered_lanes * ASSUMED_LANE_WIDTH);
|
||||
const auto trimmed_coordinates =
|
||||
TrimCoordinatesByLengthFront(coordinates, 0.8 * trimming_length);
|
||||
if (trimmed_coordinates.size() >= 2 && (total_distance >= trimming_length + 2))
|
||||
{
|
||||
// get the regression line
|
||||
const auto regression_line_trimmed = RegressionLine(trimmed_coordinates);
|
||||
@ -803,6 +804,10 @@ CoordinateExtractor::RegressionLine(const std::vector<util::Coordinate> &coordin
|
||||
// (less dependent on modelling of the data in OSM)
|
||||
const auto sampled_coordinates = SampleCoordinates(coordinates, FAR_LOOKAHEAD_DISTANCE, 1);
|
||||
|
||||
BOOST_ASSERT(!coordinates.empty());
|
||||
if (sampled_coordinates.size() < 2) // less than 1 meter in length
|
||||
return {coordinates.front(), coordinates.back()};
|
||||
|
||||
// compute the regression vector based on the sum of least squares
|
||||
const auto regression_line = leastSquareRegression(sampled_coordinates);
|
||||
const auto coord_between_front =
|
||||
|
Loading…
Reference in New Issue
Block a user