diff options
author | Добрый Ээх <bukharaev@gmail.com> | 2017-01-23 15:14:52 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2017-01-31 13:54:44 +0300 |
commit | 9b95234b255e971b4ed45e80e8c769c880c8b246 (patch) | |
tree | ba59c07bf032dc6f4e4956d0bbb4fac66711cce7 /routing | |
parent | 74b767b7bf49859e5664c6d9ec11a941e1b5caa7 (diff) |
[routing] fix double junction route
Diffstat (limited to 'routing')
-rw-r--r-- | routing/index_road_graph.cpp | 15 | ||||
-rw-r--r-- | routing/index_road_graph.hpp | 6 | ||||
-rw-r--r-- | routing/segment.hpp | 4 |
3 files changed, 16 insertions, 9 deletions
diff --git a/routing/index_road_graph.cpp b/routing/index_road_graph.cpp index ab5d45b81d..557810a66f 100644 --- a/routing/index_road_graph.cpp +++ b/routing/index_road_graph.cpp @@ -12,8 +12,8 @@ IndexRoadGraph::IndexRoadGraph(MwmSet::MwmId const & mwmId, Index const & index, for (size_t i = 0; i < junctions.size(); ++i) { Junction const & junction = junctions[i]; - m_endToSegment[junction] = segments[i]; - m_beginToSegment[junction] = segments[i + 1]; + m_endToSegment[junction].push_back(segments[i]); + m_beginToSegment[junction].push_back(segments[i + 1]); } } @@ -64,7 +64,13 @@ void IndexRoadGraph::GetEdges(Junction const & junction, bool isOutgoing, TEdgeV edges.clear(); vector<SegmentEdge> segmentEdges; - m_starter.GetEdgesList(GetSegment(junction, isOutgoing), isOutgoing, segmentEdges); + vector<SegmentEdge> tmpEdges; + for (Segment const & segment : GetSegments(junction, isOutgoing)) + { + tmpEdges.clear(); + m_starter.GetEdgesList(segment, isOutgoing, tmpEdges); + segmentEdges.insert(segmentEdges.end(), tmpEdges.begin(), tmpEdges.end()); + } for (SegmentEdge const & segmentEdge : segmentEdges) { @@ -84,7 +90,8 @@ Junction IndexRoadGraph::GetJunction(Segment const & segment, bool front) const return Junction(m_starter.GetPoint(segment, front), feature::kDefaultAltitudeMeters); } -const Segment & IndexRoadGraph::GetSegment(Junction const & junction, bool isOutgoing) const +vector<Segment> const & IndexRoadGraph::GetSegments(Junction const & junction, + bool isOutgoing) const { auto const & junctionToSegment = isOutgoing ? m_endToSegment : m_beginToSegment; diff --git a/routing/index_road_graph.hpp b/routing/index_road_graph.hpp index 2d731c6c99..c6f4ba7ca6 100644 --- a/routing/index_road_graph.hpp +++ b/routing/index_road_graph.hpp @@ -29,13 +29,13 @@ public: private: void GetEdges(Junction const & junction, bool isOutgoing, TEdgeVector & edges) const; Junction GetJunction(Segment const & segment, bool front) const; - const Segment & GetSegment(Junction const & junction, bool isOutgoing) const; + vector<Segment> const & GetSegments(Junction const & junction, bool isOutgoing) const; MwmSet::MwmId const & m_mwmId; Index const & m_index; double const m_maxSpeedKMPH; IndexGraphStarter & m_starter; - map<Junction, Segment> m_beginToSegment; - map<Junction, Segment> m_endToSegment; + map<Junction, vector<Segment>> m_beginToSegment; + map<Junction, vector<Segment>> m_endToSegment; }; } // namespace routing diff --git a/routing/segment.hpp b/routing/segment.hpp index f3a9006f33..e723998bdd 100644 --- a/routing/segment.hpp +++ b/routing/segment.hpp @@ -73,8 +73,8 @@ public: private: // Target is vertex going to for outgoing edges, vertex going from for ingoing edges. - Segment const m_target; - double const m_weight; + Segment m_target; + double m_weight; }; inline string DebugPrint(Segment const & segment) |