diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2018-11-14 15:18:26 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-11-23 17:58:49 +0300 |
commit | d99a98e4985a20b093bde7cc690c265837a34a87 (patch) | |
tree | 784f127294a0ae28144677a1268403ff7773675d /routing_common | |
parent | 2cf9833de77b39106c494cf999da328dba948142 (diff) |
[routing] Using maxspeed only in car model.
Diffstat (limited to 'routing_common')
-rw-r--r-- | routing_common/car_model.cpp | 14 | ||||
-rw-r--r-- | routing_common/car_model.hpp | 1 | ||||
-rw-r--r-- | routing_common/vehicle_model.cpp | 12 |
3 files changed, 16 insertions, 11 deletions
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 <algorithm> #include <vector> 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<double>(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<double>(speedKmPH), static_cast<double>(speedKmPH)}; - } + return GetMinTypeSpeed(types, speedParams.m_inCity); return {}; } |