| 583 | |
| 584 | template <typename It> |
| 585 | double 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 | |
| 615 | template <typename It, typename Fn> |
| 616 | void Router::ForStagePrefix(It b, It e, size_t stage, Fn && fn) |
nothing calls this directly
no test coverage detected