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

Method FindClosestProjectionToRoad

libs/routing/index_router.cpp:296–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296bool 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
334void IndexRouter::SetGuides(GuidesTracks && guides)
335{

Callers

nothing calls this directly

Calls 5

IsAlmostZeroMethod · 0.80
FindClosestEdgesMethod · 0.45
emptyMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected