diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 5bb7d5f3ff..74f3612cf1 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -143,7 +143,6 @@ public: class IRoadGraph : public RoadGraphBase { public: - // CheckGraphConnectivity() types aliases: using Vertex = geometry::PointWithAltitude; using Edge = routing::Edge; using Weight = double; diff --git a/routing/routing_helpers.cpp b/routing/routing_helpers.cpp index 7ee0fbd413..b15fb761cc 100644 --- a/routing/routing_helpers.cpp +++ b/routing/routing_helpers.cpp @@ -208,6 +208,39 @@ bool RectCoversPolyline(IRoadGraph::PointWithAltitudeVec const & junctions, m2:: return false; } +bool CheckGraphConnectivity(Segment const & start, bool isOutgoing, bool useRoutingOptions, + size_t limit, WorldGraph & graph, std::set & marked) +{ + std::queue q; + q.push(start); + + marked.insert(start); + + std::vector edges; + while (!q.empty() && marked.size() < limit) + { + auto const u = q.front(); + q.pop(); + + edges.clear(); + + // Note. If |isOutgoing| == true outgoing edges are looked for. + // If |isOutgoing| == false it's the finish. So ingoing edges are looked for. + graph.GetEdgeList(u, isOutgoing, useRoutingOptions, edges); + for (auto const & edge : edges) + { + auto const & v = edge.GetTarget(); + if (marked.count(v) == 0) + { + q.push(v); + marked.insert(v); + } + } + } + + return marked.size() >= limit; +} + // AStarLengthChecker ------------------------------------------------------------------------------ AStarLengthChecker::AStarLengthChecker(IndexGraphStarter & starter) : m_starter(starter) {} diff --git a/routing/routing_helpers.hpp b/routing/routing_helpers.hpp index f4f049ab75..bbf0affea3 100644 --- a/routing/routing_helpers.hpp +++ b/routing/routing_helpers.hpp @@ -26,6 +26,8 @@ namespace routing { +class IndexGraphStarter; + inline double KMPH2MPS(double kmph) { return kmph * 1000.0 / (60 * 60); } template @@ -75,42 +77,9 @@ bool RectCoversPolyline(IRoadGraph::PointWithAltitudeVec const & junctions, m2:: /// of edges, /// if graph ends before this number is reached then junction is assumed as not connected to the /// world graph. -template -bool CheckGraphConnectivity(typename Graph::Vertex const & start, bool isOutgoing, - bool useRoutingOptions, size_t limit, Graph & graph, - std::set & marked) -{ - std::queue q; - q.push(start); - - marked.insert(start); - - std::vector edges; - while (!q.empty() && marked.size() < limit) - { - auto const u = q.front(); - q.pop(); - - edges.clear(); - - // Note. If |isOutgoing| == true outgoing edges are looked for. - // If |isOutgoing| == false it's the finish. So ingoing edges are looked for. - graph.GetEdgeList(u, isOutgoing, useRoutingOptions, edges); - for (auto const & edge : edges) - { - auto const & v = edge.GetTarget(); - if (marked.count(v) == 0) - { - q.push(v); - marked.insert(v); - } - } - } - - return marked.size() >= limit; -} - -class IndexGraphStarter; +bool CheckGraphConnectivity(Segment const & start, bool isOutgoing, + bool useRoutingOptions, size_t limit, WorldGraph & graph, + std::set & marked); struct AStarLengthChecker { diff --git a/routing/routing_tests/index_graph_tools.hpp b/routing/routing_tests/index_graph_tools.hpp index fdad81e8bc..90846d8b4c 100644 --- a/routing/routing_tests/index_graph_tools.hpp +++ b/routing/routing_tests/index_graph_tools.hpp @@ -50,10 +50,6 @@ using AlgorithmForWorldGraph = AStarAlgorithm class WorldGraphForAStar : public AStarGraph { public: - using Vertex = AStarGraph::Vertex; - using Edge = AStarGraph::Edge; - using Weight = AStarGraph::Weight; - explicit WorldGraphForAStar(std::unique_ptr graph) : m_graph(std::move(graph)) {} ~WorldGraphForAStar() override = default; @@ -66,12 +62,14 @@ public: void GetOutgoingEdgesList(Vertex const & v, std::vector & edges) override { - m_graph->GetOutgoingEdgesList(v, edges); + edges.clear(); + m_graph->GetEdgeList(v, true /* isOutgoing */, true /* useRoutingOptions */, edges); } void GetIngoingEdgesList(Vertex const & v, std::vector & edges) override { - m_graph->GetIngoingEdgesList(v, edges); + edges.clear(); + m_graph->GetEdgeList(v, false /* isOutgoing */, true /* useRoutingOptions */, edges); } RouteWeight GetAStarWeightEpsilon() override { return RouteWeight(0.0); } diff --git a/routing/single_vehicle_world_graph.cpp b/routing/single_vehicle_world_graph.cpp index 56bfd2d338..b46e163e5d 100644 --- a/routing/single_vehicle_world_graph.cpp +++ b/routing/single_vehicle_world_graph.cpp @@ -131,20 +131,6 @@ bool SingleVehicleWorldGraph::IsPassThroughAllowed(NumMwmId mwmId, uint32_t feat return GetRoadGeometry(mwmId, featureId).IsPassThroughAllowed(); } -void SingleVehicleWorldGraph::GetOutgoingEdgesList(Segment const & segment, - vector & edges) -{ - edges.clear(); - GetEdgeList(segment, true /* isOutgoing */, true /* useRoutingOptions */, edges); -} - -void SingleVehicleWorldGraph::GetIngoingEdgesList(Segment const & segment, - vector & edges) -{ - edges.clear(); - GetEdgeList(segment, false /* isOutgoing */, true /* useRoutingOptions */, edges); -} - RouteWeight SingleVehicleWorldGraph::HeuristicCostEstimate(Segment const & from, Segment const & to) { return HeuristicCostEstimate(GetPoint(from, true /* front */), GetPoint(to, true /* front */)); diff --git a/routing/single_vehicle_world_graph.hpp b/routing/single_vehicle_world_graph.hpp index d5115d6dd5..001b6fe641 100644 --- a/routing/single_vehicle_world_graph.hpp +++ b/routing/single_vehicle_world_graph.hpp @@ -53,9 +53,6 @@ public: void SetMode(WorldGraphMode mode) override { m_mode = mode; } WorldGraphMode GetMode() const override { return m_mode; } - void GetOutgoingEdgesList(Segment const & segment, std::vector & edges) override; - void GetIngoingEdgesList(Segment const & segment, std::vector & edges) override; - RouteWeight HeuristicCostEstimate(Segment const & from, Segment const & to) override; RouteWeight HeuristicCostEstimate(m2::PointD const & from, m2::PointD const & to) override; RouteWeight HeuristicCostEstimate(Segment const & from, m2::PointD const & to) override; diff --git a/routing/transit_world_graph.cpp b/routing/transit_world_graph.cpp index e0ae3624b7..199573bd6e 100644 --- a/routing/transit_world_graph.cpp +++ b/routing/transit_world_graph.cpp @@ -107,18 +107,6 @@ void TransitWorldGraph::ClearCachedGraphs() m_transitLoader->Clear(); } -void TransitWorldGraph::GetOutgoingEdgesList(Segment const & segment, vector & edges) -{ - edges.clear(); - GetEdgeList(segment, true /* isOutgoing */, true /* useRoutingOptions */, edges); -} - -void TransitWorldGraph::GetIngoingEdgesList(Segment const & segment, vector & edges) -{ - edges.clear(); - GetEdgeList(segment, false /* isOutgoing */, true /* useRoutingOptions */, edges); -} - RouteWeight TransitWorldGraph::HeuristicCostEstimate(Segment const & from, Segment const & to) { return HeuristicCostEstimate(GetPoint(from, true /* front */), GetPoint(to, true /* front */)); diff --git a/routing/transit_world_graph.hpp b/routing/transit_world_graph.hpp index 148e4ac736..3a69fdfa8e 100644 --- a/routing/transit_world_graph.hpp +++ b/routing/transit_world_graph.hpp @@ -56,8 +56,6 @@ public: void ClearCachedGraphs() override; void SetMode(WorldGraphMode mode) override { m_mode = mode; } WorldGraphMode GetMode() const override { return m_mode; } - void GetOutgoingEdgesList(Segment const & segment, std::vector & edges) override; - void GetIngoingEdgesList(Segment const & segment, std::vector & edges) override; RouteWeight HeuristicCostEstimate(Segment const & from, Segment const & to) override; RouteWeight HeuristicCostEstimate(m2::PointD const & from, m2::PointD const & to) override; RouteWeight HeuristicCostEstimate(Segment const & from, m2::PointD const & to) override; diff --git a/routing/world_graph.hpp b/routing/world_graph.hpp index bcbf20a6d9..28ee0a1677 100644 --- a/routing/world_graph.hpp +++ b/routing/world_graph.hpp @@ -41,11 +41,6 @@ enum class WorldGraphMode class WorldGraph { public: - // AStarAlgorithm and CheckGraphConnectivity() types aliases: - using Vertex = IndexGraph::Vertex; - using Edge = IndexGraph::Edge; - using Weight = IndexGraph::Weight; - virtual ~WorldGraph() = default; virtual void GetEdgeList(Segment const & segment, bool isOutgoing, bool useRoutingOptions, @@ -69,9 +64,6 @@ public: virtual void SetMode(WorldGraphMode mode) = 0; virtual WorldGraphMode GetMode() const = 0; - virtual void GetOutgoingEdgesList(Segment const & segment, std::vector & edges) = 0; - virtual void GetIngoingEdgesList(Segment const & segment, std::vector & edges) = 0; - virtual RouteWeight HeuristicCostEstimate(Segment const & from, Segment const & to) = 0; virtual RouteWeight HeuristicCostEstimate(m2::PointD const & from, m2::PointD const & to) = 0; virtual RouteWeight HeuristicCostEstimate(Segment const & from, m2::PointD const & to) = 0;