From f9f3d43152b9921502a7a6ab0cb9380efc128869 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Fri, 18 Dec 2015 23:28:16 +0100 Subject: [PATCH] Fix min average sample time --- routing_algorithms/map_matching.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/routing_algorithms/map_matching.hpp b/routing_algorithms/map_matching.hpp index a36fabd35..430682d92 100644 --- a/routing_algorithms/map_matching.hpp +++ b/routing_algorithms/map_matching.hpp @@ -106,20 +106,23 @@ class MapMatching final : public BasicRoutingInterface 1); + + const bool use_timestamps = trace_timestamps.size() > 1; const auto median_sample_time = [&]() { - if (trace_timestamps.size() > 1) + if (use_timestamps) { - return GetMedianSampleTime(trace_timestamps); + return std::max(1u, GetMedianSampleTime(trace_timestamps)); } else { - return 0u; + return 1u; } }(); const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES; const auto max_distance_delta = [&]() { - if (trace_timestamps.size() > 1) + if (use_timestamps) { return median_sample_time * osrm::matching::MAX_SPEED; } @@ -161,7 +164,7 @@ class MapMatching final : public BasicRoutingInterface