From e7a6e1323fca6f6f8a7e822371f8e893a2f6d884 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 26 Feb 2018 15:11:38 +0300 Subject: Review fixes. --- routing/turn_candidate.hpp | 4 ++-- routing/turns.cpp | 6 ++---- routing/turns_generator.cpp | 30 ++++++++++++++++-------------- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'routing') diff --git a/routing/turn_candidate.hpp b/routing/turn_candidate.hpp index 0773072662..e6bc8c528e 100644 --- a/routing/turn_candidate.hpp +++ b/routing/turn_candidate.hpp @@ -29,8 +29,8 @@ struct TurnCandidate /// |m_segment| is the first segment of a possible way from the junction. Segment m_segment; - /// \brief |highwayClass| field for the road class caching. Because feature reading is a long - /// function. + /// \brief |highwayClass| field for the road class caching. Because feature reading is + /// a time-consuming function. ftypes::HighwayClass m_highwayClass; /// If |isLink| is true then the turn candidate is a link. diff --git a/routing/turns.cpp b/routing/turns.cpp index cabb81108f..5c55fa22f7 100644 --- a/routing/turns.cpp +++ b/routing/turns.cpp @@ -65,10 +65,8 @@ SegmentRange::SegmentRange(FeatureID const & featureId, uint32_t startSegId, uin : m_featureId(featureId), m_startSegId(startSegId), m_endSegId(endSegId), m_forward(forward), m_start(start), m_end(end) { - if (m_forward) - CHECK_LESS_OR_EQUAL(m_startSegId, m_endSegId, (*this)); - else - CHECK_LESS_OR_EQUAL(m_endSegId, m_startSegId, (*this)); + if (m_startSegId != m_endSegId) + CHECK_EQUAL(m_forward, m_startSegId < m_endSegId, (*this)); } bool SegmentRange::operator==(SegmentRange const & rhs) const diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 299efe29f3..ac2f6d3cbb 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -133,14 +133,18 @@ bool DiscardTurnByIngoingAndOutgoingEdges(CarDirection intermediateDirection, bo return false; } - // Checks if all turn candidates go straight or make a slight turn to left or to right. - bool turnCandidatesGoAlmostStraight = - turnCandidates.isCandidatesAngleValid - ? DoAllTurnCandidatesGoAlmostStraight(turnCandidates.candidates) - : false; - - if (turnCandidatesGoAlmostStraight) + // @TODO(bykoianko) If all turn candidates go almost straight and there are several ways + // from the junction (|hasMultiTurns| == true) the turn will be discarded. + // If all turn candidates go almost straight and there is only one way + // from the junction (|hasMultiTurns| == false) the turn will not be discarded in this method, + // and then may be kept. It means that in some cases if there are two or more possible + // ways from a junction the turn may be discarded and if there is only one way out + // the turn may be kept. This code should be redesigned. + if (turnCandidates.isCandidatesAngleValid && + DoAllTurnCandidatesGoAlmostStraight(turnCandidates.candidates)) + { return !hasMultiTurns; + } return ((!hasMultiTurns && IsGoStraightOrSlightTurn(intermediateDirection)) || (hasMultiTurns && intermediateDirection == CarDirection::GoStraight)); @@ -727,16 +731,14 @@ void GetTurnDirection(IRoutingResult const & result, NumMwmIds const & numMwmIds return; } - // Removing a slight turn if ingoing and outgoing edge are not links and all other + // Removing a slight turn if ingoing and outgoing edges are not links and all other // possible ways out are links. if (!turnInfo.m_ingoing.m_isLink && !turnInfo.m_outgoing.m_isLink && - turnInfo.m_ingoing.m_highwayClass == turnInfo.m_outgoing.m_highwayClass) + turnInfo.m_ingoing.m_highwayClass == turnInfo.m_outgoing.m_highwayClass && + GetLinkCount(nodes.candidates) + 1 == nodes.candidates.size()) { - if (GetLinkCount(nodes.candidates) + 1 == nodes.candidates.size()) - { - turn.m_turn = CarDirection::None; - return; - } + turn.m_turn = CarDirection::None; + return; } } -- cgit v1.2.3