diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 4066a9bd67..bc894261e7 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -223,14 +223,10 @@ ProgressRange CalcProgressRange(Checkpoints const & checkpoints, size_t subroute } if (fullDistance == 0.0) - { - return {0.0, 0.0}; - } - else - { - return {static_cast(startDistance / fullDistance * 100.0), - static_cast(finishDistance / fullDistance * 100.0)}; - } + return {100.0, 100.0}; + + return {static_cast(startDistance / fullDistance * 100.0), + static_cast(finishDistance / fullDistance * 100.0)}; } void PushPassedSubroutes(Checkpoints const & checkpoints, vector & subroutes) diff --git a/routing/routing_consistency_tests/routing_consistency_tests.cpp b/routing/routing_consistency_tests/routing_consistency_tests.cpp index 9a711624c5..72bbe1fbb7 100644 --- a/routing/routing_consistency_tests/routing_consistency_tests.cpp +++ b/routing/routing_consistency_tests/routing_consistency_tests.cpp @@ -83,7 +83,7 @@ public: bool BuildRoute(UserRoutingRecord const & record) { - m_components.GetRouter()->ClearState(); + m_components.GetRouter().ClearState(); auto const result = integration::CalculateRoute(m_components, record.start, m2::PointD::Zero(), record.stop); if (result.second != IRouter::NoError) { diff --git a/routing/routing_integration_tests/bicycle_route_test.cpp b/routing/routing_integration_tests/bicycle_route_test.cpp index 978bfc57d4..45050d5b85 100644 --- a/routing/routing_integration_tests/bicycle_route_test.cpp +++ b/routing/routing_integration_tests/bicycle_route_test.cpp @@ -6,37 +6,38 @@ #include "base/math.hpp" +using namespace integration; using namespace routing; using namespace routing::turns; UNIT_TEST(RussiaMoscowSevTushinoParkPreferingBicycleWay) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(55.87445, 37.43711), {0., 0.}, MercatorBounds::FromLatLon(55.87203, 37.44274), 460.0); } UNIT_TEST(RussiaMoscowNahimovskyLongRoute) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(55.66151, 37.63320), {0., 0.}, MercatorBounds::FromLatLon(55.67695, 37.56220), 5670.0); } UNIT_TEST(RussiaDomodedovoSteps) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(55.44010, 37.77416), {0., 0.}, MercatorBounds::FromLatLon(55.43975, 37.77272), 123.0); } UNIT_TEST(SwedenStockholmCyclewayPriority) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(59.33151, 18.09347), {0., 0.}, MercatorBounds::FromLatLon(59.33052, 18.09391), 113.0); } @@ -45,8 +46,8 @@ UNIT_TEST(SwedenStockholmCyclewayPriority) // it's allowed to ride bicycle will be found. UNIT_TEST(NetherlandsAmsterdamBicycleNo) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(52.32716, 5.05932), {0., 0.}, MercatorBounds::FromLatLon(52.32587, 5.06121), 363.4); } @@ -54,7 +55,7 @@ UNIT_TEST(NetherlandsAmsterdamBicycleNo) UNIT_TEST(NetherlandsAmsterdamBicycleYes) { TRouteResult const routeResult = - integration::CalculateRoute(integration::GetVehicleComponents(), + CalculateRoute(GetVehicleComponents(), MercatorBounds::FromLatLon(52.32872, 5.07527), {0.0, 0.0}, MercatorBounds::FromLatLon(52.33853, 5.08941)); @@ -66,24 +67,24 @@ UNIT_TEST(NetherlandsAmsterdamBicycleYes) UNIT_TEST(NetherlandsAmsterdamSingelStOnewayBicycleNo) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(52.3785, 4.89407), {0., 0.}, MercatorBounds::FromLatLon(52.37462, 4.88983), 519.0); } UNIT_TEST(RussiaMoscowKashirskoe16ToCapLongRoute) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(55.66230, 37.63214), {0., 0.}, MercatorBounds::FromLatLon(55.68895, 37.70286), 7057.0); } UNIT_TEST(RussiaKerchStraitFerryRoute) { - integration::CalculateRouteAndTestRouteLength( - integration::GetVehicleComponents(), + CalculateRouteAndTestRouteLength( + GetVehicleComponents(), MercatorBounds::FromLatLon(45.4167, 36.7658), {0.0, 0.0}, MercatorBounds::FromLatLon(45.3653, 36.6161), 18000.0); } diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index c25d51736f..c73fd13e26 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -80,11 +80,11 @@ namespace integration return storage::CountryInfoReader::CreateCountryInfoReader(platform); } - unique_ptr CreateCarRouter(Index & index, - storage::CountryInfoGetter const & infoGetter, - traffic::TrafficCache const & trafficCache, - vector const & localFiles, - VehicleType vehicleType) + unique_ptr CreateVehicleRouter(Index & index, + storage::CountryInfoGetter const & infoGetter, + traffic::TrafficCache const & trafficCache, + vector const & localFiles, + VehicleType vehicleType) { auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) { return infoGetter.GetRegionCountryId(pt); @@ -156,12 +156,9 @@ namespace integration m2::PointD const & finalPoint) { RouterDelegate delegate; - IRouter * router = routerComponents.GetRouter(); - ASSERT(router, ()); shared_ptr route(new Route("mapsme")); - IRouter::ResultCode result = - router->CalculateRoute(Checkpoints(startPoint, finalPoint), startDirection, - false /* adjust */, delegate, *route); + IRouter::ResultCode result = routerComponents.GetRouter().CalculateRoute( + Checkpoints(startPoint, finalPoint), startDirection, false /* adjust */, delegate, *route); ASSERT(route, ()); return TRouteResult(route, result); } diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp index fd64a7d365..ff24268f88 100644 --- a/routing/routing_integration_tests/routing_test_tools.hpp +++ b/routing/routing_integration_tests/routing_test_tools.hpp @@ -50,11 +50,11 @@ shared_ptr CreateFeaturesFetcher(vector CreateCountryInfoGetter(); -unique_ptr CreateCarRouter(Index & index, - storage::CountryInfoGetter const & infoGetter, - traffic::TrafficCache const & trafficCache, - vector const & localFiles, - VehicleType vehicleType); +unique_ptr CreateVehicleRouter(Index & index, + storage::CountryInfoGetter const & infoGetter, + traffic::TrafficCache const & trafficCache, + vector const & localFiles, + VehicleType vehicleType); class IRouterComponents { @@ -66,7 +66,7 @@ public: virtual ~IRouterComponents() = default; - virtual IRouter * GetRouter() const = 0; + virtual IRouter & GetRouter() const = 0; storage::CountryInfoGetter const & GetCountryInfoGetter() const noexcept { return *m_infoGetter; } @@ -80,12 +80,12 @@ class VehicleRouterComponents : public IRouterComponents public: VehicleRouterComponents(vector const & localFiles, VehicleType vehicleType) : IRouterComponents(localFiles) - , m_indexRouter(CreateCarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, m_trafficCache, - localFiles, vehicleType)) + , m_indexRouter(CreateVehicleRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, m_trafficCache, + localFiles, vehicleType)) { } - IRouter * GetRouter() const override { return m_indexRouter.get(); } + IRouter & GetRouter() const override { return *m_indexRouter; } private: traffic::TrafficCache m_trafficCache;