| 87 | } |
| 88 | |
| 89 | void FillProjections(std::vector<m2::PointD> & polyline, size_t startIndex, size_t endIndex, m2::PointD const & point, |
| 90 | double distStopsM, Direction direction, std::vector<ProjectionData> & projections) |
| 91 | { |
| 92 | CHECK_LESS_OR_EQUAL(startIndex, endIndex, ()); |
| 93 | |
| 94 | double distTravelledM = 0.0; |
| 95 | // Stop can't be further from its projection to line then |maxDistFromStopM|. |
| 96 | double constexpr maxDistFromStopM = 1000; |
| 97 | |
| 98 | size_t const from = direction == Direction::Forward ? startIndex : endIndex; |
| 99 | |
| 100 | auto const endCriterion = [&](size_t i) { return direction == Direction::Forward ? i < endIndex : i > startIndex; }; |
| 101 | |
| 102 | auto const move = [&](size_t & i) |
| 103 | { |
| 104 | direction == Direction::Forward ? ++i : --i; |
| 105 | CHECK_LESS_OR_EQUAL(i, polyline.size(), ()); |
| 106 | }; |
| 107 | |
| 108 | for (size_t i = from; endCriterion(i); move(i)) |
| 109 | { |
| 110 | auto const current = i; |
| 111 | auto const prev = direction == Direction::Forward ? i - 1 : i + 1; |
| 112 | auto const next = direction == Direction::Forward ? i + 1 : i - 1; |
| 113 | |
| 114 | if (i != from) |
| 115 | distTravelledM += mercator::DistanceOnEarth(polyline[prev], polyline[current]); |
| 116 | |
| 117 | auto proj = |
| 118 | GetProjection(polyline, current, direction, ProjectStopOnTrack(point, polyline[current], polyline[next])); |
| 119 | proj.m_distFromEnding = distTravelledM + mercator::DistanceOnEarth(polyline[current], proj.m_proj); |
| 120 | |
| 121 | // The distance on the polyline between the projections of stops must not be less than the |
| 122 | // shortest possible distance between the stops themselves. |
| 123 | if (proj.m_distFromEnding < distStopsM) |
| 124 | continue; |
| 125 | |
| 126 | if (proj.m_distFromPoint < maxDistFromStopM) |
| 127 | projections.emplace_back(proj); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | std::pair<size_t, bool> PrepareNearestPointOnTrack(m2::PointD const & point, |
| 132 | std::optional<m2::PointD> const & prevPoint, size_t prevIndex, |
no test coverage detected