diff options
author | Добрый Ээх <bukharaev@gmail.com> | 2017-03-01 18:53:40 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2017-03-06 18:26:41 +0300 |
commit | 292baa3f0f951554fffbc69cfe49779f975f860a (patch) | |
tree | fd1b82b141674eebcd337f6c263d8eec4d07a61a | |
parent | a2f5dea96fa19dcf15072039d4f9fdf60bf115d4 (diff) |
[routing] fix reconstruct route while cross mwm leapsbeta-664igor_styles_170307
-rw-r--r-- | routing/directions_engine.cpp | 7 | ||||
-rw-r--r-- | routing/index_router.cpp | 29 | ||||
-rw-r--r-- | routing/index_router.hpp | 6 | ||||
-rw-r--r-- | routing/world_graph.cpp | 11 | ||||
-rw-r--r-- | routing/world_graph.hpp | 14 |
5 files changed, 42 insertions, 25 deletions
diff --git a/routing/directions_engine.cpp b/routing/directions_engine.cpp index 0aa6b0e07b..cf20d4faec 100644 --- a/routing/directions_engine.cpp +++ b/routing/directions_engine.cpp @@ -1,5 +1,7 @@ #include "routing/directions_engine.hpp" +#include "geometry/mercator.hpp" + #include "base/assert.hpp" namespace @@ -78,7 +80,12 @@ bool IDirectionsEngine::ReconstructPath(RoadGraphBase const & graph, vector<Junc } if (!found) + { + LOG(LERROR, ("Can't find next edge, curr:", MercatorBounds::ToLatLon(curr.GetPoint()), + ", next:", MercatorBounds::ToLatLon(next.GetPoint()), ", edges size:", + currEdges.size(), ", i:", i)); return false; + } curr = next; } diff --git a/routing/index_router.cpp b/routing/index_router.cpp index c02d9e950f..053b78f191 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -83,7 +83,7 @@ IRouter::ResultCode IndexRouter::CalculateRouteForSingleMwm( } IRouter::ResultCode IndexRouter::CalculateRoute(string const & startCountry, - string const & finishCountry, bool blockMwmBorders, + string const & finishCountry, bool forSingleMwm, m2::PointD const & startPoint, m2::PointD const & startDirection, m2::PointD const & finalPoint, @@ -91,8 +91,8 @@ IRouter::ResultCode IndexRouter::CalculateRoute(string const & startCountry, { try { - return DoCalculateRoute(startCountry, finishCountry, blockMwmBorders, startPoint, - startDirection, finalPoint, delegate, route); + return DoCalculateRoute(startCountry, finishCountry, forSingleMwm, startPoint, startDirection, + finalPoint, delegate, route); } catch (RootException const & e) { @@ -102,10 +102,12 @@ IRouter::ResultCode IndexRouter::CalculateRoute(string const & startCountry, } } -IRouter::ResultCode IndexRouter::DoCalculateRoute( - string const & startCountry, string const & finishCountry, bool blockMwmBorders, - m2::PointD const & startPoint, m2::PointD const & /* startDirection */, - m2::PointD const & finalPoint, RouterDelegate const & delegate, Route & route) +IRouter::ResultCode IndexRouter::DoCalculateRoute(string const & startCountry, + string const & finishCountry, bool forSingleMwm, + m2::PointD const & startPoint, + m2::PointD const & /* startDirection */, + m2::PointD const & finalPoint, + RouterDelegate const & delegate, Route & route) { auto const startFile = platform::CountryFile(startCountry); auto const finishFile = platform::CountryFile(finishCountry); @@ -130,9 +132,7 @@ IRouter::ResultCode IndexRouter::DoCalculateRoute( make_unique<CrossMwmIndexGraph>(m_numMwmIds, m_indexManager), IndexGraphLoader::Create(m_numMwmIds, m_vehicleModelFactory, m_estimator, m_index), m_estimator); - - if (blockMwmBorders) - graph.CloseBorders(); + graph.SetMode(forSingleMwm ? WorldGraph::Mode::SingleMwm : WorldGraph::Mode::WorldWithLeaps); IndexGraphStarter starter(start, finish, graph); @@ -171,7 +171,7 @@ IRouter::ResultCode IndexRouter::DoCalculateRoute( CHECK_GREATER_OR_EQUAL(segments.size(), routingResult.path.size(), ()); - if (!RedressRoute(segments, delegate, starter, route)) + if (!RedressRoute(segments, delegate, forSingleMwm, starter, route)) return IRouter::InternalError; if (delegate.IsCancelled()) return IRouter::Cancelled; @@ -224,7 +224,7 @@ IRouter::ResultCode IndexRouter::ProcessLeaps(vector<Segment> const & input, output.reserve(input.size()); WorldGraph & worldGraph = starter.GetGraph(); - worldGraph.CloseBorders(); + worldGraph.SetMode(WorldGraph::Mode::SingleMwm); for (size_t i = 0; i < input.size(); ++i) { @@ -271,7 +271,7 @@ IRouter::ResultCode IndexRouter::ProcessLeaps(vector<Segment> const & input, } bool IndexRouter::RedressRoute(vector<Segment> const & segments, RouterDelegate const & delegate, - IndexGraphStarter & starter, Route & route) const + bool forSingleMwm, IndexGraphStarter & starter, Route & route) const { vector<Junction> junctions; size_t const numPoints = IndexGraphStarter::GetRouteNumPoints(segments); @@ -284,7 +284,8 @@ bool IndexRouter::RedressRoute(vector<Segment> const & segments, RouterDelegate } IndexRoadGraph roadGraph(m_numMwmIds, starter, segments, junctions, m_index); - starter.GetGraph().OpenBorders(); + if (!forSingleMwm) + starter.GetGraph().SetMode(WorldGraph::Mode::WorldWithoutLeaps); CHECK(m_directionsEngine, ()); ReconstructRoute(*m_directionsEngine, roadGraph, m_trafficStash, delegate, junctions, route); diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 50f9ecc7b3..0c71d2647d 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -54,12 +54,12 @@ public: private: IRouter::ResultCode CalculateRoute(string const & startCountry, string const & finishCountry, - bool blockMwmBorders, m2::PointD const & startPoint, + bool forSingleMwm, m2::PointD const & startPoint, m2::PointD const & startDirection, m2::PointD const & finalPoint, RouterDelegate const & delegate, Route & route); IRouter::ResultCode DoCalculateRoute(string const & startCountry, string const & finishCountry, - bool blockMwmBorders, m2::PointD const & startPoint, + bool forSingleMwm, m2::PointD const & startPoint, m2::PointD const & startDirection, m2::PointD const & finalPoint, RouterDelegate const & delegate, Route & route); @@ -70,7 +70,7 @@ private: IRouter::ResultCode ProcessLeaps(vector<Segment> const & input, RouterDelegate const & delegate, IndexGraphStarter & starter, vector<Segment> & output); bool RedressRoute(vector<Segment> const & segments, RouterDelegate const & delegate, - IndexGraphStarter & starter, Route & route) const; + bool forSingleMwm, IndexGraphStarter & starter, Route & route) const; string const m_name; Index & m_index; diff --git a/routing/world_graph.cpp b/routing/world_graph.cpp index 0546699eb6..a696f00876 100644 --- a/routing/world_graph.cpp +++ b/routing/world_graph.cpp @@ -15,8 +15,9 @@ WorldGraph::WorldGraph(unique_ptr<CrossMwmIndexGraph> crossMwmGraph, void WorldGraph::GetEdgeList(Segment const & segment, bool isOutgoing, bool isLeap, vector<SegmentEdge> & edges) { - if (m_crossMwmGraph && m_bordersAreOpened && isLeap) + if (isLeap && m_mode == Mode::WorldWithLeaps) { + CHECK(m_crossMwmGraph, ()); if (m_crossMwmGraph->IsTransition(segment, isOutgoing)) GetTwins(segment, isOutgoing, edges); else @@ -27,8 +28,12 @@ void WorldGraph::GetEdgeList(Segment const & segment, bool isOutgoing, bool isLe IndexGraph & indexGraph = GetIndexGraph(segment.GetMwmId()); indexGraph.GetEdgeList(segment, isOutgoing, edges); - if (m_crossMwmGraph && m_bordersAreOpened && m_crossMwmGraph->IsTransition(segment, isOutgoing)) - GetTwins(segment, isOutgoing, edges); + if (m_mode != Mode::SingleMwm) + { + CHECK(m_crossMwmGraph, ()); + if (m_crossMwmGraph->IsTransition(segment, isOutgoing)) + GetTwins(segment, isOutgoing, edges); + } } m2::PointD const & WorldGraph::GetPoint(Segment const & segment, bool front) diff --git a/routing/world_graph.hpp b/routing/world_graph.hpp index 9ff880111b..2b0ca9a002 100644 --- a/routing/world_graph.hpp +++ b/routing/world_graph.hpp @@ -16,6 +16,13 @@ namespace routing class WorldGraph final { public: + enum class Mode + { + SingleMwm, + WorldWithLeaps, + WorldWithoutLeaps, + }; + WorldGraph(std::unique_ptr<CrossMwmIndexGraph> crossMwmGraph, std::unique_ptr<IndexGraphLoader> loader, std::shared_ptr<EdgeEstimator> estimator); @@ -28,12 +35,9 @@ public: m2::PointD const & GetPoint(Segment const & segment, bool front); RoadGeometry const & GetRoadGeometry(NumMwmId mwmId, uint32_t featureId); - // Disable edges between mwms. - void CloseBorders() { m_bordersAreOpened = false; } - // Enable edges between mwms. - void OpenBorders() { m_bordersAreOpened = true; } // Clear memory used by loaded index graphs. void ClearIndexGraphs() { m_loader->Clear(); } + void SetMode(Mode mode) { m_mode = mode; } private: void GetTwins(Segment const & s, bool isOutgoing, std::vector<SegmentEdge> & edges); @@ -42,6 +46,6 @@ private: std::unique_ptr<IndexGraphLoader> m_loader; std::shared_ptr<EdgeEstimator> m_estimator; std::vector<Segment> m_twins; - bool m_bordersAreOpened = true; + Mode m_mode = Mode::SingleMwm; }; } // namespace routing |