From c0cfadd14a42b51ada8c42ec162e2437aff458e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D1=80=D1=8B=D0=B8=CC=86=20=D0=AD=D1=8D?= =?UTF-8?q?=D1=85?= Date: Thu, 15 Dec 2016 17:59:24 +0300 Subject: [PATCH] [routing] fix route times --- routing/single_mwm_router.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/routing/single_mwm_router.cpp b/routing/single_mwm_router.cpp index 6cec88940a..64d362328f 100644 --- a/routing/single_mwm_router.cpp +++ b/routing/single_mwm_router.cpp @@ -22,6 +22,8 @@ #include "base/exception.hpp" +#include "std/algorithm.hpp" + using namespace routing; namespace @@ -205,6 +207,15 @@ bool SingleMwmRouter::BuildRoute(MwmSet::MwmId const & mwmId, vector vector routePoints; starter.RedressRoute(joints, routePoints); + // ReconstructRoute removes equal points: do it self to match time indexes. + // TODO: rework ReconstructRoute and remove all time indexes stuff. + routePoints.erase(unique(routePoints.begin(), routePoints.end(), + [&](RoutePoint const & rp0, RoutePoint const & rp1) { + return starter.GetPoint(rp0.GetRoadPoint()) == + starter.GetPoint(rp1.GetRoadPoint()); + }), + routePoints.end()); + vector junctions; junctions.reserve(routePoints.size()); @@ -216,12 +227,20 @@ bool SingleMwmRouter::BuildRoute(MwmSet::MwmId const & mwmId, vector } shared_ptr trafficColoring = m_trafficCache.GetTrafficInfo(mwmId); + + vector const oldJunctions(junctions); ReconstructRoute(m_directionsEngine.get(), m_roadGraph, trafficColoring, delegate, junctions, route); + if (junctions != oldJunctions) + { + LOG(LERROR, ("ReconstructRoute changed junctions: size before", oldJunctions.size(), + ", size after", junctions.size())); + return false; + } + // ReconstructRoute duplicates all points except start and finish. // Therefore one needs fix time indexes to fit reconstructed polyline. - // TODO: rework ReconstructRoute and remove this stuff. if (routePoints.size() < 2 || route.GetPoly().GetSize() + 2 != routePoints.size() * 2) { LOG(LERROR, ("Can't fix route times: polyline size =", route.GetPoly().GetSize(),