From 1d82b01816e8a193fde872b94aeb0e26395f97e8 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Sat, 15 Dec 2018 01:15:54 -0700 Subject: [PATCH] Count reverse offset from the back of the geometry, not the front. --- include/engine/geospatial_query.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index 42f8105b8..dd52d8dc7 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -465,6 +465,7 @@ template class GeospatialQuery EdgeDuration{0}); EdgeDistance forward_distance_offset = 0; + // Sum up the distance from the start to the fwd_segment_position for (auto current = forward_geometry.begin(); current < forward_geometry.begin() + data.fwd_segment_position; ++current) @@ -494,8 +495,9 @@ template class GeospatialQuery EdgeDuration{0}); EdgeDistance reverse_distance_offset = 0; - for (auto current = forward_geometry.begin(); - current < forward_geometry.end() - data.fwd_segment_position - 2; + // Sum up the distance from just after the fwd_segment_position to the end + for (auto current = forward_geometry.begin() + data.fwd_segment_position + 1; + current != std::prev(forward_geometry.end()); ++current) { reverse_distance_offset += util::coordinate_calculation::fccApproximateDistance(