diff options
author | tatiana-kondakova <tatiana.kondakova@gmail.com> | 2017-09-28 14:02:50 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2017-09-29 18:38:29 +0300 |
commit | 94c9c467299ce448cf6f76bab3fc29f6e9691b3d (patch) | |
tree | 5cb718aeb9bbe61f1df112f30513f9a85184bf69 | |
parent | 19c5b06135be172f6c4b7494dcdce99eb29b948d (diff) |
Remove GetIndexGraph from WorldGraph interface
-rw-r--r-- | routing/index_router.cpp | 5 | ||||
-rw-r--r-- | routing/routing_tests/index_graph_tools.cpp | 2 | ||||
-rw-r--r-- | routing/routing_tests/index_graph_tools.hpp | 2 | ||||
-rw-r--r-- | routing/routing_tests/restriction_test.cpp | 12 | ||||
-rw-r--r-- | routing/world_graph.cpp | 10 | ||||
-rw-r--r-- | routing/world_graph.hpp | 7 |
6 files changed, 25 insertions, 13 deletions
diff --git a/routing/index_router.cpp b/routing/index_router.cpp index b2db2c5195..23e4be5063 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -742,8 +742,9 @@ IRouter::ResultCode IndexRouter::ProcessLeaps(vector<Segment> const & input, else { // Single mwm route. - IndexGraph & indexGraph = worldGraph.GetIndexGraph(current.GetMwmId()); - result = FindPath(current, next, delegate, indexGraph, {} /* onVisitedVertexCallback */, routingResult); + worldGraph.SetSingleMwmMode(current.GetMwmId()); + result = FindPath(current, next, delegate, worldGraph, {} /* onVisitedVertexCallback */, routingResult); + worldGraph.UnsetSingleMwmMode(); } if (result != IRouter::NoError) return result; diff --git a/routing/routing_tests/index_graph_tools.cpp b/routing/routing_tests/index_graph_tools.cpp index f5635442e7..ff4316215c 100644 --- a/routing/routing_tests/index_graph_tools.cpp +++ b/routing/routing_tests/index_graph_tools.cpp @@ -187,7 +187,7 @@ unique_ptr<WorldGraph> TestIndexGraphTopology::Builder::PrepareIndexGraph() BuildJoints(); auto worldGraph = BuildWorldGraph(move(loader), estimator, m_joints); - worldGraph->GetIndexGraph(kTestNumMwmId).SetRoadAccess(move(m_roadAccess)); + worldGraph->GetIndexGraphForTests(kTestNumMwmId).SetRoadAccess(move(m_roadAccess)); return worldGraph; } diff --git a/routing/routing_tests/index_graph_tools.hpp b/routing/routing_tests/index_graph_tools.hpp index 35729233be..b9fbcacff3 100644 --- a/routing/routing_tests/index_graph_tools.hpp +++ b/routing/routing_tests/index_graph_tools.hpp @@ -48,7 +48,7 @@ struct RestrictionTest void SetRestrictions(RestrictionVec && restrictions) { - m_graph->GetIndexGraph(kTestNumMwmId).SetRestrictions(move(restrictions)); + m_graph->GetIndexGraphForTests(kTestNumMwmId).SetRestrictions(move(restrictions)); } unique_ptr<WorldGraph> m_graph; diff --git a/routing/routing_tests/restriction_test.cpp b/routing/routing_tests/restriction_test.cpp index d9291bf95c..3a8d0c24ed 100644 --- a/routing/routing_tests/restriction_test.cpp +++ b/routing/routing_tests/restriction_test.cpp @@ -200,7 +200,7 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionOnlyF5F3) RestrictionVec restrictionsOnly = { {Restriction::Type::Only, {5 /* feature from */, 3 /* feature to */}}}; RestrictionVec restrictionsNo; - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = { {3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}, {0, 2}, {0, 3}}; @@ -312,7 +312,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph_RestrictionF3F1Only) RestrictionVec restrictionsOnly = { {Restriction::Type::Only, {3 /* feature from */, 1 /* feature to */}}}; RestrictionVec restrictionsNo; - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = { {3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}, {0, 1}, {0, 2}, {0, 3}}; @@ -410,7 +410,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3Only) RestrictionVec restrictionsOnly = { {Restriction::Type::Only, {10 /* feature from */, 3 /* feature to */}}}; RestrictionVec restrictionsNo; - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = { @@ -432,7 +432,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3OnlyF3F4Only) {Restriction::Type::Only, {3 /* feature from */, 4 /* feature to */}}, {Restriction::Type::Only, {10 /* feature from */, 3 /* feature to */}}}; RestrictionVec restrictionsNo; - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = { @@ -455,7 +455,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF2F8NoRestrictionF9F RestrictionVec const restrictionsOnly = { {Restriction::Type::Only, {9 /* feature from */, 1 /* feature to */}}}; // Invalid restriction. - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = {{3 /* x */, 0 /* y */}, {2, 0}, {1, 1}, {0, 2}, {0, 3}}; @@ -664,7 +664,7 @@ UNIT_CLASS_TEST(RestrictionTest, PosterGraph_RestrictionF0F1Only) RestrictionVec restrictionsOnly = { {Restriction::Type::Only, {0 /* feature from */, 1 /* feature to */}}}; RestrictionVec restrictionsNo; - ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraph(kTestNumMwmId), restrictionsOnly, + ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly, restrictionsNo); vector<m2::PointD> const expectedGeom = { diff --git a/routing/world_graph.cpp b/routing/world_graph.cpp index 54cfd91093..2f40825fad 100644 --- a/routing/world_graph.cpp +++ b/routing/world_graph.cpp @@ -15,6 +15,12 @@ WorldGraph::WorldGraph(unique_ptr<CrossMwmGraph> crossMwmGraph, unique_ptr<Index void WorldGraph::GetEdgeList(Segment const & segment, bool isOutgoing, bool isLeap, bool isEnding, std::vector<SegmentEdge> & edges) { + if (IsInSingleMwmMode()) + { + m_loader->GetIndexGraph(m_mwmId).GetEdgeList(segment, isOutgoing, edges); + return; + } + // If mode is LeapsOnly and |isEnding| == true we need to connect segment to transitions. // If |isOutgoing| == true connects |segment| with all exits of mwm. // If |isOutgoing| == false connects all enters to mwm with |segment|. @@ -45,7 +51,7 @@ void WorldGraph::GetEdgeList(Segment const & segment, bool isOutgoing, bool isLe return; } - IndexGraph & indexGraph = GetIndexGraph(segment.GetMwmId()); + IndexGraph & indexGraph = m_loader->GetIndexGraph(segment.GetMwmId()); indexGraph.GetEdgeList(segment, isOutgoing, edges); if (m_crossMwmGraph && m_crossMwmGraph->IsTransition(segment, isOutgoing)) @@ -65,7 +71,7 @@ m2::PointD const & WorldGraph::GetPoint(Segment const & segment, bool front) RoadGeometry const & WorldGraph::GetRoadGeometry(NumMwmId mwmId, uint32_t featureId) { - return GetIndexGraph(mwmId).GetGeometry().GetRoad(featureId); + return m_loader->GetIndexGraph(mwmId).GetGeometry().GetRoad(featureId); } void WorldGraph::GetOutgoingEdgesList(Segment const & segment, vector<SegmentEdge> & edges) diff --git a/routing/world_graph.hpp b/routing/world_graph.hpp index b372b15709..f6f96d09ef 100644 --- a/routing/world_graph.hpp +++ b/routing/world_graph.hpp @@ -5,6 +5,7 @@ #include "routing/geometry.hpp" #include "routing/index_graph.hpp" #include "routing/index_graph_loader.hpp" +#include "routing/num_mwm_id.hpp" #include "routing/segment.hpp" #include <memory> @@ -45,7 +46,9 @@ public: void GetEdgeList(Segment const & segment, bool isOutgoing, bool isLeap, bool isEnding, std::vector<SegmentEdge> & edges); - IndexGraph & GetIndexGraph(NumMwmId numMwmId) { return m_loader->GetIndexGraph(numMwmId); } + IndexGraph & GetIndexGraphForTests(NumMwmId numMwmId) { return m_loader->GetIndexGraph(numMwmId); } + void SetSingleMwmMode(NumMwmId numMwmId) { m_mwmId = numMwmId; } + void UnsetSingleMwmMode() { m_mwmId = kFakeNumMwmId; } Junction const & GetJunction(Segment const & segment, bool front); m2::PointD const & GetPoint(Segment const & segment, bool front); @@ -68,12 +71,14 @@ public: private: void GetTwins(Segment const & s, bool isOutgoing, std::vector<SegmentEdge> & edges); + bool IsInSingleMwmMode() { return m_mwmId != kFakeNumMwmId; } std::unique_ptr<CrossMwmGraph> m_crossMwmGraph; std::unique_ptr<IndexGraphLoader> m_loader; std::shared_ptr<EdgeEstimator> m_estimator; std::vector<Segment> m_twins; Mode m_mode = Mode::NoLeaps; + NumMwmId m_mwmId = kFakeNumMwmId; }; std::string DebugPrint(WorldGraph::Mode mode); |