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

Method PredictPosition

libs/routing/checkpoint_predictor.cpp:22–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22size_t CheckpointPredictor::PredictPosition(vector<m2::PointD> const & points, m2::PointD const & point) const
23{
24 double constexpr kInvalidDistance = numeric_limits<double>::max();
25 double minDeltaMeters = kInvalidDistance;
26 size_t minDeltaIdx = 0;
27 // Checkpoints include start, all the intermediate points and finish.
28 size_t const checkpointNum = points.size() + 2 /* for start and finish points */;
29 for (size_t i = 0; i + 1 != checkpointNum; ++i)
30 {
31 double const delta = CalculateDeltaMeters(GetCheckpoint(points, i), GetCheckpoint(points, i + 1), point);
32 if (minDeltaMeters > delta)
33 {
34 minDeltaMeters = delta;
35 minDeltaIdx = i;
36 }
37 }
38
39 CHECK_NOT_EQUAL(minDeltaMeters, kInvalidDistance, ());
40 return minDeltaIdx;
41}
42
43m2::PointD const & CheckpointPredictor::GetCheckpoint(vector<m2::PointD> const & points, size_t index) const
44{

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected