From dec6ddc26375dd2df98bca7bbdacaafc2149c73d Mon Sep 17 00:00:00 2001 From: Mikhail Gorbushin Date: Fri, 11 Jan 2019 13:43:54 +0300 Subject: [PATCH] [routing] Review fixes --- routing/cross_mwm_index_graph.hpp | 4 ++- .../routing_test_tools.cpp | 32 +++++-------------- .../transit_route_test.cpp | 22 ++++++------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index 809bd7fd60..ccc07a9e74 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace routing @@ -186,8 +187,9 @@ private: } /// \brief Checks segment for equality point by point. - bool SegmentsAreEqualByGeometry(Segment const & one, Segment const & two) + bool SegmentsAreEqualByGeometry(Segment const & one, Segment const & two) { + // Do not check for transit graph. if (!one.IsRealSegment() || !two.IsRealSegment()) return true; diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index db25257e2a..fe9c9e192c 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -347,9 +347,7 @@ void TestOnlineCrosses(ms::LatLon const & startPoint, ms::LatLon const & finalPo bool IsSubwayExists(Route const & route) { auto const & routeSegments = route.GetRouteSegments(); - bool intoSubway = false; - bool wasSubway = false; for (auto const & routeSegment : routeSegments) { @@ -359,30 +357,16 @@ bool IsSubwayExists(Route const & route) continue; } - switch (routeSegment.GetTransitInfo().GetType()) - { - case TransitInfo::Type::Gate: - { - if (intoSubway) - { - // Out from subway - intoSubway = false; - wasSubway = true; - } - else - { - // Enter into subway - intoSubway = true; - } - break; - } - case TransitInfo::Type::Edge: - case TransitInfo::Type::Transfer: - break; - } + if (routeSegment.GetTransitInfo().GetType() != TransitInfo::Type::Gate) + continue; + + if (intoSubway) + return true; + + intoSubway = true; } - return wasSubway; + return false; } void CheckSubwayAbsent(Route const & route) diff --git a/routing/routing_integration_tests/transit_route_test.cpp b/routing/routing_integration_tests/transit_route_test.cpp index 37b74e5468..f61b93378d 100644 --- a/routing/routing_integration_tests/transit_route_test.cpp +++ b/routing/routing_integration_tests/transit_route_test.cpp @@ -12,7 +12,7 @@ UNIT_TEST(Moscow_CenterToKotelniki_CrossMwm) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(55.75018, 37.60971), {0., 0.}, + MercatorBounds::FromLatLon(55.75018, 37.60971), {0.0, 0.0}, MercatorBounds::FromLatLon(55.67245, 37.86130)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -26,7 +26,7 @@ UNIT_TEST(Moscow_DubrovkaToTrtykovskya) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(55.71813, 37.67756), {0., 0.}, + MercatorBounds::FromLatLon(55.71813, 37.67756), {0.0, 0.0}, MercatorBounds::FromLatLon(55.74089, 37.62831)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -40,7 +40,7 @@ UNIT_TEST(Moscow_NoSubwayTest) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(55.73893, 37.62438), {0., 0.}, + MercatorBounds::FromLatLon(55.73893, 37.62438), {0.0, 0.0}, MercatorBounds::FromLatLon(55.73470, 37.62617)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -54,7 +54,7 @@ UNIT_TEST(Piter_FrunzenskyaToPlochadVosstaniya) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(59.90511, 30.31425), {0., 0.}, + MercatorBounds::FromLatLon(59.90511, 30.31425), {0.0, 0.0}, MercatorBounds::FromLatLon(59.93096, 30.35872)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -68,7 +68,7 @@ UNIT_TEST(Piter_TooLongPedestrian) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(59.90511, 30.31425), {0., 0.}, + MercatorBounds::FromLatLon(59.90511, 30.31425), {0.0, 0.0}, MercatorBounds::FromLatLon(59.80677, 30.44749)); TEST_EQUAL(routeResult.second, RouterResultCode::TransitRouteNotFoundTooLongPedestrian, ()); @@ -78,7 +78,7 @@ UNIT_TEST(Vatikan_NotEnoughGraphDataAtThenEnd) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(41.90052, 12.42642), {0., 0.}, + MercatorBounds::FromLatLon(41.90052, 12.42642), {0.0, 0.0}, MercatorBounds::FromLatLon(41.90253, 12.45574)); // TODO (@gmoryes) here must be RouteNotFound. @@ -89,7 +89,7 @@ UNIT_TEST(Vatikan_CorneliaToOttaviano) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(41.90052, 12.42642), {0., 0.}, + MercatorBounds::FromLatLon(41.90052, 12.42642), {0.0, 0.0}, MercatorBounds::FromLatLon(41.90414, 12.45640)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -104,7 +104,7 @@ UNIT_TEST(London_PoplarToOval) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(51.50818, -0.01634), {0., 0.}, + MercatorBounds::FromLatLon(51.50818, -0.01634), {0.0, 0.0}, MercatorBounds::FromLatLon(51.48041, -0.10843)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -119,7 +119,7 @@ UNIT_TEST(London_DeptfordBridgeToCyprus) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(51.47149, -0.030558), {0., 0.}, + MercatorBounds::FromLatLon(51.47149, -0.030558), {0.0, 0.0}, MercatorBounds::FromLatLon(51.51242, 0.07101)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -134,7 +134,7 @@ UNIT_TEST(Vashington_FoggyToShaw) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(38.89582, -77.04934), {0., 0.}, + MercatorBounds::FromLatLon(38.89582, -77.04934), {0.0, 0.0}, MercatorBounds::FromLatLon(38.91516, -77.01513)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ()); @@ -149,7 +149,7 @@ UNIT_TEST(NewYork_GrassmereToPleasantPlains) { TRouteResult routeResult = integration::CalculateRoute(integration::GetVehicleComponents(), - MercatorBounds::FromLatLon(40.60536, -74.07736), {0., 0.}, + MercatorBounds::FromLatLon(40.60536, -74.07736), {0.0, 0.0}, MercatorBounds::FromLatLon(40.53015, -74.21559)); TEST_EQUAL(routeResult.second, RouterResultCode::NoError, ());