From 0e113f4388eecdfb4ada253edfd0b8f4c21d4cbc Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 16 Jun 2016 17:46:41 +0300 Subject: [PATCH] Review fixes. --- routing/bicycle_model.hpp | 2 +- routing/pedestrian_model.cpp | 6 +++--- routing/vehicle_model.cpp | 22 ++++++++++++++++++---- routing/vehicle_model.hpp | 18 +++++++++--------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/routing/bicycle_model.hpp b/routing/bicycle_model.hpp index 1008fe07bd..85820d4344 100644 --- a/routing/bicycle_model.hpp +++ b/routing/bicycle_model.hpp @@ -23,7 +23,7 @@ protected: private: void Init(); - /// @return true if it is allowed to ride bicycle in two directions. + /// @return true if it is allowed to ride a bicycle in both directions. bool IsBicycleBidir(feature::TypesHolder const & types) const; uint32_t m_noBicycleType = 0; diff --git a/routing/pedestrian_model.cpp b/routing/pedestrian_model.cpp index 510568432f..678a4064d9 100644 --- a/routing/pedestrian_model.cpp +++ b/routing/pedestrian_model.cpp @@ -621,13 +621,13 @@ PedestrianModel::PedestrianModel(VehicleModel::InitListT const & speedLimits) void PedestrianModel::Init() { - initializer_list hwtagYesfoot = {"hwtag", "yesfoot"}; + initializer_list hwtagYesFoot = {"hwtag", "yesfoot"}; m_noFootType = classif().GetTypeByPath({ "hwtag", "nofoot" }); - m_yesFootType = classif().GetTypeByPath(hwtagYesfoot); + m_yesFootType = classif().GetTypeByPath(hwtagYesFoot); initializer_list arr[] = { - hwtagYesfoot, {"route", "ferry"}, {"man_made", "pier"}, + hwtagYesFoot, {"route", "ferry"}, {"man_made", "pier"}, }; SetAdditionalRoadTypes(classif(), arr, ARRAY_SIZE(arr)); diff --git a/routing/vehicle_model.cpp b/routing/vehicle_model.cpp index 79a94d835e..3ff16732d8 100644 --- a/routing/vehicle_model.cpp +++ b/routing/vehicle_model.cpp @@ -12,7 +12,7 @@ namespace routing { -VehicleModel::VehicleModel(Classificator const & c, VehicleModel::InitListT const & speedLimits) +VehicleModel::VehicleModel(Classificator const & c, InitListT const & speedLimits) : m_maxSpeedKMpH(0), m_onewayType(c.GetTypeByPath({ "hwtag", "oneway" })) { @@ -36,9 +36,9 @@ double VehicleModel::GetSpeed(FeatureType const & f) const RoadAvailability const restriction = GetRoadAvailability(types); if (restriction == RoadAvailability::Available) - return VehicleModel::GetMaxSpeed(); + return GetMaxSpeed(); if (restriction != RoadAvailability::NotAvailable && HasRoadType(types)) - return VehicleModel::GetMinTypeSpeed(types); + return GetMinTypeSpeed(types); return 0.0; } @@ -78,7 +78,7 @@ bool VehicleModel::IsRoad(FeatureType const & f) const if (GetRoadAvailability(types) == RoadAvailability::NotAvailable) return false; - return VehicleModel::HasRoadType(types); + return HasRoadType(types); } bool VehicleModel::IsRoadType(uint32_t type) const @@ -91,4 +91,18 @@ IVehicleModel::RoadAvailability VehicleModel::GetRoadAvailability(feature::Types { return RoadAvailability::Unknown; } + +string DebugPrint(IVehicleModel::RoadAvailability const l) +{ + switch (l) + { + case IVehicleModel::RoadAvailability::Available: return "Available"; + case IVehicleModel::RoadAvailability::NotAvailable: return "NotAvailable"; + case IVehicleModel::RoadAvailability::Unknown: return "Unknown"; + } + + stringstream out; + out << "Unknown IVehicleModel::RoadAvailability (" << static_cast(l) << ")"; + return out.str(); +} } // namespace routing diff --git a/routing/vehicle_model.hpp b/routing/vehicle_model.hpp index a052c6e65f..b16bf32edf 100644 --- a/routing/vehicle_model.hpp +++ b/routing/vehicle_model.hpp @@ -37,8 +37,7 @@ public: virtual bool IsOneWay(FeatureType const & f) const = 0; - /// @returns true if feature |f| can be used for routing with corresponding vehicle model - /// and returns false otherwise. + /// @returns true iff feature |f| can be used for routing with corresponding vehicle model. virtual bool IsRoad(FeatureType const & f) const = 0; }; @@ -74,14 +73,11 @@ public: bool IsOneWay(FeatureType const & f) const override; bool IsRoad(FeatureType const & f) const override; -protected: - /// @returns a special restriction which is set to the feature. - virtual RoadAvailability GetRoadAvailability(feature::TypesHolder const & types) const; - public: /// @returns true if |m_types| or |m_addRoadTypes| contains |type| and false otherwise. bool IsRoadType(uint32_t type) const; + template bool HasRoadType(TList const & types) const { @@ -94,15 +90,18 @@ public: } protected: + /// @returns a special restriction which is set to the feature. + virtual RoadAvailability GetRoadAvailability(feature::TypesHolder const & types) const; + /// Used in derived class constructors only. Not for public use. void SetAdditionalRoadTypes(Classificator const & c, initializer_list const * arr, size_t sz); /// \returns true if |types| is a oneway feature. - /// \note According to OSM tag "oneway" could have value "-1". That means it's a oneway feature - /// with reversed geometry. In that case while map generation the geometry of such features + /// \note According to OSM, tag "oneway" could have value "-1". That means it's a oneway feature + /// with reversed geometry. In that case at map generation the geometry of such features /// is reversed (the order of points is changed) so in vehicle model all oneway feature - /// could be considered as features with forward geometry. + /// may be considered as features with forward geometry. bool HasOneWayType(feature::TypesHolder const & types) const; double GetMinTypeSpeed(feature::TypesHolder const & types) const; @@ -116,4 +115,5 @@ private: uint32_t m_onewayType; }; +string DebugPrint(IVehicleModel::RoadAvailability const l); } // namespace routing