mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +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:
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "routing/routing_tests/tools.hpp"
|
||||
|
||||
#include "routing/car_directions.hpp"
|
||||
#include "routing/loaded_path_segment.hpp"
|
||||
#include "routing/route.hpp"
|
||||
#include "routing/routing_result_graph.hpp"
|
||||
#include "routing/turns.hpp"
|
||||
#include "routing/turns_generator_utils.hpp"
|
||||
#include "routing/turns_generator.hpp"
|
||||
#include "routing/car_directions.hpp"
|
||||
#include "routing/turns_generator_utils.hpp"
|
||||
|
||||
#include "indexer/ftypes_matcher.hpp"
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
|
||||
TUnpackedPathSegments const & GetSegments() const override { return m_segments; }
|
||||
|
||||
void GetPossibleTurns(SegmentRange const & segmentRange, m2::PointD const & junctionPoint,
|
||||
size_t & ingoingCount, TurnCandidates & outgoingTurns) const override
|
||||
void GetPossibleTurns(SegmentRange const & segmentRange, m2::PointD const & junctionPoint, size_t & ingoingCount,
|
||||
TurnCandidates & outgoingTurns) const override
|
||||
{
|
||||
outgoingTurns.candidates.emplace_back(0.0, Segment(), ftypes::HighwayClass::Tertiary, false);
|
||||
outgoingTurns.isCandidatesAngleValid = false;
|
||||
@@ -126,10 +126,8 @@ UNIT_TEST(TestParseLanes)
|
||||
{
|
||||
vector<SingleLaneInfo> result;
|
||||
TEST(ParseLanes("through|through|through|through;right", result), ());
|
||||
vector<SingleLaneInfo> const expected1 = {{LaneWay::Through},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through, LaneWay::Right}};
|
||||
vector<SingleLaneInfo> const expected1 = {
|
||||
{LaneWay::Through}, {LaneWay::Through}, {LaneWay::Through}, {LaneWay::Through, LaneWay::Right}};
|
||||
TEST_EQUAL(result, expected1, ());
|
||||
|
||||
TEST(ParseLanes("left|left;through|through|through", result), ());
|
||||
@@ -138,8 +136,7 @@ UNIT_TEST(TestParseLanes)
|
||||
TEST_EQUAL(result, expected2, ());
|
||||
|
||||
TEST(ParseLanes("left|through|through", result), ());
|
||||
vector<SingleLaneInfo> const expected3 = {
|
||||
{LaneWay::Left}, {LaneWay::Through}, {LaneWay::Through}};
|
||||
vector<SingleLaneInfo> const expected3 = {{LaneWay::Left}, {LaneWay::Through}, {LaneWay::Through}};
|
||||
TEST_EQUAL(result, expected3, ());
|
||||
|
||||
TEST(ParseLanes("left|le ft| through|through | right", result), ());
|
||||
@@ -153,12 +150,11 @@ UNIT_TEST(TestParseLanes)
|
||||
TEST_EQUAL(result, expected5, ());
|
||||
|
||||
TEST(ParseLanes("left|Left|through|througH|through;right;sharp_rIght", result), ());
|
||||
vector<SingleLaneInfo> const expected6 = {
|
||||
{LaneWay::Left},
|
||||
{LaneWay::Left},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through, LaneWay::Right, LaneWay::SharpRight}};
|
||||
vector<SingleLaneInfo> const expected6 = {{LaneWay::Left},
|
||||
{LaneWay::Left},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through},
|
||||
{LaneWay::Through, LaneWay::Right, LaneWay::SharpRight}};
|
||||
TEST_EQUAL(result, expected6, ());
|
||||
|
||||
TEST(!ParseLanes("left|Leftt|through|througH|right", result), ());
|
||||
@@ -176,14 +172,8 @@ UNIT_TEST(TestParseLanes)
|
||||
TEST_EQUAL(result, expected7, ());
|
||||
|
||||
TEST(ParseLanes("|||||slight_right", result), ());
|
||||
vector<SingleLaneInfo> const expected8 = {
|
||||
{LaneWay::None},
|
||||
{LaneWay::None},
|
||||
{LaneWay::None},
|
||||
{LaneWay::None},
|
||||
{LaneWay::None},
|
||||
{LaneWay::SlightRight}
|
||||
};
|
||||
vector<SingleLaneInfo> const expected8 = {{LaneWay::None}, {LaneWay::None}, {LaneWay::None},
|
||||
{LaneWay::None}, {LaneWay::None}, {LaneWay::SlightRight}};
|
||||
TEST_EQUAL(result, expected8, ());
|
||||
}
|
||||
|
||||
@@ -195,46 +185,36 @@ UNIT_TEST(TestFixupTurns)
|
||||
mercator::MetersToXY(kSquareCenterLonLat.x, kSquareCenterLonLat.y, kHalfSquareSideMeters);
|
||||
{
|
||||
// Removing a turn in case staying on a roundabout.
|
||||
vector<m2::PointD> const pointsMerc1 =
|
||||
{{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.maxY()},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.minY()}};
|
||||
vector<m2::PointD> const pointsMerc1 = {{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.maxY()},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.minY()}};
|
||||
// The constructor TurnItem(uint32_t idx, CarDirection t, uint32_t exitNum = 0)
|
||||
// is used for initialization of vector<TurnItem> below.
|
||||
vector<turns::TurnItem> turnsDir1 =
|
||||
{{1, CarDirection::EnterRoundAbout},
|
||||
{2, CarDirection::StayOnRoundAbout},
|
||||
{3, CarDirection::LeaveRoundAbout}};
|
||||
vector<turns::TurnItem> turnsDir1 = {
|
||||
{1, CarDirection::EnterRoundAbout}, {2, CarDirection::StayOnRoundAbout}, {3, CarDirection::LeaveRoundAbout}};
|
||||
vector<RouteSegment> routeSegments;
|
||||
RouteSegmentsFrom({}, pointsMerc1, turnsDir1, {}, routeSegments);
|
||||
FixupCarTurns(routeSegments);
|
||||
vector<turns::TurnItem> const expectedTurnDir1 =
|
||||
{{1, CarDirection::EnterRoundAbout, 2},
|
||||
{2, CarDirection::None, 0},
|
||||
{3, CarDirection::LeaveRoundAbout, 2}};
|
||||
vector<turns::TurnItem> const expectedTurnDir1 = {
|
||||
{1, CarDirection::EnterRoundAbout, 2}, {2, CarDirection::None, 0}, {3, CarDirection::LeaveRoundAbout, 2}};
|
||||
TEST_EQUAL(routeSegments[0].GetTurn(), expectedTurnDir1[0], ());
|
||||
TEST_EQUAL(routeSegments[1].GetTurn(), expectedTurnDir1[1], ());
|
||||
TEST_EQUAL(routeSegments[2].GetTurn(), expectedTurnDir1[2], ());
|
||||
}
|
||||
{
|
||||
// Merging turns which are close to each other.
|
||||
vector<m2::PointD> const pointsMerc2 =
|
||||
{{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareCenterLonLat.x, kSquareCenterLonLat.y},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.maxY()}};
|
||||
vector<turns::TurnItem> turnsDir2 =
|
||||
{{1, CarDirection::None},
|
||||
{2, CarDirection::GoStraight},
|
||||
{3, CarDirection::TurnLeft}};
|
||||
vector<m2::PointD> const pointsMerc2 = {{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareNearZero.minX(), kSquareNearZero.minY()},
|
||||
{kSquareCenterLonLat.x, kSquareCenterLonLat.y},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.maxY()}};
|
||||
vector<turns::TurnItem> turnsDir2 = {
|
||||
{1, CarDirection::None}, {2, CarDirection::GoStraight}, {3, CarDirection::TurnLeft}};
|
||||
vector<RouteSegment> routeSegments2;
|
||||
RouteSegmentsFrom({}, pointsMerc2, turnsDir2, {}, routeSegments2);
|
||||
FixupCarTurns(routeSegments2);
|
||||
vector<turns::TurnItem> const expectedTurnDir2 =
|
||||
{{1, CarDirection::None},
|
||||
{2, CarDirection::None},
|
||||
{3, CarDirection::TurnLeft}};
|
||||
vector<turns::TurnItem> const expectedTurnDir2 = {
|
||||
{1, CarDirection::None}, {2, CarDirection::None}, {3, CarDirection::TurnLeft}};
|
||||
TEST_EQUAL(routeSegments2[0].GetTurn(), expectedTurnDir2[0], ());
|
||||
TEST_EQUAL(routeSegments2[1].GetTurn(), expectedTurnDir2[1], ());
|
||||
TEST_EQUAL(routeSegments2[2].GetTurn(), expectedTurnDir2[2], ());
|
||||
@@ -246,14 +226,12 @@ UNIT_TEST(TestFixupTurns)
|
||||
{kSquareNearZero.minX(), kSquareNearZero.maxY()},
|
||||
{kSquareNearZero.maxX(), kSquareNearZero.maxY()},
|
||||
};
|
||||
vector<turns::TurnItem> turnsDir3 = {{1, CarDirection::None},
|
||||
{2, CarDirection::TurnRight}};
|
||||
vector<turns::TurnItem> turnsDir3 = {{1, CarDirection::None}, {2, CarDirection::TurnRight}};
|
||||
|
||||
vector<RouteSegment> routeSegments3;
|
||||
RouteSegmentsFrom({}, {}, turnsDir3, {}, routeSegments3);
|
||||
FixupCarTurns(routeSegments3);
|
||||
vector<turns::TurnItem> const expectedTurnDir3 = {{1, CarDirection::None},
|
||||
{2, CarDirection::TurnRight}};
|
||||
vector<turns::TurnItem> const expectedTurnDir3 = {{1, CarDirection::None}, {2, CarDirection::TurnRight}};
|
||||
|
||||
TEST_EQUAL(routeSegments3[0].GetTurn(), expectedTurnDir3[0], ());
|
||||
TEST_EQUAL(routeSegments3[1].GetTurn(), expectedTurnDir3[1], ());
|
||||
@@ -295,17 +273,15 @@ UNIT_TEST(TestIsLaneWayConformedTurnDirectionApproximately)
|
||||
TEST(!IsLaneWayConformedTurnDirectionApproximately(LaneWay::SharpRight, CarDirection::UTurnRight), ());
|
||||
TEST(!IsLaneWayConformedTurnDirection(LaneWay::Through, CarDirection::ReachedYourDestination), ());
|
||||
TEST(!IsLaneWayConformedTurnDirectionApproximately(LaneWay::Through, CarDirection::TurnRight), ());
|
||||
TEST(!IsLaneWayConformedTurnDirectionApproximately(LaneWay::SlightRight,
|
||||
CarDirection::TurnSharpLeft), ());
|
||||
TEST(!IsLaneWayConformedTurnDirectionApproximately(LaneWay::SlightRight, CarDirection::TurnSharpLeft), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(TestAddingActiveLaneInformation)
|
||||
{
|
||||
vector<turns::TurnItem> turns =
|
||||
{{1, CarDirection::GoStraight},
|
||||
{2, CarDirection::TurnLeft},
|
||||
{3, CarDirection::TurnRight},
|
||||
{4, CarDirection::ReachedYourDestination}};
|
||||
vector<turns::TurnItem> turns = {{1, CarDirection::GoStraight},
|
||||
{2, CarDirection::TurnLeft},
|
||||
{3, CarDirection::TurnRight},
|
||||
{4, CarDirection::ReachedYourDestination}};
|
||||
|
||||
turns[0].m_lanes.push_back({LaneWay::Left, LaneWay::Through});
|
||||
turns[0].m_lanes.push_back({LaneWay::Right});
|
||||
@@ -400,51 +376,41 @@ UNIT_TEST(TestCheckUTurnOnRoute)
|
||||
pathSegments[0].m_onRoundabout = false;
|
||||
pathSegments[0].m_isLink = false;
|
||||
pathSegments[0].m_path = {{{0, 0}, 0}, {{0, 1}, 0}};
|
||||
pathSegments[0].m_segmentRange = SegmentRange(FeatureID(), 0 /* start seg id */, 1 /* end seg id */,
|
||||
true /* forward */,
|
||||
pathSegments[0].m_path.front().GetPoint(),
|
||||
pathSegments[0].m_path.back().GetPoint());
|
||||
pathSegments[0].m_segmentRange =
|
||||
SegmentRange(FeatureID(), 0 /* start seg id */, 1 /* end seg id */, true /* forward */,
|
||||
pathSegments[0].m_path.front().GetPoint(), pathSegments[0].m_path.back().GetPoint());
|
||||
|
||||
pathSegments[1] = pathSegments[0];
|
||||
pathSegments[1].m_segmentRange = SegmentRange(FeatureID(), 1 /* start seg id */, 2 /* end seg id */,
|
||||
true /* forward */,
|
||||
pathSegments[1].m_path.front().GetPoint(),
|
||||
pathSegments[1].m_path.back().GetPoint());
|
||||
pathSegments[1].m_segmentRange =
|
||||
SegmentRange(FeatureID(), 1 /* start seg id */, 2 /* end seg id */, true /* forward */,
|
||||
pathSegments[1].m_path.front().GetPoint(), pathSegments[1].m_path.back().GetPoint());
|
||||
pathSegments[1].m_path = {{{0, 1}, 0}, {{0, 0}, 0}};
|
||||
|
||||
pathSegments[2] = pathSegments[0];
|
||||
pathSegments[2].m_segmentRange = SegmentRange(FeatureID(), 2 /* start seg id */, 3 /* end seg id */,
|
||||
true /* forward */,
|
||||
pathSegments[2].m_path.front().GetPoint(),
|
||||
pathSegments[2].m_path.back().GetPoint());
|
||||
pathSegments[2].m_segmentRange =
|
||||
SegmentRange(FeatureID(), 2 /* start seg id */, 3 /* end seg id */, true /* forward */,
|
||||
pathSegments[2].m_path.front().GetPoint(), pathSegments[2].m_path.back().GetPoint());
|
||||
pathSegments[2].m_path = {{{0, 0}, 0}, {{0, 1}, 0}};
|
||||
|
||||
pathSegments[3] = pathSegments[0];
|
||||
pathSegments[3].m_segmentRange = SegmentRange(FeatureID(), 3 /* start seg id */, 4 /* end seg id */,
|
||||
true /* forward */,
|
||||
pathSegments[3].m_path.front().GetPoint(),
|
||||
pathSegments[3].m_path.back().GetPoint());
|
||||
pathSegments[3].m_segmentRange =
|
||||
SegmentRange(FeatureID(), 3 /* start seg id */, 4 /* end seg id */, true /* forward */,
|
||||
pathSegments[3].m_path.front().GetPoint(), pathSegments[3].m_path.back().GetPoint());
|
||||
pathSegments[3].m_path.clear();
|
||||
|
||||
RoutingResultTest resultTest(pathSegments);
|
||||
RoutingSettings const vehicleSettings = GetRoutingSettings(VehicleType::Car);
|
||||
// Zigzag test.
|
||||
TurnItem turn1;
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 1 /* outgoingSegmentIndex */, NumMwmIds(),
|
||||
vehicleSettings, turn1),
|
||||
1, ());
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 1 /* outgoingSegmentIndex */, NumMwmIds(), vehicleSettings, turn1), 1, ());
|
||||
TEST_EQUAL(turn1.m_turn, CarDirection::UTurnLeft, ());
|
||||
TurnItem turn2;
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 2 /* outgoingSegmentIndex */, NumMwmIds(),
|
||||
vehicleSettings, turn2),
|
||||
1, ());
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 2 /* outgoingSegmentIndex */, NumMwmIds(), vehicleSettings, turn2), 1, ());
|
||||
TEST_EQUAL(turn2.m_turn, CarDirection::UTurnLeft, ());
|
||||
|
||||
// Empty path test.
|
||||
TurnItem turn3;
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 3 /* outgoingSegmentIndex */, NumMwmIds(),
|
||||
vehicleSettings, turn3),
|
||||
0, ());
|
||||
TEST_EQUAL(CheckUTurnOnRoute(resultTest, 3 /* outgoingSegmentIndex */, NumMwmIds(), vehicleSettings, turn3), 0, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GetNextRoutePointIndex)
|
||||
@@ -457,47 +423,47 @@ UNIT_TEST(GetNextRoutePointIndex)
|
||||
RoutePointIndex nextIndex;
|
||||
|
||||
// Forward direction.
|
||||
TEST(GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 0 /* m_pathIndex */}),
|
||||
NumMwmIds(), true /* forward */, nextIndex), ());
|
||||
TEST(GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 0 /* m_pathIndex */}), NumMwmIds(),
|
||||
true /* forward */, nextIndex),
|
||||
());
|
||||
TEST_EQUAL(nextIndex, RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}), ());
|
||||
|
||||
TEST(GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}),
|
||||
NumMwmIds(), true /* forward */, nextIndex), ());
|
||||
TEST(GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}), NumMwmIds(),
|
||||
true /* forward */, nextIndex),
|
||||
());
|
||||
TEST_EQUAL(nextIndex, RoutePointIndex({0 /* m_segmentIndex */, 2 /* m_pathIndex */}), ());
|
||||
|
||||
// Trying to get next item after the last item of the first segment.
|
||||
// False because of too sharp turn angle.
|
||||
TEST(!GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 2 /* m_pathIndex */}),
|
||||
NumMwmIds(), true /* forward */, nextIndex), ());
|
||||
TEST(!GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 2 /* m_pathIndex */}), NumMwmIds(),
|
||||
true /* forward */, nextIndex),
|
||||
());
|
||||
|
||||
// Trying to get point about the end of the route.
|
||||
TEST(!GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({1 /* m_segmentIndex */, 1 /* m_pathIndex */}),
|
||||
NumMwmIds(), true /* forward */, nextIndex), ());
|
||||
TEST(!GetNextRoutePointIndex(resultTest, RoutePointIndex({1 /* m_segmentIndex */, 1 /* m_pathIndex */}), NumMwmIds(),
|
||||
true /* forward */, nextIndex),
|
||||
());
|
||||
|
||||
// Backward direction.
|
||||
// Moving in backward direction it's possible to get index of the first item of a segment.
|
||||
TEST(GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({1 /* m_segmentIndex */, 1 /* m_pathIndex */}),
|
||||
NumMwmIds(), false /* forward */, nextIndex), ());
|
||||
TEST(GetNextRoutePointIndex(resultTest, RoutePointIndex({1 /* m_segmentIndex */, 1 /* m_pathIndex */}), NumMwmIds(),
|
||||
false /* forward */, nextIndex),
|
||||
());
|
||||
TEST_EQUAL(nextIndex, RoutePointIndex({1 /* m_segmentIndex */, 0 /* m_pathIndex */}), ());
|
||||
|
||||
TEST(GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 2 /* m_pathIndex */}),
|
||||
NumMwmIds(), false /* forward */, nextIndex), ());
|
||||
TEST(GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 2 /* m_pathIndex */}), NumMwmIds(),
|
||||
false /* forward */, nextIndex),
|
||||
());
|
||||
TEST_EQUAL(nextIndex, RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}), ());
|
||||
|
||||
TEST(GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}),
|
||||
NumMwmIds(), false /* forward */, nextIndex), ());
|
||||
TEST(GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 1 /* m_pathIndex */}), NumMwmIds(),
|
||||
false /* forward */, nextIndex),
|
||||
());
|
||||
TEST_EQUAL(nextIndex, RoutePointIndex({0 /* m_segmentIndex */, 0 /* m_pathIndex */}), ());
|
||||
|
||||
// Trying to get point before the beginning.
|
||||
TEST(!GetNextRoutePointIndex(resultTest,
|
||||
RoutePointIndex({0 /* m_segmentIndex */, 0 /* m_pathIndex */}),
|
||||
NumMwmIds(), false /* forward */, nextIndex), ());
|
||||
TEST(!GetNextRoutePointIndex(resultTest, RoutePointIndex({0 /* m_segmentIndex */, 0 /* m_pathIndex */}), NumMwmIds(),
|
||||
false /* forward */, nextIndex),
|
||||
());
|
||||
}
|
||||
} // namespace turn_generator_test
|
||||
} // namespace turn_generator_test
|
||||
|
||||
Reference in New Issue
Block a user