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:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2018-03-27 14:14:03 +0300
committerTatiana Yan <tatiana.kondakova@gmail.com>2018-03-27 15:41:12 +0300
commitd9d795a2e781360ef4f1c9917eefb20fde9abe8c (patch)
treef9a1d38b899ea4bb4c5c7370528ebd3bfd87d8a6 /routing
parent310e1416ef68fe610ffdec4d03d692a4878a7069 (diff)
Removing unnecessary routing algorithm lines.
Diffstat (limited to 'routing')
-rw-r--r--routing/routing_tests/astar_router_test.cpp36
-rw-r--r--routing/routing_tests/routing_algorithm.cpp71
-rw-r--r--routing/routing_tests/routing_algorithm.hpp23
3 files changed, 31 insertions, 99 deletions
diff --git a/routing/routing_tests/astar_router_test.cpp b/routing/routing_tests/astar_router_test.cpp
index 3584aefa32..585226df40 100644
--- a/routing/routing_tests/astar_router_test.cpp
+++ b/routing/routing_tests/astar_router_test.cpp
@@ -5,16 +5,22 @@
#include "routing/features_road_graph.hpp"
#include "routing/route.hpp"
+#include "routing/road_graph.hpp"
#include "routing/router_delegate.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/feature_altitude.hpp"
+#include "geometry/point2d.hpp"
+
#include "base/logging.hpp"
#include "base/macros.hpp"
+#include <vector>
+
using namespace routing;
using namespace routing_test;
+using namespace std;
namespace
{
@@ -29,11 +35,10 @@ void TestAStarRouterMock(Junction const & startPos, Junction const & finalPos,
RoadGraphMockSource graph;
InitRoadGraphMockSourceWithTest2(graph);
- RouterDelegate delegate;
RoutingResult<Junction, double /* Weight */> result;
TRoutingAlgorithm algorithm;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
TEST_EQUAL(expected, result.m_path, ());
}
@@ -97,11 +102,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_RouteIsFound)
MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, 30)),
MakeJunctionForTesting(m2::PointD(0, 60)), MakeJunctionForTesting(m2::PointD(40, 100))};
- RouterDelegate delegate;
RoutingResult<Junction, double /* Weight */> result;
TRoutingAlgorithm algorithm;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
TEST_EQUAL(expected, result.m_path, ());
}
@@ -165,13 +169,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
Junction const startPos = roadInfo_1[i].m_junctions[0];
for (size_t j = 0; j < roadInfo_2.size(); ++j)
{
- RouterDelegate delegate;
Junction const finalPos = roadInfo_2[j].m_junctions[0];
RoutingResult<Junction, double /* Weight */> result;
TEST_EQUAL(TRoutingAlgorithm::Result::NoPath,
- algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
TEST_EQUAL(TRoutingAlgorithm::Result::NoPath,
- algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, finalPos, startPos, result), ());
}
}
@@ -181,13 +184,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
Junction const startPos = roadInfo_1[i].m_junctions[0];
for (size_t j = i + 1; j < roadInfo_1.size(); ++j)
{
- RouterDelegate delegate;
Junction const finalPos = roadInfo_1[j].m_junctions[0];
RoutingResult<Junction, double /* Weight */> result;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, finalPos, startPos, result), ());
}
}
@@ -197,13 +199,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
Junction const startPos = roadInfo_2[i].m_junctions[0];
for (size_t j = i + 1; j < roadInfo_2.size(); ++j)
{
- RouterDelegate delegate;
Junction const finalPos = roadInfo_2[j].m_junctions[0];
RoutingResult<Junction, double /* Weight */> result;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
- algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
+ algorithm.CalculateRoute(graph, finalPos, startPos, result), ());
}
}
}
@@ -226,12 +227,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1)
// path2 = 8/3 = 2.666(6)
// path3 = 1/5 + 8/4 + 1/5 = 2.4
- RouterDelegate delegate;
RoutingResult<Junction, double /* Weight */> result;
TRoutingAlgorithm algorithm;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)),
- MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result),
+ MakeJunctionForTesting(m2::PointD(10, 2)), result),
());
TEST_EQUAL(
result.m_path,
@@ -261,12 +261,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2)
// path2 = 8/4.1 = 1.95
// path3 = 1/5 + 8/4.4 + 1/5 = 2.2
- RouterDelegate delegate;
RoutingResult<Junction, double /* Weight */> result;
TRoutingAlgorithm algorithm;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)),
- MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result),
+ MakeJunctionForTesting(m2::PointD(10, 2)), result),
());
TEST_EQUAL(result.m_path,
vector<Junction>({MakeJunctionForTesting(m2::PointD(2, 2)),
@@ -293,12 +292,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3)
// path2 = 8/3.9 = 2.05
// path3 = 1/5 + 8/4.9 + 1/5 = 2.03
- RouterDelegate delegate;
RoutingResult<Junction, double /* Weight */> result;
TRoutingAlgorithm algorithm;
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)),
- MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result),
+ MakeJunctionForTesting(m2::PointD(10, 2)), result),
());
TEST_EQUAL(
result.m_path,
diff --git a/routing/routing_tests/routing_algorithm.cpp b/routing/routing_tests/routing_algorithm.cpp
index f7821d899a..b6b04efec4 100644
--- a/routing/routing_tests/routing_algorithm.cpp
+++ b/routing/routing_tests/routing_algorithm.cpp
@@ -1,21 +1,21 @@
#include "routing/routing_tests/routing_algorithm.hpp"
#include "routing/base/astar_algorithm.hpp"
-#include "routing/base/astar_progress.hpp"
-#include "routing/road_graph.hpp"
+
+#include "geometry/mercator.hpp"
#include "base/assert.hpp"
-#include "geometry/mercator.hpp"
+#include <cmath>
+#include <cstdint>
+#include <vector>
namespace routing
{
+using namespace std;
namespace
{
-uint32_t constexpr kVisitPeriod = 4;
-float constexpr kProgressInterval = 2;
-
double constexpr KMPH2MPS = 1000.0 / (60 * 60);
inline double TimeBetweenSec(Junction const & j1, Junction const & j2, double speedMPS)
@@ -37,7 +37,6 @@ public:
WeightedEdge(Junction const & target, double weight) : target(target), weight(weight) {}
inline Junction const & GetTarget() const { return target; }
-
inline double GetWeight() const { return weight; }
private:
@@ -128,69 +127,19 @@ string DebugPrint(IRoutingAlgorithm::Result const & value)
case IRoutingAlgorithm::Result::Cancelled:
return "Cancelled";
}
+ ASSERT(false, ("Unexpected TAlgorithmImpl::Result value:", value));
return string();
}
-// *************************** AStar routing algorithm implementation *************************************
-
-IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const & graph,
- Junction const & startPos,
- Junction const & finalPos,
- RouterDelegate const & delegate,
- RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path)
-{
- AStarProgress progress(0, 95);
- uint32_t visitCount = 0;
-
- auto onVisitJunctionFn = [&](Junction const & junction, Junction const & /* target */) {
- if (++visitCount % kVisitPeriod != 0)
- return;
-
- delegate.OnPointCheck(junction.GetPoint());
- auto const lastValue = progress.GetLastValue();
- auto const newValue = progress.GetProgressForDirectedAlgo(junction.GetPoint());
- if (newValue - lastValue > kProgressInterval)
- delegate.OnProgress(newValue);
-
- };
-
- base::Cancellable const & cancellable = delegate;
- progress.Initialize(startPos.GetPoint(), finalPos.GetPoint());
- RoadGraph roadGraph(graph);
- TAlgorithmImpl::Params params(roadGraph, startPos, finalPos, nullptr /* prevRoute */, cancellable,
- onVisitJunctionFn, {} /* checkLength */);
- TAlgorithmImpl::Result const res = TAlgorithmImpl().FindPath(params, path);
- return Convert(res);
-}
-
// *************************** AStar-bidirectional routing algorithm implementation ***********************
-
IRoutingAlgorithm::Result AStarBidirectionalRoutingAlgorithm::CalculateRoute(
IRoadGraph const & graph, Junction const & startPos, Junction const & finalPos,
- RouterDelegate const & delegate, RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path)
+ RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path)
{
- AStarProgress progress(0, 95);
- uint32_t visitCount = 0;
-
- auto onVisitJunctionFn = [&](Junction const & junction, Junction const & target) {
- if (++visitCount % kVisitPeriod != 0)
- return;
-
- delegate.OnPointCheck(junction.GetPoint());
- auto const lastValue = progress.GetLastValue();
- auto const newValue =
- progress.GetProgressForBidirectedAlgo(junction.GetPoint(), target.GetPoint());
- if (newValue - lastValue > kProgressInterval)
- delegate.OnProgress(newValue);
- };
-
- base::Cancellable const & cancellable = delegate;
- progress.Initialize(startPos.GetPoint(), finalPos.GetPoint());
RoadGraph roadGraph(graph);
- TAlgorithmImpl::Params params(roadGraph, startPos, finalPos, {} /* prevRoute */, cancellable,
- onVisitJunctionFn, {} /* checkLength */);
+ TAlgorithmImpl::Params params(roadGraph, startPos, finalPos, {} /* prevRoute */,
+ {} /* cancellable */, {} /* onVisitJunctionFn */, {} /* checkLength */);
TAlgorithmImpl::Result const res = TAlgorithmImpl().FindPathBidirectional(params, path);
return Convert(res);
}
-
} // namespace routing
diff --git a/routing/routing_tests/routing_algorithm.hpp b/routing/routing_tests/routing_algorithm.hpp
index e1eb72467b..124a248746 100644
--- a/routing/routing_tests/routing_algorithm.hpp
+++ b/routing/routing_tests/routing_algorithm.hpp
@@ -4,11 +4,7 @@
#include "routing/road_graph.hpp"
#include "routing/router.hpp"
-#include "base/cancellable.hpp"
-
-#include "std/functional.hpp"
-#include "std/string.hpp"
-#include "std/vector.hpp"
+#include <string>
namespace routing
{
@@ -26,21 +22,11 @@ public:
};
virtual Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
- Junction const & finalPos, RouterDelegate const & delegate,
+ Junction const & finalPos,
RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path) = 0;
};
-string DebugPrint(IRoutingAlgorithm::Result const & result);
-
-// AStar routing algorithm implementation
-class AStarRoutingAlgorithm : public IRoutingAlgorithm
-{
-public:
- // IRoutingAlgorithm overrides:
- Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
- Junction const & finalPos, RouterDelegate const & delegate,
- RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path) override;
-};
+std::string DebugPrint(IRoutingAlgorithm::Result const & result);
// AStar-bidirectional routing algorithm implementation
class AStarBidirectionalRoutingAlgorithm : public IRoutingAlgorithm
@@ -48,8 +34,7 @@ class AStarBidirectionalRoutingAlgorithm : public IRoutingAlgorithm
public:
// IRoutingAlgorithm overrides:
Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
- Junction const & finalPos, RouterDelegate const & delegate,
+ Junction const & finalPos,
RoutingResult<IRoadGraph::Vertex, IRoadGraph::Weight> & path) override;
};
-
} // namespace routing