diff --git a/routing/dijkstra_router.cpp b/routing/dijkstra_router.cpp index 09a61b1d84..504441b09b 100644 --- a/routing/dijkstra_router.cpp +++ b/routing/dijkstra_router.cpp @@ -26,6 +26,9 @@ void DijkstraRouter::CalculateRoute(vector const & startPos, vector startSet(startPos.begin(), startPos.end()); + set startFeatureSet; + for (vector::const_iterator it = startPos.begin(); it != startPos.end(); ++it) + startFeatureSet.insert(it->GetFeatureId()); while (!m_queue.empty()) { double const cost = m_queue.top().m_cost; @@ -53,7 +56,9 @@ void DijkstraRouter::CalculateRoute(vector const & startPos, vectorGetPos()) != startSet.end()) + bool const bStartFeature = startFeatureSet.find(pEntry->GetPos().GetFeatureId()) != startFeatureSet.end(); + + if (bStartFeature && startSet.find(pEntry->GetPos()) != startSet.end()) { LOG(LDEBUG, ("Found result!")); // Reached one of the starting points! @@ -64,7 +69,7 @@ void DijkstraRouter::CalculateRoute(vector const & startPos, vectorGetPossibleTurns(pEntry->GetPos(), turns); + m_pRoadGraph->GetPossibleTurns(pEntry->GetPos(), turns, bStartFeature); LOG(LDEBUG, ("Getting all turns", turns)); for (IRoadGraph::TurnsVectorT::const_iterator iTurn = turns.begin(); iTurn != turns.end(); ++iTurn) { diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 4febf77b92..4aa11d31bb 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -108,7 +108,7 @@ void FeatureRoadGraph::LoadFeature(uint32_t id, FeatureType & ft) ASSERT_GREATER(ft.GetPointsCount(), 1, (id)); } -void FeatureRoadGraph::GetPossibleTurns(RoadPos const & pos, vector & turns) +void FeatureRoadGraph::GetPossibleTurns(RoadPos const & pos, vector & turns, bool noOptimize /*= true*/) { uint32_t const ftId = pos.GetFeatureId(); FeatureType ft; @@ -149,7 +149,7 @@ void FeatureRoadGraph::GetPossibleTurns(RoadPos const & pos, vector 0) + if (crossLoader.GetCount() > 0 || noOptimize) { // Push turn points for this feature. if (isForward) diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index 9d25765675..b9c93ef75f 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -18,7 +18,7 @@ class FeatureRoadGraph : public IRoadGraph public: FeatureRoadGraph(Index const * pIndex, size_t mwmID); - virtual void GetPossibleTurns(RoadPos const & pos, vector & turns); + virtual void GetPossibleTurns(RoadPos const & pos, vector & turns, bool noOptimize = true); virtual void ReconstructPath(RoadPosVectorT const & positions, Route & route); static uint32_t GetStreetReadScale(); diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 3bbfb177c6..00a1059623 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -74,7 +74,7 @@ public: virtual ~IRoadGraph() {} /// Find all feature sections (turns), that route to the "pos" section. - virtual void GetPossibleTurns(RoadPos const & pos, TurnsVectorT & turns) = 0; + virtual void GetPossibleTurns(RoadPos const & pos, TurnsVectorT & turns, bool noOptimize = true) = 0; /// Construct route by road positions (doesn't include first and last section). virtual void ReconstructPath(RoadPosVectorT const & positions, Route & route) = 0; }; diff --git a/routing/routing_tests/road_graph_builder.cpp b/routing/routing_tests/road_graph_builder.cpp index 8d1f2c2514..29c079c3cc 100644 --- a/routing/routing_tests/road_graph_builder.cpp +++ b/routing/routing_tests/road_graph_builder.cpp @@ -50,7 +50,7 @@ void RoadGraphMockSource::AddRoad(RoadInfo & rd) m_roads.back().Swap(rd); } -void RoadGraphMockSource::GetPossibleTurns(RoadPos const & pos, TurnsVectorT & turns) +void RoadGraphMockSource::GetPossibleTurns(RoadPos const & pos, TurnsVectorT & turns, bool /*noOptimize = true*/) { uint32_t const fID = pos.GetFeatureId(); ASSERT_LESS(fID, m_roads.size(), ()); diff --git a/routing/routing_tests/road_graph_builder.hpp b/routing/routing_tests/road_graph_builder.hpp index e34bd5fd63..39ee03ee17 100644 --- a/routing/routing_tests/road_graph_builder.hpp +++ b/routing/routing_tests/road_graph_builder.hpp @@ -46,7 +46,7 @@ class RoadGraphMockSource : public routing::IRoadGraph public: void AddRoad(RoadInfo & rd); - virtual void GetPossibleTurns(routing::RoadPos const & pos, TurnsVectorT & turns); + virtual void GetPossibleTurns(routing::RoadPos const & pos, TurnsVectorT & turns, bool noOptimize = true); virtual void ReconstructPath(RoadPosVectorT const & positions, routing::Route & route); };