From b7c4788282396e442235b9def63d1267e04ed341 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 30 Sep 2019 10:19:06 +0300 Subject: [PATCH] [routing] Handling rare cases when two point of track has the same time. --- track_analyzing/track_analyzer/cmd_table.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/track_analyzing/track_analyzer/cmd_table.cpp b/track_analyzing/track_analyzer/cmd_table.cpp index fc68a0d0d1..363f788633 100644 --- a/track_analyzing/track_analyzer/cmd_table.cpp +++ b/track_analyzing/track_analyzer/cmd_table.cpp @@ -30,6 +30,7 @@ #include "base/assert.hpp" #include "base/file_name_utils.hpp" +#include "base/logging.hpp" #include "base/stl_helpers.hpp" #include "base/sunrise_sunset.hpp" #include "base/timer.hpp" @@ -283,7 +284,18 @@ public: if (begin + 1 >= end) return; - uint64_t const time = (end - 1)->GetDataPoint().m_timestamp - begin->GetDataPoint().m_timestamp; + auto const & beginDataPoint = begin->GetDataPoint(); + auto const & endDataPoint = (end - 1)->GetDataPoint(); + uint64_t const time = endDataPoint.m_timestamp - beginDataPoint.m_timestamp; + + if (time == 0) + { + LOG(LWARNING, ("Track with the same time at the beginning and at the end. Beginning:", + beginDataPoint.m_latLon, " End:", endDataPoint.m_latLon, + " Timestamp:", beginDataPoint.m_timestamp, " Segment:", begin->GetSegment())); + return; + } + double const length = CalcSubtrackLength(begin, end, geometry); m_moveInfos[moveType].Add(length, time, crossroads); }