diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2018-11-12 18:20:49 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-11-23 17:58:49 +0300 |
commit | 63c78b71dbaa3a519d27f8a1bff10174f556cbf7 (patch) | |
tree | a94cac37f01e3a11fbbff45026759ef335d92460 /routing_common | |
parent | 1a9c5d3d09b297f1343e12172a8bd0833373a799 (diff) |
[routing] Gathering params for getting feature speed to singal struct and using it.
Diffstat (limited to 'routing_common')
-rw-r--r-- | routing_common/vehicle_model.cpp | 9 | ||||
-rw-r--r-- | routing_common/vehicle_model.hpp | 19 |
2 files changed, 17 insertions, 11 deletions
diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index d9e957d829..9dc4292a76 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -1,7 +1,5 @@ #include "routing_common/vehicle_model.hpp" -#include "routing_common/maxspeed_conversion.hpp" - #include "indexer/classificator.hpp" #include "indexer/feature.hpp" #include "indexer/ftypes_matcher.hpp" @@ -89,17 +87,16 @@ void VehicleModel::SetAdditionalRoadTypes(Classificator const & c, } } -VehicleModel::SpeedKMpH VehicleModel::GetSpeed(FeatureType & f, bool forward, bool inCity, - Maxspeed const & maxspeed) const +VehicleModel::SpeedKMpH VehicleModel::GetSpeed(FeatureType & f, SpeedParams const & speedParams) const { feature::TypesHolder const types(f); RoadAvailability const restriction = GetRoadAvailability(types); // @TODO(bykoianko) Consider using speed on feature |f| instead of using max speed below. if (restriction == RoadAvailability::Available) - return inCity ? m_maxSpeed.m_inCity : m_maxSpeed.m_outCity; + return speedParams.m_inCity ? m_maxSpeed.m_inCity : m_maxSpeed.m_outCity; if (restriction != RoadAvailability::NotAvailable && HasRoadType(types)) - return GetMinTypeSpeed(types, inCity); + return GetMinTypeSpeed(types, speedParams.m_inCity); return {}; } diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index d48c28362c..30fa221daf 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -1,5 +1,7 @@ #pragma once +#include "routing_common/maxspeed_conversion.hpp" + #include <array> #include <functional> #include <initializer_list> @@ -16,7 +18,16 @@ namespace feature { class TypesHolder; } namespace routing { -struct Maxspeed; +/// \brief Params for calcualtion of an approximate speed on a feature. +struct SpeedParams +{ + SpeedParams() = delete; + + bool m_forward; + // |m_inCity| == true if a corresponding feature lies inside a city of a town. + bool m_inCity; + Maxspeed m_maxspeed; +}; class VehicleModelInterface { @@ -75,8 +86,7 @@ public: /// @return Allowed weight and ETA speed in KMpH. /// 0 means that it's forbidden to move on this feature or it's not a road at all. /// @param inCity is true if |f| lies in a city of town. - virtual SpeedKMpH GetSpeed(FeatureType & f, bool forward, bool inCity, - Maxspeed const & maxspeed) const = 0; + virtual SpeedKMpH GetSpeed(FeatureType & f, SpeedParams const & speedParams) const = 0; virtual double GetMaxWeightSpeed() const = 0; @@ -162,8 +172,7 @@ public: SurfaceInitList const & featureTypeSurface); /// VehicleModelInterface overrides: - SpeedKMpH GetSpeed(FeatureType & f, bool forward, bool inCity, - Maxspeed const & maxspeed) const override; + SpeedKMpH GetSpeed(FeatureType & f, SpeedParams const & speedParams) const override; double GetMaxWeightSpeed() const override; bool IsOneWay(FeatureType & f) const override; bool IsRoad(FeatureType & f) const override; |