From 2477bc30b030e2e662d325dbb38986e34e40d8fe Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 24 Jan 2019 14:41:33 +0300 Subject: [PATCH] Review fixes. --- routing/edge_estimator.cpp | 18 ++++++++++-------- routing/index_router.cpp | 3 ++- .../pedestrian_route_test.cpp | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index f174a76a20..39bef23fba 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -17,7 +17,7 @@ using namespace traffic; namespace { -feature::TAltitude constexpr mountainSicknessAltitudeM = 3000; +feature::TAltitude constexpr kMountainSicknessAltitudeM = 2500; enum class Purpose { @@ -52,10 +52,12 @@ double GetPedestrianClimbPenalty(double tangent, feature::TAltitude altitudeM) return 1.0 + 2.0 * (-tangent); // Climb. - if (altitudeM < mountainSicknessAltitudeM) - return 1.0 + 10.0 * tangent; - else - return 1.0 + 30.0 * tangent; + // The upper the penalty is more: + // |1 + 10 * tangent| for altitudes lower than |kMountainSicknessAltitudeM| + // |1 + 20 * tangent| for 4000 meters + // |1 + 30 * tangent| for 5500 meters + // |1 + 40 * tangent| for 7000 meters + return 1.0 + (10.0 + max(0, altitudeM - kMountainSicknessAltitudeM) * 10.0 / 1500) * tangent; } double GetBicycleClimbPenalty(double tangent, feature::TAltitude altitudeM) @@ -64,10 +66,10 @@ double GetBicycleClimbPenalty(double tangent, feature::TAltitude altitudeM) return 1.0; // Climb. - if (altitudeM < mountainSicknessAltitudeM) + if (altitudeM < kMountainSicknessAltitudeM) return 1.0 + 30.0 * tangent; - else - return 1.0 + 50.0 * tangent; + + return 1.0 + 50.0 * tangent; } double GetCarClimbPenalty(double /* tangent */, feature::TAltitude /* altitude */) { return 1.0; } diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 32ac259d55..5dd5667b26 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -473,7 +473,8 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, if (redressResult != RouterResultCode::NoError) return redressResult; - LOG(LINFO, ("Route length:", route.GetTotalDistanceMeters())); + LOG(LINFO, ("Route length:", route.GetTotalDistanceMeters(), "meters. ETA:", + route.GetTotalTimeSec(), "seconds.")); m_lastRoute = make_unique(checkpoints.GetStart(), checkpoints.GetFinish(), route.GetSubroutes()); diff --git a/routing/routing_integration_tests/pedestrian_route_test.cpp b/routing/routing_integration_tests/pedestrian_route_test.cpp index 54b8eba63e..02d6aa4fd5 100644 --- a/routing/routing_integration_tests/pedestrian_route_test.cpp +++ b/routing/routing_integration_tests/pedestrian_route_test.cpp @@ -512,7 +512,7 @@ UNIT_TEST(RussiaPriut11Elbrus) integration::CalculateRouteAndTestRouteTime( integration::GetVehicleComponents(), MercatorBounds::FromLatLon(43.31475, 42.46035), {0., 0.}, - MercatorBounds::FromLatLon(43.35254, 42.43788), 37300.8 /* expectedTimeSeconds */); + MercatorBounds::FromLatLon(43.35254, 42.43788), 32588.6 /* expectedTimeSeconds */); } // Test on going down from Elbrus mountain to Priut11. @@ -521,5 +521,5 @@ UNIT_TEST(RussiaElbrusPriut11) integration::CalculateRouteAndTestRouteTime( integration::GetVehicleComponents(), MercatorBounds::FromLatLon(43.35254, 42.43788), {0., 0.}, - MercatorBounds::FromLatLon(43.31475, 42.46035), 5980.33 /* expectedTimeSeconds */); + MercatorBounds::FromLatLon(43.31475, 42.46035), 5998.61 /* expectedTimeSeconds */); }