From 144f74e1e6430ba798fc27b047a05dff20efaa7c Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 24 Jan 2019 09:43:38 +0300 Subject: [PATCH] [routing] Adding weight for graph and eta in case of going up for pedestrian and bicycle routing. --- routing/edge_estimator.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 386570dd73..f174a76a20 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -4,6 +4,8 @@ #include "traffic/traffic_info.hpp" +#include "indexer/feature_altitude.hpp" + #include "base/assert.hpp" #include @@ -15,6 +17,8 @@ using namespace traffic; namespace { +feature::TAltitude constexpr mountainSicknessAltitudeM = 3000; + enum class Purpose { Weight, @@ -42,23 +46,31 @@ double CalcTrafficFactor(SpeedGroup speedGroup) return 1.0 / percentage; } -double GetPedestrianClimbPenalty(double tangent) +double GetPedestrianClimbPenalty(double tangent, feature::TAltitude altitudeM) { - if (tangent < 0) + if (tangent <= 0) // Descent return 1.0 + 2.0 * (-tangent); - return 1.0 + 5.0 * tangent; + // Climb. + if (altitudeM < mountainSicknessAltitudeM) + return 1.0 + 10.0 * tangent; + else + return 1.0 + 30.0 * tangent; } -double GetBicycleClimbPenalty(double tangent) +double GetBicycleClimbPenalty(double tangent, feature::TAltitude altitudeM) { - if (tangent <= 0) + if (tangent <= 0) // Descent return 1.0; - return 1.0 + 10.0 * tangent; + // Climb. + if (altitudeM < mountainSicknessAltitudeM) + return 1.0 + 30.0 * tangent; + else + return 1.0 + 50.0 * tangent; } -double GetCarClimbPenalty(double /* tangent */) { return 1.0; } +double GetCarClimbPenalty(double /* tangent */, feature::TAltitude /* altitude */) { return 1.0; } template double CalcClimbSegment(Purpose purpose, Segment const & segment, RoadGeometry const & road, @@ -78,7 +90,7 @@ double CalcClimbSegment(Purpose purpose, Segment const & segment, RoadGeometry c double const altitudeDiff = static_cast(to.GetAltitude()) - static_cast(from.GetAltitude()); - return timeSec * getClimbPenalty(altitudeDiff / distance); + return timeSec * getClimbPenalty(altitudeDiff / distance, to.GetAltitude()); } } // namespace