| 399 | } |
| 400 | |
| 401 | bool Route::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo) const |
| 402 | { |
| 403 | if (!IsValid()) |
| 404 | return false; |
| 405 | |
| 406 | auto const & iter = m_poly.GetCurrentIter(); |
| 407 | routeMatchingInfo.Set(iter.m_pt, iter.m_ind, GetMercatorDistanceFromBegin()); |
| 408 | |
| 409 | auto const locationMerc = mercator::FromLatLon(location.m_latitude, location.m_longitude); |
| 410 | auto const distFromRouteM = mercator::DistanceOnEarth(iter.m_pt, locationMerc); |
| 411 | |
| 412 | if (distFromRouteM < m_routingSettings.m_matchingThresholdM) |
| 413 | { |
| 414 | if (!m_poly.IsFakeSegment(iter.m_ind)) |
| 415 | { |
| 416 | location.m_latitude = mercator::YToLat(iter.m_pt.y); |
| 417 | location.m_longitude = mercator::XToLon(iter.m_pt.x); |
| 418 | if (m_routingSettings.m_matchRoute) |
| 419 | location.m_bearing = location::AngleToBearing(GetPolySegAngle(iter.m_ind)); |
| 420 | return true; |
| 421 | } |
| 422 | } |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | size_t Route::GetSubrouteCount() const |
| 427 | { |