From 243151201f4bd40fee1d11fe18804afc35892e51 Mon Sep 17 00:00:00 2001 From: Mikhail Gorbushin Date: Tue, 7 May 2019 15:54:19 +0300 Subject: [PATCH] [routing] fix assert crash for zero route length --- routing/index_router.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 8f9cde0710..e9130049f2 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -423,8 +423,11 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, isStartSegmentStrictForward, *graph); vector subroute; + static double constexpr kEpsAlmostZero = 1e-7; double const contributionCoef = - MercatorBounds::DistanceOnEarth(startCheckpoint, finishCheckpoint) / checkpointsLength; + !base::AlmostEqualAbs(checkpointsLength, 0.0, kEpsAlmostZero) ? + MercatorBounds::DistanceOnEarth(startCheckpoint, finishCheckpoint) / checkpointsLength : + kEpsAlmostZero; AStarSubProgress subProgress(startCheckpoint, finishCheckpoint, contributionCoef); progress.AppendSubProgress(subProgress);