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

Method GetMatchingScore

tools/openlr/router.cpp:585–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583
584template <typename It>
585double Router::GetMatchingScore(m2::PointD const & u, m2::PointD const & v, It b, It e)
586{
587 double const kEps = 1e-5;
588
589 double const len = mercator::DistanceOnEarth(u, v);
590
591 m2::PointD const uv = v - u;
592
593 double cov = 0;
594 for (; b != e; ++b)
595 {
596 // Need p here to prolongate lifetime of (*b) if iterator
597 // dereferencing returns a temprorary object instead of a
598 // reference.
599 auto const & p = *b;
600 auto const & s = p.first;
601 auto const & t = p.second;
602 if (!m2::IsPointOnSegmentEps(s, u, v, kEps) || !m2::IsPointOnSegmentEps(t, u, v, kEps))
603 break;
604
605 m2::PointD const st = t - s;
606 if (DotProduct(uv, st) < -kEps)
607 break;
608
609 cov += mercator::DistanceOnEarth(s, t);
610 }
611
612 return len == 0 ? 0 : math::Clamp(cov / len, 0.0, 1.0);
613}
614
615template <typename It, typename Fn>
616void Router::ForStagePrefix(It b, It e, size_t stage, Fn && fn)

Callers

nothing calls this directly

Calls 4

IsPointOnSegmentEpsFunction · 0.85
ClampFunction · 0.85
DistanceOnEarthFunction · 0.50
DotProductFunction · 0.50

Tested by

no test coverage detected