MCPcopy Create free account
hub / github.com/comaps/comaps / GetCurrentTimeFromBeginSec

Method GetCurrentTimeFromBeginSec

libs/routing/route.cpp:134–154  ·  view source on GitHub ↗

| curSegLenMeters | | | | passedSegMeters | | ----------*-----------------*------------*----> x | | | LastPoint CurrentPoint NextPoint | fromLastPassedPointToEndSec ----------*-----------------*------------*----> t | | | toLastPointSec currentTime toNextPointSec CurrentTime is c

Source from the content-addressed store, hash-verified

132//
133// CurrentTime is calculated using equal proportions for distance and time at any segment.
134double Route::GetCurrentTimeFromBeginSec() const
135{
136 if (!IsValid())
137 return 0.0;
138
139 auto const & curIter = m_poly.GetCurrentIter();
140 CHECK_LESS(curIter.m_ind, m_routeSegments.size(), ());
141
142 double const toLastPointSec =
143 (curIter.m_ind == 0) ? 0.0 : m_routeSegments[curIter.m_ind - 1].GetTimeFromBeginningSec();
144 double const toNextPointSec = m_routeSegments[curIter.m_ind].GetTimeFromBeginningSec();
145
146 double const curSegLenMeters = GetSegLenMeters(curIter.m_ind);
147
148 if (curSegLenMeters < 1.0)
149 return toLastPointSec;
150
151 double const passedSegMeters = m_poly.GetDistFromCurPointToRoutePointMeters();
152
153 return toLastPointSec + passedSegMeters / curSegLenMeters * (toNextPointSec - toLastPointSec);
154}
155
156double Route::GetCurrentTimeToSegmentSec(size_t segIdx) const
157{

Callers

nothing calls this directly

Calls 5

GetCurrentIterMethod · 0.80
IsValidFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected