From 277b635d733a871dd2f80f9ae3f4754152c073a0 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 9 Aug 2016 14:52:35 +0300 Subject: Review fixes. --- routing/bicycle_model.cpp | 7 +++-- routing/car_model.cpp | 66 +++++++++++++++++++++++++++++--------------- routing/pedestrian_model.cpp | 7 +++-- routing/vehicle_model.cpp | 25 ++++++++--------- routing/vehicle_model.hpp | 15 +++++----- 5 files changed, 72 insertions(+), 48 deletions(-) (limited to 'routing') diff --git a/routing/bicycle_model.cpp b/routing/bicycle_model.cpp index 0761ac44c0..d1540f3b21 100644 --- a/routing/bicycle_model.cpp +++ b/routing/bicycle_model.cpp @@ -47,6 +47,7 @@ double constexpr kSpeedStepsKMpH = 1.0; double constexpr kSpeedPedestrianKMpH = 5.0; double constexpr kSpeedFootwayKMpH = 7.0; double constexpr kSpeedPlatformKMpH = 3.0; +double constexpr kSpeedPierKMpH = 7.0; // Default routing::VehicleModel::InitListT const g_bicycleLimitsDefault = @@ -607,8 +608,10 @@ void BicycleModel::Init() m_noBicycleType = classif().GetTypeByPath({"hwtag", "nobicycle"}); m_bidirBicycleType = classif().GetTypeByPath({"hwtag", "bidir_bicycle"}); - vector additionalTags = { - { hwtagYesBicycle, m_maxSpeedKMpH }, {{"route", "ferry"}, m_maxSpeedKMpH}, {{"man_made", "pier"}, 7.0 }, + vector const additionalTags = { + {hwtagYesBicycle, m_maxSpeedKMpH}, + {{"route", "ferry"}, m_maxSpeedKMpH}, + {{"man_made", "pier"}, kSpeedPierKMpH}, }; SetAdditionalRoadTypes(classif(), additionalTags); diff --git a/routing/car_model.cpp b/routing/car_model.cpp index 9b743d37ba..5bd2350359 100644 --- a/routing/car_model.cpp +++ b/routing/car_model.cpp @@ -8,26 +8,47 @@ namespace { +double constexpr kSpeedMotorwayKMpH = 90.0; +double constexpr kSpeedMotorwayLinkKMpH = 75.0; +double constexpr kSpeedTrunkKMpH = 85.0; +double constexpr kSpeedTrunkLinkKMpH = 70.0; +double constexpr kSpeedPrimaryKMpH = 65.0; +double constexpr kSpeedPrimaryLinkKMpH = 60.0; +double constexpr kSpeedSecondaryKMpH = 55.0; +double constexpr kSpeedSecondaryLinkKMpH = 50.0; +double constexpr kSpeedTertiaryKMpH = 40.0; +double constexpr kSpeedTertiaryLinkKMpH = 30.0; +double constexpr kSpeedResidentialKMpH = 25.0; +double constexpr kSpeedPedestrianKMpH = 25.0; +double constexpr kSpeedUnclassifiedKMpH = 25.0; +double constexpr kSpeedServiceKMpH = 15.0; +double constexpr kSpeedLivingStreetKMpH = 10.0; +double constexpr kSpeedRoadKMpH = 10.0; +double constexpr kSpeedTrackKMpH = 5.0; +double constexpr kSpeedFerryMotorcarKMpH = 15.0; +double constexpr kSpeedFerryMotorcarVehicleKMpH = 15.0; +double constexpr kSpeedRailMotorcarVehicleKMpH = 25.0; +double constexpr kSpeedShuttleTrainKMpH = 25.0; routing::VehicleModel::InitListT const s_carLimits = { - { {"highway", "motorway"}, 90 }, - { {"highway", "trunk"}, 85 }, - { {"highway", "motorway_link"}, 75 }, - { {"highway", "trunk_link"}, 70 }, - { {"highway", "primary"}, 65 }, - { {"highway", "primary_link"}, 60 }, - { {"highway", "secondary"}, 55 }, - { {"highway", "secondary_link"}, 50 }, - { {"highway", "tertiary"}, 40 }, - { {"highway", "tertiary_link"}, 30 }, - { {"highway", "residential"}, 25 }, - { {"highway", "pedestrian"}, 25 }, - { {"highway", "unclassified"}, 25 }, - { {"highway", "service"}, 15 }, - { {"highway", "living_street"}, 10 }, - { {"highway", "road"}, 10 }, - { {"highway", "track"}, 5 }, + { {"highway", "motorway"}, kSpeedMotorwayKMpH }, + { {"highway", "trunk"}, kSpeedTrunkKMpH }, + { {"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH }, + { {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH }, + { {"highway", "primary"}, kSpeedPrimaryKMpH }, + { {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH }, + { {"highway", "secondary"}, kSpeedSecondaryKMpH }, + { {"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH }, + { {"highway", "tertiary"}, kSpeedTertiaryKMpH }, + { {"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH }, + { {"highway", "residential"}, kSpeedResidentialKMpH }, + { {"highway", "pedestrian"}, kSpeedPedestrianKMpH }, + { {"highway", "unclassified"}, kSpeedUnclassifiedKMpH }, + { {"highway", "service"}, kSpeedServiceKMpH }, + { {"highway", "living_street"}, kSpeedLivingStreetKMpH }, + { {"highway", "road"}, kSpeedRoadKMpH }, + { {"highway", "track"}, kSpeedTrackKMpH }, /// @todo: Add to classificator //{ {"highway", "shuttle_train"}, 10 }, //{ {"highway", "ferry"}, 5 }, @@ -44,12 +65,11 @@ namespace routing CarModel::CarModel() : VehicleModel(classif(), s_carLimits) { - vector additionalTags = - { - {{ "route", "ferry", "motorcar" }, 15.0 }, - {{ "route", "ferry", "motor_vehicle" }, 15.0 }, - {{ "railway", "rail", "motor_vehicle" }, 40.0 }, - {{ "route", "shuttle_train"}, 40.0 }, + vector const additionalTags = { + {{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH}, + {{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH}, + {{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH}, + {{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH}, }; SetAdditionalRoadTypes(classif(), additionalTags); diff --git a/routing/pedestrian_model.cpp b/routing/pedestrian_model.cpp index a70576c3b7..275d19d772 100644 --- a/routing/pedestrian_model.cpp +++ b/routing/pedestrian_model.cpp @@ -47,6 +47,7 @@ double constexpr kSpeedStepsKMpH = 4.9; double constexpr kSpeedPedestrianKMpH = 5.0; double constexpr kSpeedFootwayKMpH = 5.0; double constexpr kSpeedPlatformKMpH = 5.0; +double constexpr kSpeedPierKMpH = 4.0; // Default routing::VehicleModel::InitListT const g_pedestrianLimitsDefault = @@ -626,8 +627,10 @@ void PedestrianModel::Init() m_noFootType = classif().GetTypeByPath({ "hwtag", "nofoot" }); m_yesFootType = classif().GetTypeByPath(hwtagYesFoot); - vector additionalTags = { - { hwtagYesFoot, m_maxSpeedKMpH }, {{"route", "ferry"}, m_maxSpeedKMpH }, {{"man_made", "pier"}, 4.0 }, + vector const additionalTags = { + {hwtagYesFoot, m_maxSpeedKMpH}, + {{"route", "ferry"}, m_maxSpeedKMpH}, + {{"man_made", "pier"}, kSpeedPierKMpH}, }; SetAdditionalRoadTypes(classif(), additionalTags); diff --git a/routing/vehicle_model.cpp b/routing/vehicle_model.cpp index 8a582e4e6b..efa0b982c4 100644 --- a/routing/vehicle_model.cpp +++ b/routing/vehicle_model.cpp @@ -7,14 +7,14 @@ #include "base/macros.hpp" #include "std/algorithm.hpp" -#include "std/limits.hpp" #include "std/initializer_list.hpp" +#include "std/limits.hpp" namespace routing { - -VehicleModel::AdditionalRoadTypes::AdditionalRoadTypes(Classificator const & c, AdditionalRoadTags const & tag) - : m_type(c.GetTypeByPath(tag.m_hwtag)), m_speedKmPerH(tag.m_speedKmPerH) +VehicleModel::AdditionalRoadType::AdditionalRoadType(Classificator const & c, + AdditionalRoadTags const & tag) + : m_type(c.GetTypeByPath(tag.m_hwtag)), m_speedKMpH(tag.m_speedKMpH) { } @@ -35,7 +35,7 @@ void VehicleModel::SetAdditionalRoadTypes(Classificator const & c, for (auto const & tag : additionalTags) { m_addRoadTypes.emplace_back(c, tag); - m_maxSpeedKMpH = max(m_maxSpeedKMpH, tag.m_speedKmPerH); + m_maxSpeedKMpH = max(m_maxSpeedKMpH, tag.m_speedKMpH); } } @@ -49,8 +49,7 @@ double VehicleModel::GetSpeed(FeatureType const & f) const if (restriction != RoadAvailability::NotAvailable && HasRoadType(types)) return GetMinTypeSpeed(types); - LOG(LERROR, ("Wrong routing types:", types)); - return 0.5 /* Small speed to prevent routing along this edge. */; + return 0.0 /* Speed */; } double VehicleModel::GetMinTypeSpeed(feature::TypesHolder const & types) const @@ -64,14 +63,13 @@ double VehicleModel::GetMinTypeSpeed(feature::TypesHolder const & types) const speed = min(speed, it->second); auto const addRoadInfoIter = GetRoadTypeIter(type); - if (addRoadInfoIter!= m_addRoadTypes.end()) - speed = min(speed, addRoadInfoIter->m_speedKmPerH); + if (addRoadInfoIter != m_addRoadTypes.end()) + speed = min(speed, addRoadInfoIter->m_speedKMpH); } if (speed <= m_maxSpeedKMpH) return speed; - LOG(LERROR, ("Wrong routing types:", types)); - return 0.5 /* Small speed to prevent routing along this edge. */; + return 0.0 /* Speed */; } bool VehicleModel::IsOneWay(FeatureType const & f) const @@ -107,10 +105,11 @@ IVehicleModel::RoadAvailability VehicleModel::GetRoadAvailability(feature::Types return RoadAvailability::Unknown; } -vector::const_iterator VehicleModel::GetRoadTypeIter(uint32_t type) const +vector::const_iterator VehicleModel::GetRoadTypeIter( + uint32_t type) const { return find_if(m_addRoadTypes.begin(), m_addRoadTypes.end(), - [&type](AdditionalRoadTypes const & t){ return t.m_type == type;}); + [&type](AdditionalRoadType const & t) { return t.m_type == type; }); } string DebugPrint(IVehicleModel::RoadAvailability const l) diff --git a/routing/vehicle_model.hpp b/routing/vehicle_model.hpp index b45f8dd14b..cd9f4cc153 100644 --- a/routing/vehicle_model.hpp +++ b/routing/vehicle_model.hpp @@ -92,7 +92,7 @@ protected: struct AdditionalRoadTags { initializer_list m_hwtag; - double m_speedKmPerH; + double m_speedKMpH; }; /// @returns a special restriction which is set to the feature. @@ -114,21 +114,20 @@ protected: double m_maxSpeedKMpH; private: - struct AdditionalRoadTypes + struct AdditionalRoadType { - AdditionalRoadTypes(Classificator const & c, AdditionalRoadTags const & tag); - - bool operator==(AdditionalRoadTypes const & rhs) const { return m_type == rhs.m_type; } + AdditionalRoadType(Classificator const & c, AdditionalRoadTags const & tag); + bool operator==(AdditionalRoadType const & rhs) const { return m_type == rhs.m_type; } uint32_t const m_type; - double const m_speedKmPerH; + double const m_speedKMpH; }; - vector::const_iterator GetRoadTypeIter(uint32_t type) const; + vector::const_iterator GetRoadTypeIter(uint32_t type) const; unordered_map m_types; - vector m_addRoadTypes; + vector m_addRoadTypes; uint32_t m_onewayType; }; -- cgit v1.2.3