diff --git a/routing_common/car_model.cpp b/routing_common/car_model.cpp index da1096201a..174901458a 100644 --- a/routing_common/car_model.cpp +++ b/routing_common/car_model.cpp @@ -4,6 +4,7 @@ #include "indexer/classificator.hpp" +#include #include using namespace std; @@ -231,6 +232,19 @@ CarModel::CarModel(VehicleModel::LimitsInitList const & roadLimits) InitAdditionalRoadTypes(); } +SpeedKMpH CarModel::GetSpeed(FeatureType & f, SpeedParams const & speedParams) const +{ + if (!speedParams.m_maxspeed.IsValid()) + return VehicleModel::GetSpeed(f, speedParams); + + // Note. It's the first rough attempt using maxspeed tag value for speed calculation. + // It's used as a feature speed if it's valid and less then some value. + // @TODO maxspeed tag value should be used more sophisticated. + uint16_t const maxspeedBasedspeedKmPH = speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward); + auto const speedKmPH = min(static_cast(maxspeedBasedspeedKmPH), GetMaxWeightSpeed()); + return {speedKmPH /* weight */, speedKmPH /* eta */}; +} + double CarModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; } void CarModel::InitAdditionalRoadTypes() diff --git a/routing_common/car_model.hpp b/routing_common/car_model.hpp index 2716f6418b..57f8ce05ed 100644 --- a/routing_common/car_model.hpp +++ b/routing_common/car_model.hpp @@ -12,6 +12,7 @@ public: CarModel(VehicleModel::LimitsInitList const & roadLimits); // VehicleModelInterface overrides + SpeedKMpH GetSpeed(FeatureType & f, SpeedParams const & speedParams) const override; double GetOffroadSpeed() const override; static CarModel const & AllLimitsInstance(); diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index 3008499b6d..e0e60571d9 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -95,18 +95,8 @@ VehicleModel::SpeedKMpH VehicleModel::GetSpeed(FeatureType & f, SpeedParams cons // @TODO(bykoianko) Consider using speed on feature |f| instead of using max speed below. if (restriction == RoadAvailability::Available) return speedParams.m_inCity ? m_modelMaxSpeed.m_inCity : m_modelMaxSpeed.m_outCity; - if (restriction != RoadAvailability::NotAvailable && HasRoadType(types)) - { - uint16_t const speedKmPH = speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward); - // Note. It's the first rough attept using maxspeed tag value for speed calculation. - // It's used as a feature speed if it's valid and less then some value. - // @TODO maxspeed tag value should be used more sophisticated. - if (!speedParams.m_maxspeed.IsValid() || speedKmPH > 200) - return GetMinTypeSpeed(types, speedParams.m_inCity); - - return {static_cast(speedKmPH), static_cast(speedKmPH)}; - } + return GetMinTypeSpeed(types, speedParams.m_inCity); return {}; }