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

Method getTurnPenalty

libs/routing/index_graph.cpp:552–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550}
551
552RouteWeight 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

Callers

nothing calls this directly

Calls 8

ToVectorFunction · 0.85
GetPointFunction · 0.85
RadToDegFunction · 0.85
DotProductFunction · 0.50
CrossProductFunction · 0.50
GetFeatureIdMethod · 0.45
LengthMethod · 0.45
GetTurnPenaltyMethod · 0.45

Tested by

no test coverage detected