forked from organicmaps/organicmaps-tmp
[routing] Fix remaining route time
This commit is contained in:
parent
7c986bba83
commit
48e6a356a3
1 changed files with 30 additions and 1 deletions
|
@ -54,6 +54,34 @@ 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 ScaleRouteTimes(size_t const polySize, Route::TTimes & times)
|
||||
{
|
||||
if (polySize - 2 != (times.size() - 2) * 2)
|
||||
{
|
||||
LOG(LERROR, ("Can't scale route times, polyline:", polySize, ", times:", times.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
Route::TTimes scaledtimes;
|
||||
scaledtimes.reserve(polySize);
|
||||
scaledtimes.emplace_back(scaledtimes.size(), times.front().second);
|
||||
|
||||
for (size_t i = 1; i < times.size() - 1; ++i)
|
||||
{
|
||||
double const time = times[i].second;
|
||||
scaledtimes.emplace_back(scaledtimes.size(), time);
|
||||
scaledtimes.emplace_back(scaledtimes.size(), time);
|
||||
}
|
||||
|
||||
scaledtimes.emplace_back(scaledtimes.size(), times.back().second);
|
||||
times = move(scaledtimes);
|
||||
CHECK_EQUAL(times.size(), polySize, ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace routing
|
||||
|
@ -374,8 +402,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));
|
||||
|
||||
ScaleRouteTimes(route.GetPoly().GetSize(), times);
|
||||
route.SetSectionTimes(move(times));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue