mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#include "routing/routing_tests/routing_algorithm.hpp"
|
||||
|
||||
#include "routing/features_road_graph.hpp"
|
||||
#include "routing/route.hpp"
|
||||
#include "routing/road_graph.hpp"
|
||||
#include "routing/route.hpp"
|
||||
#include "routing/router_delegate.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
@@ -25,8 +25,7 @@ using namespace routing;
|
||||
using namespace routing_test;
|
||||
using namespace std;
|
||||
|
||||
void TestAStarRouterMock(geometry::PointWithAltitude const & startPos,
|
||||
geometry::PointWithAltitude const & finalPos,
|
||||
void TestAStarRouterMock(geometry::PointWithAltitude const & startPos, geometry::PointWithAltitude const & finalPos,
|
||||
vector<geometry::PointWithAltitude> const & expected)
|
||||
{
|
||||
classificator::Load();
|
||||
@@ -36,8 +35,7 @@ void TestAStarRouterMock(geometry::PointWithAltitude const & startPos,
|
||||
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TestAStarBidirectionalAlgo algorithm;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
|
||||
TEST_EQUAL(expected, result.m_path, ());
|
||||
}
|
||||
@@ -55,37 +53,31 @@ void AddRoad(RoadGraphMockSource & graph, initializer_list<m2::PointD> const & p
|
||||
|
||||
UNIT_TEST(AStarRouter_Graph2_Simple1)
|
||||
{
|
||||
geometry::PointWithAltitude const startPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0));
|
||||
geometry::PointWithAltitude const finalPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55));
|
||||
geometry::PointWithAltitude const startPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0));
|
||||
geometry::PointWithAltitude const finalPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55));
|
||||
|
||||
vector<geometry::PointWithAltitude> const expected = {
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(5, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(5, 40)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(18, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(39, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55))};
|
||||
vector<geometry::PointWithAltitude> const expected = {geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(5, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(5, 40)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(18, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(39, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55))};
|
||||
|
||||
TestAStarRouterMock(startPos, finalPos, expected);
|
||||
}
|
||||
|
||||
UNIT_TEST(AStarRouter_Graph2_Simple2)
|
||||
{
|
||||
geometry::PointWithAltitude const startPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55));
|
||||
geometry::PointWithAltitude const finalPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 0));
|
||||
geometry::PointWithAltitude const startPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55));
|
||||
geometry::PointWithAltitude const finalPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 0));
|
||||
|
||||
vector<geometry::PointWithAltitude> const expected = {
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(39, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(37, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 0))};
|
||||
vector<geometry::PointWithAltitude> const expected = {geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(39, 55)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(37, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(80, 0))};
|
||||
|
||||
TestAStarRouterMock(startPos, finalPos, expected);
|
||||
}
|
||||
@@ -95,28 +87,24 @@ UNIT_TEST(AStarRouter_SimpleGraph_RouteIsFound)
|
||||
classificator::Load();
|
||||
|
||||
RoadGraphMockSource graph;
|
||||
AddRoad(graph, {m2::PointD(0, 0), m2::PointD(40, 0)}); // feature 0
|
||||
AddRoad(graph, {m2::PointD(40, 0), m2::PointD(40, 30)}); // feature 1
|
||||
AddRoad(graph, {m2::PointD(40, 30), m2::PointD(40, 100)}); // feature 2
|
||||
AddRoad(graph, {m2::PointD(40, 100), m2::PointD(0, 60)}); // feature 3
|
||||
AddRoad(graph, {m2::PointD(0, 60), m2::PointD(0, 30)}); // feature 4
|
||||
AddRoad(graph, {m2::PointD(0, 30), m2::PointD(0, 0)}); // feature 5
|
||||
AddRoad(graph, {m2::PointD(0, 0), m2::PointD(40, 0)}); // feature 0
|
||||
AddRoad(graph, {m2::PointD(40, 0), m2::PointD(40, 30)}); // feature 1
|
||||
AddRoad(graph, {m2::PointD(40, 30), m2::PointD(40, 100)}); // feature 2
|
||||
AddRoad(graph, {m2::PointD(40, 100), m2::PointD(0, 60)}); // feature 3
|
||||
AddRoad(graph, {m2::PointD(0, 60), m2::PointD(0, 30)}); // feature 4
|
||||
AddRoad(graph, {m2::PointD(0, 30), m2::PointD(0, 0)}); // feature 5
|
||||
|
||||
geometry::PointWithAltitude const startPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0));
|
||||
geometry::PointWithAltitude const finalPos =
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(40, 100));
|
||||
geometry::PointWithAltitude const startPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0));
|
||||
geometry::PointWithAltitude const finalPos = geometry::MakePointWithAltitudeForTesting(m2::PointD(40, 100));
|
||||
|
||||
vector<geometry::PointWithAltitude> const expected = {
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 60)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(40, 100))};
|
||||
vector<geometry::PointWithAltitude> const expected = {geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 0)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(0, 60)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(40, 100))};
|
||||
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TestAStarBidirectionalAlgo algorithm;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
|
||||
TEST_EQUAL(expected, result.m_path, ());
|
||||
}
|
||||
@@ -131,42 +119,34 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
||||
|
||||
// Roads in the first connected component.
|
||||
vector<IRoadGraph::RoadInfo> const roadInfo_1 = {
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 10))}), // feature 0
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 90))}), // feature 1
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 90)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 90))}), // feature 2
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 90)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 10))}), // feature 3
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 10))}), // feature 0
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 10)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 90))}), // feature 1
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(90, 90)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 90))}), // feature 2
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 90)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 10))}), // feature 3
|
||||
};
|
||||
|
||||
// Roads in the second connected component.
|
||||
vector<IRoadGraph::RoadInfo> const roadInfo_2 = {
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30))}), // feature 4
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 70))}), // feature 5
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 70)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 70))}), // feature 6
|
||||
IRoadGraph::RoadInfo(
|
||||
true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 70)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 30))}), // feature 7
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30))}), // feature 4
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 30)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 70))}), // feature 5
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(70, 70)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 70))}), // feature 6
|
||||
IRoadGraph::RoadInfo(true /* bidir */, speedKMpH,
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 70)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(30, 30))}), // feature 7
|
||||
};
|
||||
|
||||
for (auto const & ri : roadInfo_1)
|
||||
@@ -203,10 +183,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
||||
{
|
||||
geometry::PointWithAltitude const finalPos = roadInfo_1[j].m_junctions[0];
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, startPos, finalPos, result),
|
||||
());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, finalPos, startPos, result),
|
||||
());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +198,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
||||
{
|
||||
geometry::PointWithAltitude const finalPos = roadInfo_2[j].m_junctions[0];
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, result), ());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, startPos, finalPos, result),
|
||||
());
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK, algorithm.CalculateRoute(graph, finalPos, startPos, result),
|
||||
());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,13 +212,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1)
|
||||
|
||||
RoadGraphMockSource graph;
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2,1), m2::PointD(2,2), m2::PointD(2,3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10,1), m2::PointD(10,2), m2::PointD(10,3)});
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2,3), m2::PointD(4,3), m2::PointD(6,3), m2::PointD(8,3), m2::PointD(10,3)});
|
||||
AddRoad(graph, 3.0, {m2::PointD(2,2), m2::PointD(6,2), m2::PointD(10,2)});
|
||||
AddRoad(graph, 4.0, {m2::PointD(2,1), m2::PointD(10,1)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(2, 1), m2::PointD(2, 2), m2::PointD(2, 3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10, 1), m2::PointD(10, 2), m2::PointD(10, 3)});
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2, 3), m2::PointD(4, 3), m2::PointD(6, 3), m2::PointD(8, 3), m2::PointD(10, 3)});
|
||||
AddRoad(graph, 3.0, {m2::PointD(2, 2), m2::PointD(6, 2), m2::PointD(10, 2)});
|
||||
AddRoad(graph, 4.0, {m2::PointD(2, 1), m2::PointD(10, 1)});
|
||||
|
||||
// path1 = 1/5 + 8/5 + 1/5 = 2
|
||||
// path2 = 8/3 = 2.666(6)
|
||||
@@ -247,19 +226,17 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1)
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TestAStarBidirectionalAlgo algorithm;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(
|
||||
graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
algorithm.CalculateRoute(graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
());
|
||||
TEST_EQUAL(result.m_path,
|
||||
vector<geometry::PointWithAltitude>(
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(4, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(6, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(8, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
vector<geometry::PointWithAltitude>({geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(4, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(6, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(8, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 3)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
());
|
||||
TEST(AlmostEqualAbs(result.m_distance, 800451., 1.), ("Distance error:", result.m_distance));
|
||||
}
|
||||
@@ -270,12 +247,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2)
|
||||
|
||||
RoadGraphMockSource graph;
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2,1), m2::PointD(2,2), m2::PointD(2,3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10,1), m2::PointD(10,2), m2::PointD(10,3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(2, 1), m2::PointD(2, 2), m2::PointD(2, 3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10, 1), m2::PointD(10, 2), m2::PointD(10, 3)});
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2,3), m2::PointD(4,3), m2::PointD(6,3), m2::PointD(8,3), m2::PointD(10,3)});
|
||||
AddRoad(graph, 4.1, {m2::PointD(2,2), m2::PointD(6,2), m2::PointD(10,2)});
|
||||
AddRoad(graph, 4.4, {m2::PointD(2,1), m2::PointD(10,1)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(2, 3), m2::PointD(4, 3), m2::PointD(6, 3), m2::PointD(8, 3), m2::PointD(10, 3)});
|
||||
AddRoad(graph, 4.1, {m2::PointD(2, 2), m2::PointD(6, 2), m2::PointD(10, 2)});
|
||||
AddRoad(graph, 4.4, {m2::PointD(2, 1), m2::PointD(10, 1)});
|
||||
|
||||
// path1 = 1/5 + 8/5 + 1/5 = 2
|
||||
// path2 = 8/4.1 = 1.95
|
||||
@@ -284,15 +261,13 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2)
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TestAStarBidirectionalAlgo algorithm;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(
|
||||
graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
algorithm.CalculateRoute(graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
());
|
||||
TEST_EQUAL(result.m_path,
|
||||
vector<geometry::PointWithAltitude>(
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(6, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
vector<geometry::PointWithAltitude>({geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(6, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
());
|
||||
TEST(AlmostEqualAbs(result.m_distance, 781458., 1.), ("Distance error:", result.m_distance));
|
||||
}
|
||||
@@ -303,12 +278,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3)
|
||||
|
||||
RoadGraphMockSource graph;
|
||||
|
||||
AddRoad(graph, 5.0, {m2::PointD(2,1), m2::PointD(2,2), m2::PointD(2,3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10,1), m2::PointD(10,2), m2::PointD(10,3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(2, 1), m2::PointD(2, 2), m2::PointD(2, 3)});
|
||||
AddRoad(graph, 5.0, {m2::PointD(10, 1), m2::PointD(10, 2), m2::PointD(10, 3)});
|
||||
|
||||
AddRoad(graph, 4.8, {m2::PointD(2,3), m2::PointD(4,3), m2::PointD(6,3), m2::PointD(8,3), m2::PointD(10,3)});
|
||||
AddRoad(graph, 3.9, {m2::PointD(2,2), m2::PointD(6,2), m2::PointD(10,2)});
|
||||
AddRoad(graph, 4.9, {m2::PointD(2,1), m2::PointD(10,1)});
|
||||
AddRoad(graph, 4.8, {m2::PointD(2, 3), m2::PointD(4, 3), m2::PointD(6, 3), m2::PointD(8, 3), m2::PointD(10, 3)});
|
||||
AddRoad(graph, 3.9, {m2::PointD(2, 2), m2::PointD(6, 2), m2::PointD(10, 2)});
|
||||
AddRoad(graph, 4.9, {m2::PointD(2, 1), m2::PointD(10, 1)});
|
||||
|
||||
// path1 = 1/5 + 8/4.8 + 1/5 = 2.04
|
||||
// path2 = 8/3.9 = 2.05
|
||||
@@ -317,17 +292,15 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3)
|
||||
RoutingResult<geometry::PointWithAltitude, double /* Weight */> result;
|
||||
TestAStarBidirectionalAlgo algorithm;
|
||||
TEST_EQUAL(TestAStarBidirectionalAlgo::Result::OK,
|
||||
algorithm.CalculateRoute(
|
||||
graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
algorithm.CalculateRoute(graph, geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2)), result),
|
||||
());
|
||||
TEST_EQUAL(result.m_path,
|
||||
vector<geometry::PointWithAltitude>(
|
||||
{geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 1)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 1)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
vector<geometry::PointWithAltitude>({geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 2)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(2, 1)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 1)),
|
||||
geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}),
|
||||
());
|
||||
TEST(AlmostEqualAbs(result.m_distance, 814412., 1.), ("Distance error:", result.m_distance));
|
||||
}
|
||||
} // namespace astar_router_test
|
||||
} // namespace astar_router_test
|
||||
|
||||
Reference in New Issue
Block a user