diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-06-28 15:48:59 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-07-23 10:25:10 +0300 |
commit | 06a48f68e87d06147d726827d131af4bd19bd62c (patch) | |
tree | 3f9c0b995ee242bfefd26b86f08650bb4e8b9ed6 /routing | |
parent | 7de86381e97a0606dd7db6dcba600178d9095202 (diff) |
git-clang-format
Diffstat (limited to 'routing')
-rw-r--r-- | routing/features_road_graph.cpp | 7 | ||||
-rw-r--r-- | routing/features_road_graph.hpp | 7 | ||||
-rw-r--r-- | routing/nearest_edge_finder.cpp | 26 | ||||
-rw-r--r-- | routing/road_graph.cpp | 24 | ||||
-rw-r--r-- | routing/road_graph.hpp | 11 | ||||
-rw-r--r-- | routing/routing_helpers.hpp | 8 | ||||
-rw-r--r-- | routing/routing_tests/astar_router_test.cpp | 106 | ||||
-rw-r--r-- | routing/routing_tests/nearest_edge_finder_tests.cpp | 40 | ||||
-rw-r--r-- | routing/routing_tests/road_graph_nearest_edges_test.cpp | 38 |
9 files changed, 136 insertions, 131 deletions
diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index a59ed392e7..90546fd332 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -263,11 +263,12 @@ void FeaturesRoadGraph::ExtractRoadInfo(FeatureID const & featureId, FeatureType ft.ParseGeometry(FeatureType::BEST_GEOMETRY); ft.ParseAltitude(); // @TODO It's a temprarery solution until a vector of feature altitudes is saved in mwm. - bool const isAltidudeValid = - ft.GetAltitudes().begin != feature::kInvalidAltitude && ft.GetAltitudes().end != feature::kInvalidAltitude; + bool const isAltidudeValid = ft.GetAltitudes().begin != feature::kInvalidAltitude && + ft.GetAltitudes().end != feature::kInvalidAltitude; feature::TAltitude pointAlt = ft.GetAltitudes().begin; size_t const pointsCount = ft.GetPointsCount(); - feature::TAltitude const diffAlt = isAltidudeValid ? (ft.GetAltitudes().end - ft.GetAltitudes().begin) / pointsCount : 0; + feature::TAltitude const diffAlt = + isAltidudeValid ? (ft.GetAltitudes().end - ft.GetAltitudes().begin) / pointsCount : 0; ri.m_junctions.clear(); ri.m_junctions.resize(pointsCount); diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index e870d18859..1ca7957ecc 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -87,11 +87,10 @@ private: RoadInfo const & GetCachedRoadInfo(FeatureID const & featureId) const; // Searches a feature RoadInfo in the cache, and if does not find then takes passed feature and speed. // This version is used to prevent redundant feature loading when feature speed is known. - RoadInfo const & GetCachedRoadInfo(FeatureID const & featureId, - FeatureType const & ft, + RoadInfo const & GetCachedRoadInfo(FeatureID const & featureId, FeatureType const & ft, double speedKMPH) const; - void ExtractRoadInfo(FeatureID const & featureId, FeatureType const & ft, - double speedKMPH, RoadInfo & ri) const; + void ExtractRoadInfo(FeatureID const & featureId, FeatureType const & ft, double speedKMPH, + RoadInfo & ri) const; void LockFeatureMwm(FeatureID const & featureId) const; diff --git a/routing/nearest_edge_finder.cpp b/routing/nearest_edge_finder.cpp index 1e7b1b0e02..181eda1cf9 100644 --- a/routing/nearest_edge_finder.cpp +++ b/routing/nearest_edge_finder.cpp @@ -10,12 +10,7 @@ namespace routing { - -NearestEdgeFinder::Candidate::Candidate() - : m_dist(numeric_limits<double>::max()), - m_segId(0) -{ -} +NearestEdgeFinder::Candidate::Candidate() : m_dist(numeric_limits<double>::max()), m_segId(0) {} NearestEdgeFinder::NearestEdgeFinder(m2::PointD const & point) : m_point(point) @@ -45,11 +40,14 @@ void NearestEdgeFinder::AddInformationSource(FeatureID const & featureId, IRoadG res.m_segEnd = roadInfo.m_junctions[i]; // @TODO res.m_projPoint.GetAltitude() is an altitude of |pt|. |pt| is a projection of m_point // to segment [res.m_segStart.GetPoint(), res.m_segEnd.GetPoint()]. - // It's necessary to calculate exact value of res.m_projPoint.GetAltitude() by this information. - bool const isAltidudeValid = res.m_segStart.GetAltitude() != feature::kInvalidAltitude - && res.m_segEnd.GetAltitude() != feature::kInvalidAltitude; - feature::TAltitude const projPointAlt = isAltidudeValid ? static_cast<feature::TAltitude>((res.m_segStart.GetAltitude() + res.m_segEnd.GetAltitude()) / 2) - : feature::kInvalidAltitude; + // It's necessary to calculate exact value of res.m_projPoint.GetAltitude() by this + // information. + bool const isAltidudeValid = res.m_segStart.GetAltitude() != feature::kInvalidAltitude && + res.m_segEnd.GetAltitude() != feature::kInvalidAltitude; + feature::TAltitude const projPointAlt = + isAltidudeValid ? static_cast<feature::TAltitude>( + (res.m_segStart.GetAltitude() + res.m_segEnd.GetAltitude()) / 2) + : feature::kInvalidAltitude; res.m_projPoint = Junction(pt, projPointAlt); } } @@ -58,7 +56,8 @@ void NearestEdgeFinder::AddInformationSource(FeatureID const & featureId, IRoadG m_candidates.push_back(res); } -void NearestEdgeFinder::MakeResult(vector<pair<Edge, Junction>> & res, size_t const maxCountFeatures) +void NearestEdgeFinder::MakeResult(vector<pair<Edge, Junction>> & res, + size_t const maxCountFeatures) { sort(m_candidates.begin(), m_candidates.end(), [](Candidate const & r1, Candidate const & r2) { @@ -72,7 +71,8 @@ void NearestEdgeFinder::MakeResult(vector<pair<Edge, Junction>> & res, size_t co for (Candidate const & candidate : m_candidates) { res.emplace_back(Edge(candidate.m_fid, true /* forward */, candidate.m_segId, - candidate.m_segStart, candidate.m_segEnd), candidate.m_projPoint); + candidate.m_segStart, candidate.m_segEnd), + candidate.m_projPoint); ++i; if (i == maxCountFeatures) break; diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index a2e1ea414a..c362365400 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -66,9 +66,7 @@ void ReverseEdges(size_t beginIdx, IRoadGraph::TEdgeVector & edges) // Junction -------------------------------------------------------------------- -Junction::Junction() - : m_point(m2::PointD::Zero()), m_altitude(feature::kInvalidAltitude) -{} +Junction::Junction() : m_point(m2::PointD::Zero()), m_altitude(feature::kInvalidAltitude) {} Junction::Junction(m2::PointD const & point, feature::TAltitude altitude) : m_point(point), m_altitude(altitude) @@ -146,19 +144,21 @@ IRoadGraph::RoadInfo::RoadInfo() {} IRoadGraph::RoadInfo::RoadInfo(RoadInfo && ri) - : m_junctions(move(ri.m_junctions)), - m_speedKMPH(ri.m_speedKMPH), - m_bidirectional(ri.m_bidirectional) + : m_junctions(move(ri.m_junctions)) + , m_speedKMPH(ri.m_speedKMPH) + , m_bidirectional(ri.m_bidirectional) {} -IRoadGraph::RoadInfo::RoadInfo(bool bidirectional, double speedKMPH, initializer_list<Junction> const & points) - : m_junctions(points), m_speedKMPH(speedKMPH), m_bidirectional(bidirectional) +IRoadGraph::RoadInfo::RoadInfo(bool bidirectional, double speedKMPH, + initializer_list<Junction> const & points) + : m_junctions(points), m_speedKMPH(speedKMPH), m_bidirectional(bidirectional) {} // IRoadGraph::CrossOutgoingLoader --------------------------------------------- void IRoadGraph::CrossOutgoingLoader::LoadEdges(FeatureID const & featureId, RoadInfo const & roadInfo) { - ForEachEdge(roadInfo, [&featureId, &roadInfo, this](size_t segId, Junction const & endJunction, bool forward) + ForEachEdge(roadInfo, [&featureId, &roadInfo, this](size_t segId, Junction const & endJunction, + bool forward) { if (forward || roadInfo.m_bidirectional || m_mode == IRoadGraph::Mode::IgnoreOnewayTag) m_edges.emplace_back(featureId, forward, segId, m_cross, endJunction); @@ -168,7 +168,8 @@ void IRoadGraph::CrossOutgoingLoader::LoadEdges(FeatureID const & featureId, Roa // IRoadGraph::CrossIngoingLoader ---------------------------------------------- void IRoadGraph::CrossIngoingLoader::LoadEdges(FeatureID const & featureId, RoadInfo const & roadInfo) { - ForEachEdge(roadInfo, [&featureId, &roadInfo, this](size_t segId, Junction const & endJunction, bool forward) + ForEachEdge(roadInfo, [&featureId, &roadInfo, this](size_t segId, Junction const & endJunction, + bool forward) { if (!forward || roadInfo.m_bidirectional || m_mode == IRoadGraph::Mode::IgnoreOnewayTag) m_edges.emplace_back(featureId, !forward, segId, endJunction, m_cross); @@ -222,7 +223,8 @@ void IRoadGraph::ResetFakes() m_outgoingEdges.clear(); } -void IRoadGraph::AddFakeEdges(Junction const & junction, vector<pair<Edge, Junction>> const & vicinity) +void IRoadGraph::AddFakeEdges(Junction const & junction, + vector<pair<Edge, Junction>> const & vicinity) { for (auto const & v : vicinity) { diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 00b86e670f..505376aed5 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -143,7 +143,8 @@ public: { for (size_t i = 0; i < roadInfo.m_junctions.size(); ++i) { - if (!my::AlmostEqualAbs(m_cross.GetPoint(), roadInfo.m_junctions[i].GetPoint(), kPointsEqualEpsilon)) + if (!my::AlmostEqualAbs(m_cross.GetPoint(), roadInfo.m_junctions[i].GetPoint(), + kPointsEqualEpsilon)) continue; if (i < roadInfo.m_junctions.size() - 1) @@ -172,7 +173,9 @@ public: { public: CrossOutgoingLoader(Junction const & cross, IRoadGraph::Mode mode, TEdgeVector & edges) - : ICrossEdgesLoader(cross, mode, edges) {} + : ICrossEdgesLoader(cross, mode, edges) + { + } private: // ICrossEdgesLoader overrides: @@ -183,7 +186,9 @@ public: { public: CrossIngoingLoader(Junction const & cross, IRoadGraph::Mode mode, TEdgeVector & edges) - : ICrossEdgesLoader(cross, mode, edges) {} + : ICrossEdgesLoader(cross, mode, edges) + { + } private: // ICrossEdgesLoader overrides: diff --git a/routing/routing_helpers.hpp b/routing/routing_helpers.hpp index 45f8fa7b3c..c602fbd453 100644 --- a/routing/routing_helpers.hpp +++ b/routing/routing_helpers.hpp @@ -10,8 +10,8 @@ namespace routing template <class TList> bool IsRoad(TList const & types) { - return CarModel::Instance().HasRoadType(types) - || PedestrianModel::DefaultInstance().HasRoadType(types) - || BicycleModel::DefaultInstance().HasRoadType(types); + return CarModel::Instance().HasRoadType(types) || + PedestrianModel::DefaultInstance().HasRoadType(types) || + BicycleModel::DefaultInstance().HasRoadType(types); } -} // namespace rouing +} // namespace rouing diff --git a/routing/routing_tests/astar_router_test.cpp b/routing/routing_tests/astar_router_test.cpp index f6372bf326..3f7a125997 100644 --- a/routing/routing_tests/astar_router_test.cpp +++ b/routing/routing_tests/astar_router_test.cpp @@ -56,12 +56,10 @@ UNIT_TEST(AStarRouter_Graph2_Simple1) Junction const startPos = MakeJunctionForTesting(m2::PointD(0, 0)); Junction const finalPos = MakeJunctionForTesting(m2::PointD(80, 55)); - vector<Junction> const expected = {MakeJunctionForTesting(m2::PointD(0, 0)), - MakeJunctionForTesting(m2::PointD(5, 10)), - MakeJunctionForTesting(m2::PointD(5, 40)), - MakeJunctionForTesting(m2::PointD(18, 55)), - MakeJunctionForTesting(m2::PointD(39, 55)), - MakeJunctionForTesting(m2::PointD(80, 55))}; + vector<Junction> const expected = { + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(5, 10)), + MakeJunctionForTesting(m2::PointD(5, 40)), MakeJunctionForTesting(m2::PointD(18, 55)), + MakeJunctionForTesting(m2::PointD(39, 55)), MakeJunctionForTesting(m2::PointD(80, 55))}; TestAStarRouterMock(startPos, finalPos, expected); } @@ -71,13 +69,11 @@ UNIT_TEST(AStarRouter_Graph2_Simple2) Junction const startPos = MakeJunctionForTesting(m2::PointD(80, 55)); Junction const finalPos = MakeJunctionForTesting(m2::PointD(80, 0)); - vector<Junction> const expected = {MakeJunctionForTesting(m2::PointD(80, 55)), - MakeJunctionForTesting(m2::PointD(39, 55)), - MakeJunctionForTesting(m2::PointD(37, 30)), - MakeJunctionForTesting(m2::PointD(70, 30)), - MakeJunctionForTesting(m2::PointD(70, 10)), - MakeJunctionForTesting(m2::PointD(70, 0)), - MakeJunctionForTesting(m2::PointD(80, 0))}; + vector<Junction> const expected = { + MakeJunctionForTesting(m2::PointD(80, 55)), MakeJunctionForTesting(m2::PointD(39, 55)), + MakeJunctionForTesting(m2::PointD(37, 30)), MakeJunctionForTesting(m2::PointD(70, 30)), + MakeJunctionForTesting(m2::PointD(70, 10)), MakeJunctionForTesting(m2::PointD(70, 0)), + MakeJunctionForTesting(m2::PointD(80, 0))}; TestAStarRouterMock(startPos, finalPos, expected); } @@ -97,10 +93,9 @@ UNIT_TEST(AStarRouter_SimpleGraph_RouteIsFound) Junction const startPos = MakeJunctionForTesting(m2::PointD(0, 0)); Junction const finalPos = MakeJunctionForTesting(m2::PointD(40, 100)); - vector<Junction> const expected = {MakeJunctionForTesting(m2::PointD(0, 0)), - MakeJunctionForTesting(m2::PointD(0, 30)), - MakeJunctionForTesting(m2::PointD(0, 60)), - MakeJunctionForTesting(m2::PointD(40, 100))}; + vector<Junction> const expected = { + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, 30)), + MakeJunctionForTesting(m2::PointD(0, 60)), MakeJunctionForTesting(m2::PointD(40, 100))}; RouterDelegate delegate; RoutingResult<Junction> result; @@ -120,30 +115,36 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents) double const speedKMPH = graph.GetMaxSpeedKMPH(); // Roads in the first connected component. - vector<IRoadGraph::RoadInfo> const roadInfo_1 = - { - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(10, 10)), MakeJunctionForTesting(m2::PointD(90, 10))}), // feature 0 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(90, 10)), MakeJunctionForTesting(m2::PointD(90, 90))}), // feature 1 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(90, 90)), MakeJunctionForTesting(m2::PointD(10, 90))}), // feature 2 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(10, 90)), MakeJunctionForTesting(m2::PointD(10, 10))}), // feature 3 + vector<IRoadGraph::RoadInfo> const roadInfo_1 = { + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(10, 10)), + MakeJunctionForTesting(m2::PointD(90, 10))}), // feature 0 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(90, 10)), + MakeJunctionForTesting(m2::PointD(90, 90))}), // feature 1 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(90, 90)), + MakeJunctionForTesting(m2::PointD(10, 90))}), // feature 2 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(10, 90)), + MakeJunctionForTesting(m2::PointD(10, 10))}), // feature 3 }; vector<uint32_t> const featureId_1 = { 0, 1, 2, 3 }; // featureIDs in the first connected component // Roads in the second connected component. - vector<IRoadGraph::RoadInfo> const roadInfo_2 = - { - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(30, 30)), MakeJunctionForTesting(m2::PointD(70, 30))}), // feature 4 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(70, 30)), MakeJunctionForTesting(m2::PointD(70, 70))}), // feature 5 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(70, 70)), MakeJunctionForTesting(m2::PointD(30, 70))}), // feature 6 - IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, { - MakeJunctionForTesting(m2::PointD(30, 70)), MakeJunctionForTesting(m2::PointD(30, 30))}), // feature 7 + vector<IRoadGraph::RoadInfo> const roadInfo_2 = { + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(30, 30)), + MakeJunctionForTesting(m2::PointD(70, 30))}), // feature 4 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(70, 30)), + MakeJunctionForTesting(m2::PointD(70, 70))}), // feature 5 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(70, 70)), + MakeJunctionForTesting(m2::PointD(30, 70))}), // feature 6 + IRoadGraph::RoadInfo(true /* bidir */, speedKMPH, + {MakeJunctionForTesting(m2::PointD(30, 70)), + MakeJunctionForTesting(m2::PointD(30, 30))}), // feature 7 }; vector<uint32_t> const featureId_2 = { 4, 5, 6, 7 }; // featureIDs in the second connected component @@ -232,13 +233,14 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1) algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)), MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result), ()); - TEST_EQUAL(result.path, vector<Junction>({MakeJunctionForTesting(m2::PointD(2,2)), - MakeJunctionForTesting(m2::PointD(2,3)), - MakeJunctionForTesting(m2::PointD(4,3)), - MakeJunctionForTesting(m2::PointD(6,3)), - MakeJunctionForTesting(m2::PointD(8,3)), - MakeJunctionForTesting(m2::PointD(10,3)), - MakeJunctionForTesting(m2::PointD(10,2))}), ()); + TEST_EQUAL( + result.path, + vector<Junction>( + {MakeJunctionForTesting(m2::PointD(2, 2)), MakeJunctionForTesting(m2::PointD(2, 3)), + MakeJunctionForTesting(m2::PointD(4, 3)), MakeJunctionForTesting(m2::PointD(6, 3)), + MakeJunctionForTesting(m2::PointD(8, 3)), MakeJunctionForTesting(m2::PointD(10, 3)), + MakeJunctionForTesting(m2::PointD(10, 2))}), + ()); TEST(my::AlmostEqualAbs(result.distance, 800451., 1.), ("Distance error:", result.distance)); } @@ -266,9 +268,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2) algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)), MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result), ()); - TEST_EQUAL(result.path, vector<Junction>({MakeJunctionForTesting(m2::PointD(2,2)), - MakeJunctionForTesting(m2::PointD(6,2)), - MakeJunctionForTesting(m2::PointD(10,2))}), ()); + TEST_EQUAL(result.path, vector<Junction>({MakeJunctionForTesting(m2::PointD(2, 2)), + MakeJunctionForTesting(m2::PointD(6, 2)), + MakeJunctionForTesting(m2::PointD(10, 2))}), + ()); TEST(my::AlmostEqualAbs(result.distance, 781458., 1.), ("Distance error:", result.distance)); } @@ -296,9 +299,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3) algorithm.CalculateRoute(graph, MakeJunctionForTesting(m2::PointD(2, 2)), MakeJunctionForTesting(m2::PointD(10, 2)), delegate, result), ()); - TEST_EQUAL(result.path, vector<Junction>({MakeJunctionForTesting(m2::PointD(2,2)), - MakeJunctionForTesting(m2::PointD(2,1)), - MakeJunctionForTesting(m2::PointD(10,1)), - MakeJunctionForTesting(m2::PointD(10,2))}), ()); + TEST_EQUAL(result.path, vector<Junction>({MakeJunctionForTesting(m2::PointD(2, 2)), + MakeJunctionForTesting(m2::PointD(2, 1)), + MakeJunctionForTesting(m2::PointD(10, 1)), + MakeJunctionForTesting(m2::PointD(10, 2))}), + ()); TEST(my::AlmostEqualAbs(result.distance, 814412., 1.), ("Distance error:", result.distance)); } diff --git a/routing/routing_tests/nearest_edge_finder_tests.cpp b/routing/routing_tests/nearest_edge_finder_tests.cpp index 978f3531c2..913317febb 100644 --- a/routing/routing_tests/nearest_edge_finder_tests.cpp +++ b/routing/routing_tests/nearest_edge_finder_tests.cpp @@ -8,7 +8,7 @@ using namespace routing; using namespace routing_test; void TestNearestOnMock1(m2::PointD const & point, size_t const candidatesCount, - vector<pair<Edge, Junction>> const & expected) + vector<pair<Edge, Junction>> const & expected) { unique_ptr<RoadGraphMockSource> graph(new RoadGraphMockSource()); InitRoadGraphMockSourceWithTest1(*graph); @@ -29,36 +29,32 @@ void TestNearestOnMock1(m2::PointD const & point, size_t const candidatesCount, UNIT_TEST(StarterPosAtBorder_Mock1Graph) { - vector<pair<Edge, Junction>> const expected = - { - make_pair(Edge(MakeTestFeatureID(0), true /* forward */, 0, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(5, 0))), - MakeJunctionForTesting(m2::PointD(0, 0))) - }; + vector<pair<Edge, Junction>> const expected = {make_pair( + Edge(MakeTestFeatureID(0), true /* forward */, 0, MakeJunctionForTesting(m2::PointD(0, 0)), + MakeJunctionForTesting(m2::PointD(5, 0))), + MakeJunctionForTesting(m2::PointD(0, 0)))}; TestNearestOnMock1(m2::PointD(0, 0), 1, expected); } UNIT_TEST(MiddleEdgeTest_Mock1Graph) { - vector<pair<Edge, Junction>> const expected = - { - make_pair(Edge(MakeTestFeatureID(0), true /* forward */, 0, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(5, 0))), - MakeJunctionForTesting(m2::PointD(3, 0))) - }; + vector<pair<Edge, Junction>> const expected = {make_pair( + Edge(MakeTestFeatureID(0), true /* forward */, 0, MakeJunctionForTesting(m2::PointD(0, 0)), + MakeJunctionForTesting(m2::PointD(5, 0))), + MakeJunctionForTesting(m2::PointD(3, 0)))}; TestNearestOnMock1(m2::PointD(3, 3), 1, expected); } UNIT_TEST(MiddleSegmentTest_Mock1Graph) { - vector<pair<Edge, Junction>> const expected = - { - make_pair(Edge(MakeTestFeatureID(0), true /* forward */, 2, - MakeJunctionForTesting(m2::PointD(10, 0)), MakeJunctionForTesting(m2::PointD(15, 0))), - MakeJunctionForTesting(m2::PointD(12.5, 0))), - make_pair(Edge(MakeTestFeatureID(1), true /* forward */, 2, - MakeJunctionForTesting(m2::PointD(10, 0)), MakeJunctionForTesting(m2::PointD(10, 5))), - MakeJunctionForTesting(m2::PointD(10, 2.5))) - }; + vector<pair<Edge, Junction>> const expected = { + make_pair(Edge(MakeTestFeatureID(0), true /* forward */, 2, + MakeJunctionForTesting(m2::PointD(10, 0)), + MakeJunctionForTesting(m2::PointD(15, 0))), + MakeJunctionForTesting(m2::PointD(12.5, 0))), + make_pair(Edge(MakeTestFeatureID(1), true /* forward */, 2, + MakeJunctionForTesting(m2::PointD(10, 0)), + MakeJunctionForTesting(m2::PointD(10, 5))), + MakeJunctionForTesting(m2::PointD(10, 2.5)))}; TestNearestOnMock1(m2::PointD(12.5, 2.5), 2, expected); } diff --git a/routing/routing_tests/road_graph_nearest_edges_test.cpp b/routing/routing_tests/road_graph_nearest_edges_test.cpp index 757c7623ea..9346ab6441 100644 --- a/routing/routing_tests/road_graph_nearest_edges_test.cpp +++ b/routing/routing_tests/road_graph_nearest_edges_test.cpp @@ -55,30 +55,28 @@ UNIT_TEST(RoadGraph_NearestEdges) Junction const crossPos = MakeJunctionForTesting(m2::PointD(0, 0)); // Expected outgoing edges. - IRoadGraph::TEdgeVector expectedOutgoing = - { - Edge(MakeTestFeatureID(0) /* first road */, false /* forward */, 1 /* segId */, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(-1, 0))), - Edge(MakeTestFeatureID(0) /* first road */, true /* forward */, 2 /* segId */, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(1, 0))), - Edge(MakeTestFeatureID(1) /* second road */, false /* forward */, 1 /* segId */, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, -1))), - Edge(MakeTestFeatureID(1) /* second road */, true /* forward */, 2 /* segId */, - MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, 1))), + IRoadGraph::TEdgeVector expectedOutgoing = { + Edge(MakeTestFeatureID(0) /* first road */, false /* forward */, 1 /* segId */, + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(-1, 0))), + Edge(MakeTestFeatureID(0) /* first road */, true /* forward */, 2 /* segId */, + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(1, 0))), + Edge(MakeTestFeatureID(1) /* second road */, false /* forward */, 1 /* segId */, + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, -1))), + Edge(MakeTestFeatureID(1) /* second road */, true /* forward */, 2 /* segId */, + MakeJunctionForTesting(m2::PointD(0, 0)), MakeJunctionForTesting(m2::PointD(0, 1))), }; sort(expectedOutgoing.begin(), expectedOutgoing.end()); // Expected ingoing edges. - IRoadGraph::TEdgeVector expectedIngoing = - { - Edge(MakeTestFeatureID(0) /* first road */, true /* forward */, 1 /* segId */, - MakeJunctionForTesting(m2::PointD(-1, 0)), MakeJunctionForTesting(m2::PointD(0, 0))), - Edge(MakeTestFeatureID(0) /* first road */, false /* forward */, 2 /* segId */, - MakeJunctionForTesting(m2::PointD(1, 0)), MakeJunctionForTesting(m2::PointD(0, 0))), - Edge(MakeTestFeatureID(1) /* second road */, true /* forward */, 1 /* segId */, - MakeJunctionForTesting(m2::PointD(0, -1)), MakeJunctionForTesting(m2::PointD(0, 0))), - Edge(MakeTestFeatureID(1) /* second road */, false /* forward */, 2 /* segId */, - MakeJunctionForTesting(m2::PointD(0, 1)), MakeJunctionForTesting(m2::PointD(0, 0))), + IRoadGraph::TEdgeVector expectedIngoing = { + Edge(MakeTestFeatureID(0) /* first road */, true /* forward */, 1 /* segId */, + MakeJunctionForTesting(m2::PointD(-1, 0)), MakeJunctionForTesting(m2::PointD(0, 0))), + Edge(MakeTestFeatureID(0) /* first road */, false /* forward */, 2 /* segId */, + MakeJunctionForTesting(m2::PointD(1, 0)), MakeJunctionForTesting(m2::PointD(0, 0))), + Edge(MakeTestFeatureID(1) /* second road */, true /* forward */, 1 /* segId */, + MakeJunctionForTesting(m2::PointD(0, -1)), MakeJunctionForTesting(m2::PointD(0, 0))), + Edge(MakeTestFeatureID(1) /* second road */, false /* forward */, 2 /* segId */, + MakeJunctionForTesting(m2::PointD(0, 1)), MakeJunctionForTesting(m2::PointD(0, 0))), }; sort(expectedIngoing.begin(), expectedIngoing.end()); |