diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2018-09-19 20:30:41 +0300 |
---|---|---|
committer | Vlad Mihaylenko <vxmihaylenko@gmail.com> | 2018-09-20 18:05:43 +0300 |
commit | 0bdf41c8281849363c173519c44c8d517d83f5fe (patch) | |
tree | 597950e56851d50ab4374a3b515d34ed5f301b3d /routing_common | |
parent | 5767b1f71c3ff1890f24d35da77d6e81ed3eb780 (diff) |
Review fixes.
Diffstat (limited to 'routing_common')
-rw-r--r-- | routing_common/pedestrian_model.cpp | 2 | ||||
-rw-r--r-- | routing_common/routing_common_tests/vehicle_model_test.cpp | 5 | ||||
-rw-r--r-- | routing_common/vehicle_model.cpp | 18 | ||||
-rw-r--r-- | routing_common/vehicle_model.hpp | 9 |
4 files changed, 12 insertions, 22 deletions
diff --git a/routing_common/pedestrian_model.cpp b/routing_common/pedestrian_model.cpp index 63c70697d7..c8fa6a3ebe 100644 --- a/routing_common/pedestrian_model.cpp +++ b/routing_common/pedestrian_model.cpp @@ -49,7 +49,7 @@ InOutCitySpeedKMpH const kSpeedBridlewayKMpH(SpeedKMpH(1.0), SpeedKMpH(1.0)); InOutCitySpeedKMpH const kSpeedCyclewayKMpH(SpeedKMpH(4.0), SpeedKMpH(4.0)); InOutCitySpeedKMpH const kSpeedResidentialKMpH(SpeedKMpH(4.5), SpeedKMpH(4.5)); InOutCitySpeedKMpH const kSpeedLivingStreetKMpH(SpeedKMpH(5.0), SpeedKMpH(5.0)); -InOutCitySpeedKMpH const kSpeedStepsKMpH(SpeedKMpH(4.9), SpeedKMpH(4.9)); +InOutCitySpeedKMpH const kSpeedStepsKMpH(SpeedKMpH(3.0), SpeedKMpH(3.0)); InOutCitySpeedKMpH const kSpeedPedestrianKMpH(SpeedKMpH(5.0), SpeedKMpH(5.0)); InOutCitySpeedKMpH const kSpeedFootwayKMpH(SpeedKMpH(5.0), SpeedKMpH(5.0)); InOutCitySpeedKMpH const kSpeedPlatformKMpH(SpeedKMpH(5.0), SpeedKMpH(5.0)); diff --git a/routing_common/routing_common_tests/vehicle_model_test.cpp b/routing_common/routing_common_tests/vehicle_model_test.cpp index 4901349786..0a7d4c6633 100644 --- a/routing_common/routing_common_tests/vehicle_model_test.cpp +++ b/routing_common/routing_common_tests/vehicle_model_test.cpp @@ -94,10 +94,7 @@ void CheckPassThroughAllowed(initializer_list<uint32_t> const & types, bool expe UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_MaxSpeed) { TestVehicleModel vehicleModel; - TEST_EQUAL(vehicleModel.GetMaxSpeed().m_inCity.m_weight, 100, ()); - TEST_EQUAL(vehicleModel.GetMaxSpeed().m_inCity.m_eta, 100, ()); - TEST_EQUAL(vehicleModel.GetMaxSpeed().m_outCity.m_weight, 150, ()); - TEST_EQUAL(vehicleModel.GetMaxSpeed().m_outCity.m_eta, 150, ()); + TEST_EQUAL(vehicleModel.GetMaxWeightSpeed(), 150.0, ()); } UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_Speed) diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index 62d57f5d86..4ebb3c8943 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -94,14 +94,20 @@ VehicleModel::SpeedKMpH VehicleModel::GetSpeed(FeatureType & f, bool inCity) con 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 ? GetMaxSpeed().m_inCity : GetMaxSpeed().m_outCity; + return inCity ? m_maxSpeed.m_inCity : m_maxSpeed.m_outCity; if (restriction != RoadAvailability::NotAvailable && HasRoadType(types)) return GetMinTypeSpeed(types, inCity); return {}; } +double VehicleModel::GetMaxWeightSpeed() const +{ + return max(m_maxSpeed.m_inCity.m_weight, m_maxSpeed.m_outCity.m_weight); +} + VehicleModel::SpeedKMpH VehicleModel::GetMinTypeSpeed(feature::TypesHolder const & types, bool inCity) const { double const maxSpeedWeight = inCity ? m_maxSpeed.m_inCity.m_weight : m_maxSpeed.m_outCity.m_weight; @@ -265,16 +271,6 @@ double GetMaxWeight(VehicleModel::InOutCitySpeedKMpH const & speed) return max(speed.m_inCity.m_weight, speed.m_outCity.m_weight); } -double GetMaxEta(VehicleModel::InOutCitySpeedKMpH const & speed) -{ - return max(speed.m_inCity.m_eta, speed.m_outCity.m_eta); -} - -VehicleModel::SpeedKMpH GetMax(VehicleModel::InOutCitySpeedKMpH const & speed) -{ - return {GetMaxWeight(speed), GetMaxEta(speed)}; -} - string DebugPrint(VehicleModelInterface::RoadAvailability const l) { switch (l) diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index f9f31afc5f..6e9dfeef90 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -71,10 +71,10 @@ 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. - // @TODO(bykoianko) A param if feature in city or not should be added. + /// @param inCity is true if |f| lies in a city of town. virtual SpeedKMpH GetSpeed(FeatureType & f, bool inCity) const = 0; - virtual InOutCitySpeedKMpH GetMaxSpeed() const = 0; + virtual double GetMaxWeightSpeed() const = 0; /// @return Offroad speed in KMpH for vehicle. This speed should be used for non-feature routing /// e.g. to connect start point to nearest feature. @@ -159,7 +159,7 @@ public: /// VehicleModelInterface overrides: SpeedKMpH GetSpeed(FeatureType & f, bool inCity) const override; - InOutCitySpeedKMpH GetMaxSpeed() const override { return m_maxSpeed; } + double GetMaxWeightSpeed() const override; bool IsOneWay(FeatureType & f) const override; bool IsRoad(FeatureType & f) const override; bool IsPassThroughAllowed(FeatureType & f) const override; @@ -275,9 +275,6 @@ protected: CountryParentNameGetterFn m_countryParentNameGetterFn; }; -VehicleModel::SpeedKMpH GetMax(VehicleModel::InOutCitySpeedKMpH const & speed); -double GetMaxWeight(VehicleModel::InOutCitySpeedKMpH const & speed); - std::string DebugPrint(VehicleModelInterface::RoadAvailability const l); std::string DebugPrint(VehicleModelInterface::SpeedKMpH const & speed); std::string DebugPrint(VehicleModelInterface::InOutCitySpeedKMpH const & speed); |