| 601 | } |
| 602 | |
| 603 | void 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 | |
| 648 | bool RoutingSession::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo) |
| 649 | { |
no test coverage detected