diff --git a/routing_common/routing_common_tests/vehicle_model_test.cpp b/routing_common/routing_common_tests/vehicle_model_test.cpp index 769ed3e24d..91c1030372 100644 --- a/routing_common/routing_common_tests/vehicle_model_test.cpp +++ b/routing_common/routing_common_tests/vehicle_model_test.cpp @@ -11,15 +11,17 @@ namespace { routing::VehicleModel::InitListT const s_testLimits = { - {{"highway", "trunk"}, 150}, - {{"highway", "primary"}, 120}, - {{"highway", "secondary"}, 80}, - {{"highway", "residential"}, 50}, + {{"highway", "trunk"}, 150, true}, + {{"highway", "primary"}, 120, true}, + {{"highway", "secondary"}, 80, true}, + {{"highway", "residential"}, 50, true}, + {{"highway", "service"}, 50, false}, }; class TestVehicleModel : public routing::VehicleModel { friend void CheckOneWay(initializer_list const & types, bool expectedValue); + friend void CheckTransitAllowed(initializer_list const & types, bool expectedValue); friend void CheckSpeed(initializer_list const & types, double expectedSpeed); public: @@ -57,6 +59,16 @@ void CheckOneWay(initializer_list const & types, bool expectedValue) TEST_EQUAL(vehicleModel.HasOneWayType(h), expectedValue, ()); } + +void CheckTransitAllowed(initializer_list const & types, bool expectedValue) +{ + TestVehicleModel vehicleModel; + feature::TypesHolder h; + for (uint32_t t : types) + h.Add(t); + + TEST_EQUAL(vehicleModel.HasTransitType(h), expectedValue, ()); +} } // namespace UNIT_TEST(VehicleModel_MaxSpeed) @@ -114,3 +126,10 @@ UNIT_TEST(VehicleModel_DifferentSpeeds) CheckSpeed({typePrimary, typeOneway, typeSecondary}, 80.0); CheckOneWay({typePrimary, typeOneway, typeSecondary}, true); } + +UNIT_TEST(VehicleModel_TransitAllowed) +{ + CheckTransitAllowed({GetType("highway", "secondary")}, true); + CheckTransitAllowed({GetType("highway", "primary")}, true); + CheckTransitAllowed({GetType("highway", "service")}, false); +} diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index 1cb1dc1d3b..b755eadade 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -114,7 +114,11 @@ bool VehicleModel::IsRoad(FeatureType const & f) const bool VehicleModel::IsTransitAllowed(FeatureType const & f) const { feature::TypesHolder const types(f); + return HasTransitType(types); +} +bool VehicleModel::HasTransitType(feature::TypesHolder const & types) const +{ for (uint32_t t : types) { uint32_t const type = ftypes::BaseChecker::PrepareToMatch(t, 2); diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index 02f1a95d34..e2c0542244 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -113,6 +113,8 @@ protected: /// may be considered as features with forward geometry. bool HasOneWayType(feature::TypesHolder const & types) const; + bool HasTransitType(feature::TypesHolder const & types) const; + double GetMinTypeSpeed(feature::TypesHolder const & types) const; double m_maxSpeedKMpH;