| 57 | } |
| 58 | |
| 59 | ProjectionData GetProjection(std::vector<m2::PointD> const & polyline, size_t index, Direction direction, |
| 60 | ProjectionToShape const & proj) |
| 61 | { |
| 62 | ProjectionData projData; |
| 63 | projData.m_distFromPoint = proj.m_dist; |
| 64 | projData.m_proj = proj.m_point; |
| 65 | |
| 66 | int64_t const next = direction == Direction::Forward ? index + 1 : index - 1; |
| 67 | CHECK_GREATER_OR_EQUAL(next, 0, ()); |
| 68 | CHECK_LESS(static_cast<size_t>(next), polyline.size(), ()); |
| 69 | |
| 70 | if (AlmostEqualAbs(proj.m_point, polyline[index], kEps)) |
| 71 | { |
| 72 | projData.m_indexOnShape = index; |
| 73 | projData.m_needsInsertion = false; |
| 74 | } |
| 75 | else if (AlmostEqualAbs(proj.m_point, polyline[next], kEps)) |
| 76 | { |
| 77 | projData.m_indexOnShape = next; |
| 78 | projData.m_needsInsertion = false; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | projData.m_indexOnShape = direction == Direction::Forward ? next : index; |
| 83 | projData.m_needsInsertion = true; |
| 84 | } |
| 85 | |
| 86 | return projData; |
| 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) |
no test coverage detected