diff --git a/routing/segment.hpp b/routing/segment.hpp index 052265bbb2..85cfece861 100644 --- a/routing/segment.hpp +++ b/routing/segment.hpp @@ -74,6 +74,8 @@ public: m_mwmId == seg.m_mwmId && m_forward != seg.m_forward; } + void Inverse() { m_forward = !m_forward; } + bool IsRealSegment() const { return m_mwmId != kFakeNumMwmId && !FakeFeatureIds::IsTransitFeature(m_featureId); diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 0ce68dd79f..daf56ea007 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -42,8 +42,9 @@ struct TurnHighwayClasses // |m_smallestRouteRoadClass| is equal to the less important road between ingoing and outgoing // segments. ftypes::HighwayClass m_smallestRouteRoadClass = ftypes::HighwayClass::Error; - // Let's consider all possible ways from the turn except for the way along the route. - // |m_biggestPossibleTurnRoadClass| should be equal to the class of the biggest road. + // Let's consider all possible ways from the turn except for the way along the route and + // the way which let us to make a U-turn by going along the ingoing segment. + // |m_biggestPossibleTurnRoadClass| should be equal to the class of the biggest road of such roads. ftypes::HighwayClass m_biggestPossibleTurnRoadClass = ftypes::HighwayClass::Error; }; @@ -125,10 +126,18 @@ bool GetTurnHighwayClasses(TurnCandidates const & possibleTurns, TurnInfo const if (!turnInfo.m_outgoing.m_segmentRange.GetFirstSegment(numMwmIds, firstOutgoingSegment)) return true; + Segment inversedLastIngoingSegment; + if (!turnInfo.m_ingoing.m_segmentRange.GetLastSegment(numMwmIds, inversedLastIngoingSegment)) + return true; + inversedLastIngoingSegment.Inverse(); + turnHighwayClasses.m_biggestPossibleTurnRoadClass = ftypes::HighwayClass::Count; for (auto const & t : possibleTurns.candidates) { - if (t.m_segment == firstOutgoingSegment) + // Let's consider all outgoing segments except for + // (1) route outgoing segment + // (2) a U-turn segment (inversedLastIngoingSegment) + if (t.m_segment == firstOutgoingSegment || t.m_segment == inversedLastIngoingSegment) continue; ftypes::HighwayClass const highwayClass = t.m_highwayClass; // Note. The bigger road the less HighwayClass value.