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

Method MatchLocationToRoadGraph

libs/routing/routing_session.cpp:603–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603void RoutingSession::MatchLocationToRoadGraph(location::GpsInfo & location)
604{
605 auto const locationMerc = mercator::FromLatLon(location.m_latitude, location.m_longitude);
606 double const radius = m_route->GetCurrentRoutingSettings().m_matchingThresholdM;
607
608 m2::PointD const direction = m_positionAccumulator.GetDirection();
609
610 static auto constexpr kEps = 1e-5;
611 if (AlmostEqualAbs(direction, m2::PointD::Zero(), kEps))
612 return;
613
614 EdgeProj proj;
615 if (!m_router->FindClosestProjectionToRoad(locationMerc, direction, radius, proj))
616 {
617 m_projectedToRoadGraph = false;
618 return;
619 }
620
621 // First matching to the same road. We pull coordinates and angle on the following matchings.
622 if (!m_projectedToRoadGraph)
623 {
624 m_projectedToRoadGraph = true;
625 m_proj = proj;
626 return;
627 }
628
629 if (m_proj.m_edge.GetFeatureId() == proj.m_edge.GetFeatureId())
630 {
631 if (m_route->GetCurrentRoutingSettings().m_matchRoute)
632 {
633 if (!AlmostEqualAbs(m_proj.m_point, proj.m_point, kEps))
634 location.m_bearing = location::AngleToBearing(math::RadToDeg(ang::AngleTo(m_proj.m_point, proj.m_point)));
635 }
636
637 location.m_latitude = mercator::YToLat(proj.m_point.y);
638 location.m_longitude = mercator::XToLon(proj.m_point.x);
639 }
640 else
641 {
642 m_projectedToRoadGraph = false;
643 }
644
645 m_proj = proj;
646}
647
648bool RoutingSession::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo)
649{

Callers 1

MatchLocationToRouteMethod · 0.80

Calls 11

ZeroFunction · 0.85
AngleToBearingFunction · 0.85
RadToDegFunction · 0.85
AngleToFunction · 0.85
YToLatFunction · 0.85
XToLonFunction · 0.85
FromLatLonFunction · 0.50
AlmostEqualAbsFunction · 0.50
GetDirectionMethod · 0.45
GetFeatureIdMethod · 0.45

Tested by

no test coverage detected