| 294 | } |
| 295 | |
| 296 | bool IndexRouter::FindClosestProjectionToRoad(m2::PointD const & point, m2::PointD const & direction, double radius, |
| 297 | EdgeProj & proj) |
| 298 | { |
| 299 | auto const rect = mercator::RectByCenterXYAndSizeInMeters(point, radius); |
| 300 | std::vector<EdgeProjectionT> candidates; |
| 301 | |
| 302 | uint32_t const count = direction.IsAlmostZero() ? 1 : 4; |
| 303 | m_roadGraph.FindClosestEdges(rect, count, candidates); |
| 304 | |
| 305 | if (candidates.empty()) |
| 306 | return false; |
| 307 | |
| 308 | if (direction.IsAlmostZero()) |
| 309 | { |
| 310 | // We have no direction so return the first closest edge. |
| 311 | proj.m_edge = candidates[0].first; |
| 312 | proj.m_point = candidates[0].second.GetPoint(); |
| 313 | return true; |
| 314 | } |
| 315 | |
| 316 | // We have direction so we can find the closest codirectional edge. |
| 317 | Edge codirectionalEdge; |
| 318 | if (!PointsOnEdgesSnapping::FindClosestCodirectionalEdge(point, direction, candidates, codirectionalEdge)) |
| 319 | return false; |
| 320 | |
| 321 | for (auto const & [edge, projection] : candidates) |
| 322 | { |
| 323 | if (edge == codirectionalEdge) |
| 324 | { |
| 325 | proj.m_edge = edge; |
| 326 | proj.m_point = projection.GetPoint(); |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | void IndexRouter::SetGuides(GuidesTracks && guides) |
| 335 | { |
nothing calls this directly
no test coverage detected