| 550 | } |
| 551 | |
| 552 | RouteWeight IndexGraph::getTurnPenalty(EdgeEstimator::Purpose purpose, Segment const & from, Segment const & to) const |
| 553 | { |
| 554 | if (from.GetFeatureId() == to.GetFeatureId()) |
| 555 | return {0, 0, 0, 0, 0}; |
| 556 | auto const & to_road = GetRoadGeometry(to.GetFeatureId()); |
| 557 | auto const & from_road = GetRoadGeometry(from.GetFeatureId()); |
| 558 | auto v1 = ms::ToVector(GetPoint(from, true)) - ms::ToVector(GetPoint(from, false)); |
| 559 | auto v2 = ms::ToVector(GetPoint(to, true)) - ms::ToVector(GetPoint(to, false)); |
| 560 | auto const dotLen = v1.Length() * v2.Length(); |
| 561 | if (dotLen == 0) |
| 562 | return {0, 0, 0, 0, 0}; |
| 563 | auto normal = ms::ToVector(GetPoint(from, true)) + ms::ToVector(GetPoint(to, false)); |
| 564 | normal = normal / normal.Length(); |
| 565 | auto const signed_angle = |
| 566 | math::RadToDeg(atan2(m3::DotProduct(m3::CrossProduct(v1, v2), normal), m3::DotProduct(v1, v2))); |
| 567 | return {m_estimator->GetTurnPenalty(purpose, signed_angle, from_road, to_road, m_isLeftHandTraffic), 0, 0, 0, 0}; |
| 568 | } |
| 569 | } // namespace routing |
nothing calls this directly
no test coverage detected