Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gorbushin <m.gorbushin@corp.mail.ru>2019-03-26 13:55:49 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2019-04-01 17:12:51 +0300
commitb6b8b4e26e455951efb13fcc25172d9c3de5733d (patch)
tree3970c49bf7e58bdf70dd34c8aa9678ada9a6c1ce /routing
parent9cc034a71703395ea9ee5f9da344bb9e20fcd260 (diff)
[routing] review fixes
Diffstat (limited to 'routing')
-rw-r--r--routing/index_graph_starter.hpp4
-rw-r--r--routing/index_graph_starter_joints.hpp3
-rw-r--r--routing/index_router.cpp16
-rw-r--r--routing/index_router.hpp2
-rw-r--r--routing/routing_tests/astar_algorithm_test.cpp3
-rw-r--r--routing/routing_tests/index_graph_tools.cpp50
-rw-r--r--routing/routing_tests/index_graph_tools.hpp30
-rw-r--r--routing/routing_tests/routing_algorithm.cpp8
8 files changed, 50 insertions, 66 deletions
diff --git a/routing/index_graph_starter.hpp b/routing/index_graph_starter.hpp
index b21bc86007..4d12f200ef 100644
--- a/routing/index_graph_starter.hpp
+++ b/routing/index_graph_starter.hpp
@@ -31,10 +31,6 @@ class FakeEdgesContainer;
class IndexGraphStarter : public AStarGraph<IndexGraph::Vertex, IndexGraph::Edge, IndexGraph::Weight>
{
public:
- // AStarAlgorithm types aliases:
- using Vertex = AStarGraph::Vertex;
- using Edge = AStarGraph::Edge;
- using Weight = AStarGraph::Weight;
friend class FakeEdgesContainer;
diff --git a/routing/index_graph_starter_joints.hpp b/routing/index_graph_starter_joints.hpp
index e27bde15ec..16efceeda4 100644
--- a/routing/index_graph_starter_joints.hpp
+++ b/routing/index_graph_starter_joints.hpp
@@ -26,9 +26,6 @@ template <typename Graph>
class IndexGraphStarterJoints : public AStarGraph<JointSegment, JointEdge, RouteWeight>
{
public:
- using Vertex = AStarGraph::Vertex;
- using Edge = AStarGraph::Edge;
- using Weight = AStarGraph::Weight;
explicit IndexGraphStarterJoints(Graph & graph) : m_graph(graph) {}
IndexGraphStarterJoints(Graph & graph,
diff --git a/routing/index_router.cpp b/routing/index_router.cpp
index a3d1f90feb..ec9c7e3ead 100644
--- a/routing/index_router.cpp
+++ b/routing/index_router.cpp
@@ -572,8 +572,8 @@ RouterResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoints,
auto checkLength = [&starter](RouteWeight const & weight) { return starter.CheckLength(weight); };
base::HighResTimer timer;
- WorldGraphMode mode = starter.GetGraph().GetMode();
- if (mode == WorldGraph::Mode::Joints)
+ WorldGraphMode const mode = starter.GetGraph().GetMode();
+ if (mode == WorldGraphMode::Joints)
{
IndexGraphStarterJoints<IndexGraphStarter> jointStarter(starter, starter.GetStartSegment(), starter.GetFinishSegment());
RoutingResult<JointSegment, RouteWeight> routingResult;
@@ -595,9 +595,9 @@ RouterResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoints,
delegate.OnPointCheck(pointFrom);
};
- using Vertex = IndexGraphStarterJoints::Vertex;
- using Edge = IndexGraphStarterJoints::Edge;
- using Weight = IndexGraphStarterJoints::Weight;
+ using Vertex = IndexGraphStarterJoints<IndexGraphStarter>::Vertex;
+ using Edge = IndexGraphStarterJoints<IndexGraphStarter>::Edge;
+ using Weight = IndexGraphStarterJoints<IndexGraphStarter>::Weight;
AStarAlgorithm<Vertex, Edge, Weight>::Params params(
jointStarter, jointStarter.GetStartJoint(), jointStarter.GetFinishJoint(), nullptr /* prevRoute */,
@@ -916,9 +916,9 @@ RouterResultCode IndexRouter::ProcessLeapsJoints(vector<Segment> const & input,
fillMwmIds(start, end, mwmIds);
- using Vertex = IndexGraphStarterJoints::Vertex;
- using Edge = IndexGraphStarterJoints::Edge;
- using Weight = IndexGraphStarterJoints::Weight;
+ using Vertex = IndexGraphStarterJoints<IndexGraphStarter>::Vertex;
+ using Edge = IndexGraphStarterJoints<IndexGraphStarter>::Edge;
+ using Weight = IndexGraphStarterJoints<IndexGraphStarter>::Weight;
AStarAlgorithm<Vertex, Edge, Weight>::Params params(
jointStarter, jointStarter.GetStartJoint(), jointStarter.GetFinishJoint(),
diff --git a/routing/index_router.hpp b/routing/index_router.hpp
index e2b5e44aa8..8e309f5738 100644
--- a/routing/index_router.hpp
+++ b/routing/index_router.hpp
@@ -143,7 +143,7 @@ private:
template <typename Vertex, typename Edge, typename Weight>
RouterResultCode FindPath(
typename AStarAlgorithm<Vertex, Edge, Weight>::Params & params, std::set<NumMwmId> const & mwmIds,
- RoutingResult<Vertex, Weight> & routingResult, WorldGraph::Mode mode) const
+ RoutingResult<Vertex, Weight> & routingResult, WorldGraphMode mode) const
{
AStarAlgorithm<Vertex, Edge, Weight> algorithm;
if (mode == WorldGraphMode::LeapsOnly)
diff --git a/routing/routing_tests/astar_algorithm_test.cpp b/routing/routing_tests/astar_algorithm_test.cpp
index 60a4488346..e05cc7bd82 100644
--- a/routing/routing_tests/astar_algorithm_test.cpp
+++ b/routing/routing_tests/astar_algorithm_test.cpp
@@ -27,9 +27,6 @@ struct Edge
class UndirectedGraph : public AStarGraph<unsigned, routing_test::Edge, double>
{
public:
- using Vertex = AStarGraph::Vertex;
- using Edge = AStarGraph::Edge;
- using Weight = AStarGraph::Weight;
void AddEdge(unsigned u, unsigned v, unsigned w)
{
diff --git a/routing/routing_tests/index_graph_tools.cpp b/routing/routing_tests/index_graph_tools.cpp
index 52f7799216..95faf43111 100644
--- a/routing/routing_tests/index_graph_tools.cpp
+++ b/routing/routing_tests/index_graph_tools.cpp
@@ -21,6 +21,33 @@ namespace
{
double constexpr kEpsilon = 1e-6;
+class WorldGraphForAStar : public AStarGraph<Segment, SegmentEdge, RouteWeight>
+{
+public:
+
+ explicit WorldGraphForAStar(WorldGraph & graph) : m_graph(graph) {}
+
+ Weight HeuristicCostEstimate(Vertex const & from, Vertex const & to) override
+ {
+ return m_graph.HeuristicCostEstimate(from, to);
+ }
+
+ void GetOutgoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
+ {
+ m_graph.GetOutgoingEdgesList(v, edges);
+ }
+
+ void GetIngoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
+ {
+ m_graph.GetIngoingEdgesList(v, edges);
+ }
+
+ ~WorldGraphForAStar() override = default;
+
+private:
+ WorldGraph & m_graph;
+};
+
template <typename Graph>
Graph & GetGraph(unordered_map<NumMwmId, unique_ptr<Graph>> const & graphs, NumMwmId mwmId)
{
@@ -199,8 +226,8 @@ bool TestIndexGraphTopology::FindPath(Vertex start, Vertex finish, double & path
WorldGraphForAStar graphForAStar(*worldGraph);
AlgorithmForWorldGraph::ParamsForTests params(graphForAStar, startSegment, finishSegment,
- nullptr /* prevRoute */,
- {} /* checkLengthCallback */);
+ nullptr /* prevRoute */,
+ {} /* checkLengthCallback */);
RoutingResult<Segment, RouteWeight> routingResult;
auto const resultCode = algorithm.FindPathBidirectional(params, routingResult);
@@ -216,8 +243,8 @@ bool TestIndexGraphTopology::FindPath(Vertex start, Vertex finish, double & path
if (resultCode == AlgorithmForWorldGraph::Result::NoPath)
return false;
- CHECK_EQUAL(resultCode, AlgorithmForWorldGraph::Result::OK, ());
+ CHECK_EQUAL(resultCode, AlgorithmForWorldGraph::Result::OK, ());
CHECK_GREATER_OR_EQUAL(routingResult.m_path.size(), 2, ());
CHECK_EQUAL(routingResult.m_path.front(), startSegment, ());
CHECK_EQUAL(routingResult.m_path.back(), finishSegment, ());
@@ -383,14 +410,13 @@ shared_ptr<EdgeEstimator> CreateEstimatorForCar(shared_ptr<TrafficStash> traffic
return EdgeEstimator::Create(VehicleType::Car, *carModel, trafficStash);
}
-AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result
-CalculateRoute(IndexGraphStarter & starter, vector<Segment> & roadPoints,
- double & timeSec)
+AlgorithmForWorldGraph::Result CalculateRoute(IndexGraphStarter & starter, vector<Segment> & roadPoints,
+ double & timeSec)
{
- AStarAlgorithm<Segment, SegmentEdge, RouteWeight> algorithm;
+ AlgorithmForWorldGraph algorithm;
RoutingResult<Segment, RouteWeight> routingResult;
- AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::ParamsForTests params(
+ AlgorithmForWorldGraph::ParamsForTests params(
starter, starter.GetStartSegment(), starter.GetFinishSegment(), nullptr /* prevRoute */,
[&](RouteWeight const & weight) { return starter.CheckLength(weight); });
@@ -402,7 +428,7 @@ CalculateRoute(IndexGraphStarter & starter, vector<Segment> & roadPoints,
}
void TestRouteGeometry(IndexGraphStarter & starter,
- AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result expectedRouteResult,
+ AlgorithmForWorldGraph::Result expectedRouteResult,
vector<m2::PointD> const & expectedRouteGeom)
{
vector<Segment> routeSegs;
@@ -411,7 +437,7 @@ void TestRouteGeometry(IndexGraphStarter & starter,
TEST_EQUAL(resultCode, expectedRouteResult, ());
- if (AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result::NoPath == expectedRouteResult &&
+ if (AlgorithmForWorldGraph::Result::NoPath == expectedRouteResult &&
expectedRouteGeom.empty())
{
// The route goes through a restriction. So there's no choice for building route
@@ -419,7 +445,7 @@ void TestRouteGeometry(IndexGraphStarter & starter,
return;
}
- if (resultCode != AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result::OK)
+ if (resultCode != AlgorithmForWorldGraph::Result::OK)
return;
CHECK(!routeSegs.empty(), ());
@@ -449,7 +475,7 @@ void TestRouteGeometry(IndexGraphStarter & starter,
}
void TestRestrictions(vector<m2::PointD> const & expectedRouteGeom,
- AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result expectedRouteResult,
+ AlgorithmForWorldGraph::Result expectedRouteResult,
FakeEnding const & start, FakeEnding const & finish,
RestrictionVec && restrictions, RestrictionTest & restrictionTest)
{
diff --git a/routing/routing_tests/index_graph_tools.hpp b/routing/routing_tests/index_graph_tools.hpp
index ec82c117ff..b5a99a0c99 100644
--- a/routing/routing_tests/index_graph_tools.hpp
+++ b/routing/routing_tests/index_graph_tools.hpp
@@ -44,36 +44,6 @@ using namespace routing;
// It just a noticeable value to detect the source of such id while debuging unit tests.
NumMwmId constexpr kTestNumMwmId = 777;
-class WorldGraphForAStar : public AStarGraph<Segment, SegmentEdge, RouteWeight>
-{
-public:
- using Vertex = AStarGraph::Vertex;
- using Edge = AStarGraph::Edge;
- using Weight = AStarGraph::Weight;
-
- explicit WorldGraphForAStar(WorldGraph & graph) : m_graph(graph) {}
-
- Weight HeuristicCostEstimate(Vertex const & from, Vertex const & to) override
- {
- return m_graph.HeuristicCostEstimate(from, to);
- }
-
- void GetOutgoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
- {
- m_graph.GetOutgoingEdgesList(v, edges);
- }
-
- void GetIngoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
- {
- m_graph.GetIngoingEdgesList(v, edges);
- }
-
- ~WorldGraphForAStar() override = default;
-
-private:
- WorldGraph & m_graph;
-};
-
struct RestrictionTest
{
RestrictionTest() { classificator::Load(); }
diff --git a/routing/routing_tests/routing_algorithm.cpp b/routing/routing_tests/routing_algorithm.cpp
index f5d385318a..53a8e7c547 100644
--- a/routing/routing_tests/routing_algorithm.cpp
+++ b/routing/routing_tests/routing_algorithm.cpp
@@ -2,6 +2,7 @@
#include "routing/base/astar_algorithm.hpp"
#include "routing/base/astar_graph.hpp"
+
#include "routing/maxspeeds.hpp"
#include "routing/routing_helpers.hpp"
@@ -48,12 +49,9 @@ private:
using Algorithm = AStarAlgorithm<Junction, WeightedEdge, double>;
/// A wrapper around IRoadGraph, which makes it possible to use IRoadGraph with astar algorithms.
-class RoadGraph : public AStarGraph<Junction, WeightedEdge, double>
+class RoadGraph : public Algorithm::Graph
{
public:
- using Vertex = AStarGraph::Vertex;
- using Edge = AStarGraph::Edge;
- using Weight = AStarGraph::Weight;
explicit RoadGraph(IRoadGraph const & roadGraph)
: m_roadGraph(roadGraph), m_maxSpeedMPS(KMPH2MPS(roadGraph.GetMaxSpeedKMpH()))
@@ -143,7 +141,7 @@ TestAStarBidirectionalAlgo::Result TestAStarBidirectionalAlgo::CalculateRoute(
RoadGraph roadGraph(graph);
base::Cancellable const cancellable;
Algorithm::Params params(roadGraph, startPos, finalPos, {} /* prevRoute */,
- cancellable, {} /* onVisitJunctionFn */, {} /* checkLength */);
+ cancellable, {} /* onVisitJunctionFn */, {} /* checkLength */);
Algorithm::Result const res = Algorithm().FindPathBidirectional(params, path);
return Convert(res);
}