From 6dc10d695fbfc5df6ef63c6b3f17bf8bad1f5baf Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 5 Aug 2019 14:54:15 +0300 Subject: [PATCH] [routing] Calling GetSegmentCandidateForRoadPoint() for joints and for feature ends. --- routing/index_graph.cpp | 50 +++++++++++++++++++++++++---------------- routing/index_graph.hpp | 2 ++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index 7e3173a454..094feb3243 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -234,6 +234,28 @@ void IndexGraph::GetNeighboringEdges(Segment const & from, RoadPoint const & rp, } } +void IndexGraph::GetSegmentCandidateForRoadPoint(RoadPoint const & rp, NumMwmId numMwmId, + bool isOutgoing, std::vector & children) +{ + RoadGeometry const & road = m_geometry->GetRoad(rp.GetFeatureId()); + if (!road.IsValid()) + return; + + // Note. Flag |useRoutingOptions| is not passed to this place because it's true + // for all cases in current code. So if below should be checked anyway. + if (!road.SuitableForOptions(m_avoidRoutingOptions)) + return; + + bool const bidirectional = !road.IsOneWay(); + auto const pointId = rp.GetPointId(); + + if ((isOutgoing || bidirectional) && pointId + 1 < road.GetPointsCount()) + children.emplace_back(numMwmId, rp.GetFeatureId(), pointId, isOutgoing); + + if ((!isOutgoing || bidirectional) && pointId > 0) + children.emplace_back(numMwmId, rp.GetFeatureId(), pointId - 1, !isOutgoing); +} + void IndexGraph::GetSegmentCandidateForJoint(Segment const & parent, bool isOutgoing, vector & children) { @@ -241,27 +263,17 @@ void IndexGraph::GetSegmentCandidateForJoint(Segment const & parent, bool isOutg Joint::Id const jointId = m_roadIndex.GetJointId(roadPoint); if (jointId == Joint::kInvalidId) - return; - - m_jointIndex.ForEachPoint(jointId, [&](RoadPoint const & rp) { - RoadGeometry const & road = m_geometry->GetRoad(rp.GetFeatureId()); - if (!road.IsValid()) - return; + if (IsJointOrEnd(parent, isOutgoing)) + { + // It's not a joint but a loose end of a feature. + GetSegmentCandidateForRoadPoint(roadPoint, parent.GetMwmId(), isOutgoing, children); + } + return; + } - // Note. Flag |useRoutingOptions| is not passed to this place because it's true - // for all cases in current code. So if below should be checked anyway. - if (!road.SuitableForOptions(m_avoidRoutingOptions)) - return; - - bool const bidirectional = !road.IsOneWay(); - auto const pointId = rp.GetPointId(); - - if ((isOutgoing || bidirectional) && pointId + 1 < road.GetPointsCount()) - children.emplace_back(parent.GetMwmId(), rp.GetFeatureId(), pointId, isOutgoing); - - if ((!isOutgoing || bidirectional) && pointId > 0) - children.emplace_back(parent.GetMwmId(), rp.GetFeatureId(), pointId - 1, !isOutgoing); + m_jointIndex.ForEachPoint(jointId, [&](RoadPoint const & rp) { + GetSegmentCandidateForRoadPoint(rp, parent.GetMwmId(), isOutgoing, children); }); } diff --git a/routing/index_graph.hpp b/routing/index_graph.hpp index 86fa43cc8e..d9797168c1 100644 --- a/routing/index_graph.hpp +++ b/routing/index_graph.hpp @@ -127,6 +127,8 @@ private: std::vector & edges, std::map & parents); RouteWeight GetPenalties(Segment const & u, Segment const & v); + void GetSegmentCandidateForRoadPoint(RoadPoint const & rp, NumMwmId numMwmId, + bool isOutgoing, std::vector & children); void GetSegmentCandidateForJoint(Segment const & parent, bool isOutgoing, std::vector & children); void ReconstructJointSegment(JointSegment const & parentJoint, Segment const & parent,