| 20 | } |
| 21 | |
| 22 | size_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 | |
| 43 | m2::PointD const & CheckpointPredictor::GetCheckpoint(vector<m2::PointD> const & points, size_t index) const |
| 44 | { |
no test coverage detected