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

Method MatchLocationToRoute

libs/routing/route.cpp:401–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401bool 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
426size_t Route::GetSubrouteCount() const
427{

Callers 1

UNIT_TESTFunction · 0.45

Calls 9

YToLatFunction · 0.85
XToLonFunction · 0.85
AngleToBearingFunction · 0.85
GetCurrentIterMethod · 0.80
IsValidFunction · 0.50
FromLatLonFunction · 0.50
DistanceOnEarthFunction · 0.50
SetMethod · 0.45
IsFakeSegmentMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36