diff options
author | burivuh <burivuh@maps.me> | 2017-05-05 19:04:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-05 19:04:16 +0300 |
commit | f213961d609b83d4b6fc6dbd6ef7f2c02c99cd60 (patch) | |
tree | 23f25760ed64cff05edda01d89b5313023436cf1 | |
parent | 0373a4c6c9e782fb5246f9c70e77b169abbf118c (diff) | |
parent | 47df3e1b0d71dfcaa063f73db4dff0d8d0210adc (diff) |
Merge pull request #6011 from mapsme/fix-remaining-route-timebeta-796beta-795beta-794beta-793beta-792
[release-73][routing] Fix remaining route time
-rw-r--r-- | routing/index_router.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/routing/index_router.cpp b/routing/index_router.cpp index c816532d88..653eaafbd5 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -52,6 +52,35 @@ bool IsDeadEnd(Segment const & segment, bool isOutgoing, WorldGraph & worldGraph return !CheckGraphConnectivity(segment, kDeadEndTestLimit, worldGraph, getVertexByEdgeFn, getOutgoingEdgesFn); } + +// ReconstructRoute duplicates polyline internal points. +// Internal points are all polyline points except first and last. +// +// Need duplicate times also. +void DuplicateRouteTimes(size_t const polySize, Route::TTimes ×) +{ + if (polySize - 2 != (times.size() - 2) * 2) + { + LOG(LERROR, ("Can't duplicate route times, polyline:", polySize, ", times:", times.size())); + return; + } + + Route::TTimes duplicatedTimes; + duplicatedTimes.reserve(polySize); + size_t index = 0; + duplicatedTimes.emplace_back(index++, times.front().second); + + for (size_t i = 1; i < times.size() - 1; ++i) + { + double const time = times[i].second; + duplicatedTimes.emplace_back(index++, time); + duplicatedTimes.emplace_back(index++, time); + } + + duplicatedTimes.emplace_back(index++, times.back().second); + times = move(duplicatedTimes); + CHECK_EQUAL(times.size(), polySize, ()); +} } // namespace namespace routing @@ -371,8 +400,9 @@ bool IndexRouter::RedressRoute(vector<Segment> const & segments, RouterDelegate times.emplace_back(static_cast<uint32_t>(i), time); time += starter.CalcSegmentWeight(segments[i]); } - route.SetSectionTimes(move(times)); + DuplicateRouteTimes(route.GetPoly().GetSize(), times); + route.SetSectionTimes(move(times)); return true; } |