#include "routing_common/car_model.hpp" #include "base/macros.hpp" #include "indexer/classificator.hpp" #include using namespace std; using namespace routing; namespace { using InOutCitySpeedKMpH = VehicleModel::InOutCitySpeedKMpH; using SpeedKMpH = VehicleModel::SpeedKMpH; // See model specifics in different countries here: // https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions // See road types here: // https://wiki.openstreetmap.org/wiki/Key:highway // Speed of road features located inside and outside cities and towns polygons in km per hour. // in city out city InOutCitySpeedKMpH const kSpeedMotorwayKMpH(SpeedKMpH(115.37), SpeedKMpH(115.37)); InOutCitySpeedKMpH const kSpeedMotorwayLinkKMpH(SpeedKMpH(75.0), SpeedKMpH(75.0)); InOutCitySpeedKMpH const kSpeedTrunkKMpH(SpeedKMpH(70.0), SpeedKMpH(93.89)); InOutCitySpeedKMpH const kSpeedTrunkLinkKMpH(SpeedKMpH(50.0), SpeedKMpH(70.0)); InOutCitySpeedKMpH const kSpeedPrimaryKMpH(SpeedKMpH(65.0), SpeedKMpH(84.29)); InOutCitySpeedKMpH const kSpeedPrimaryLinkKMpH(SpeedKMpH(55.0), SpeedKMpH(60.0)); InOutCitySpeedKMpH const kSpeedSecondaryKMpH(SpeedKMpH(45.0), SpeedKMpH(72.23)); InOutCitySpeedKMpH const kSpeedSecondaryLinkKMpH(SpeedKMpH(40.0), SpeedKMpH(50.0)); InOutCitySpeedKMpH const kSpeedTertiaryKMpH(SpeedKMpH(40.0), SpeedKMpH(62.63)); InOutCitySpeedKMpH const kSpeedTertiaryLinkKMpH(SpeedKMpH(30.0), SpeedKMpH(30.0)); InOutCitySpeedKMpH const kSpeedResidentialKMpH(SpeedKMpH(25.0), SpeedKMpH(25.0)); InOutCitySpeedKMpH const kSpeedUnclassifiedKMpH(SpeedKMpH(25.0), SpeedKMpH(51.09)); InOutCitySpeedKMpH const kSpeedServiceKMpH(SpeedKMpH(15.0), SpeedKMpH(15.0)); InOutCitySpeedKMpH const kSpeedLivingStreetKMpH(SpeedKMpH(10.0), SpeedKMpH(10.0)); InOutCitySpeedKMpH const kSpeedRoadKMpH(SpeedKMpH(10.0), SpeedKMpH(10.0)); InOutCitySpeedKMpH const kSpeedTrackKMpH(SpeedKMpH(5.0), SpeedKMpH(5.0)); InOutCitySpeedKMpH const kSpeedFerryMotorcarKMpH(SpeedKMpH(15.0), SpeedKMpH(15.0)); InOutCitySpeedKMpH const kSpeedFerryMotorcarVehicleKMpH(SpeedKMpH(15.0), SpeedKMpH(15.0)); InOutCitySpeedKMpH const kSpeedRailMotorcarVehicleKMpH(SpeedKMpH(15.0), SpeedKMpH(15.0)); InOutCitySpeedKMpH const kSpeedShuttleTrainKMpH(SpeedKMpH(25.0), SpeedKMpH(25.0)); InOutCitySpeedKMpH const kSpeedPierKMpH(SpeedKMpH(10.0), SpeedKMpH(10.0)); double constexpr kSpeedOffroadKMpH = 10.0; VehicleModel::LimitsInitList const g_carLimitsDefault = { // {{roadType, roadType} Speed km per hour passThroughAllowed} {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, {{"highway", "primary"}, kSpeedPrimaryKMpH, true}, {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true}, {{"highway", "secondary"}, kSpeedSecondaryKMpH, true}, {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true}, {{"highway", "tertiary"}, kSpeedTertiaryKMpH, true}, {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true}, {{"highway", "residential"}, kSpeedResidentialKMpH, true}, {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true}, {{"highway", "service"}, kSpeedServiceKMpH, true}, {{"highway", "living_street"}, kSpeedLivingStreetKMpH, true}, {{"highway", "road"}, kSpeedRoadKMpH, true}, {{"highway", "track"}, kSpeedTrackKMpH, true} /// @todo: Add to classificator //{ {"highway", "shuttle_train"}, 10 }, //{ {"highway", "ferry"}, 5 }, //{ {"highway", "default"}, 10 }, /// @todo: Check type //{ {"highway", "construction"}, 40 }, }; VehicleModel::LimitsInitList const g_carLimitsNoPassThroughLivingStreet = { {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, {{"highway", "primary"}, kSpeedPrimaryKMpH, true}, {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true}, {{"highway", "secondary"}, kSpeedSecondaryKMpH, true}, {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true}, {{"highway", "tertiary"}, kSpeedTertiaryKMpH, true}, {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true}, {{"highway", "residential"}, kSpeedResidentialKMpH, true}, {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true}, {{"highway", "service"}, kSpeedServiceKMpH, true}, {{"highway", "living_street"}, kSpeedLivingStreetKMpH, false}, {{"highway", "road"}, kSpeedRoadKMpH, true}, {{"highway", "track"}, kSpeedTrackKMpH, true} }; VehicleModel::LimitsInitList const g_carLimitsNoPassThroughLivingStreetAndService = { {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, {{"highway", "primary"}, kSpeedPrimaryKMpH, true}, {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true}, {{"highway", "secondary"}, kSpeedSecondaryKMpH, true}, {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true}, {{"highway", "tertiary"}, kSpeedTertiaryKMpH, true}, {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true}, {{"highway", "residential"}, kSpeedResidentialKMpH, true}, {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true}, {{"highway", "service"}, kSpeedServiceKMpH, false}, {{"highway", "living_street"}, kSpeedLivingStreetKMpH, false}, {{"highway", "road"}, kSpeedRoadKMpH, true}, {{"highway", "track"}, kSpeedTrackKMpH, true} }; VehicleModel::LimitsInitList const g_carLimitsAustralia = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsAustria = g_carLimitsNoPassThroughLivingStreet; VehicleModel::LimitsInitList const g_carLimitsBelarus = g_carLimitsNoPassThroughLivingStreet; VehicleModel::LimitsInitList const g_carLimitsBelgium = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsBrazil = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsDenmark = { // No track {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, {{"highway", "primary"}, kSpeedPrimaryKMpH, true}, {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true}, {{"highway", "secondary"}, kSpeedSecondaryKMpH, true}, {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true}, {{"highway", "tertiary"}, kSpeedTertiaryKMpH, true}, {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true}, {{"highway", "residential"}, kSpeedResidentialKMpH, true}, {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true}, {{"highway", "service"}, kSpeedServiceKMpH, true}, {{"highway", "living_street"}, kSpeedLivingStreetKMpH, true}, {{"highway", "road"}, kSpeedRoadKMpH, true} }; VehicleModel::LimitsInitList const g_carLimitsFrance = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsFinland = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsGermany = { // No pass through track {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, {{"highway", "primary"}, kSpeedPrimaryKMpH, true}, {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true}, {{"highway", "secondary"}, kSpeedSecondaryKMpH, true}, {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true}, {{"highway", "tertiary"}, kSpeedTertiaryKMpH, true}, {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true}, {{"highway", "residential"}, kSpeedResidentialKMpH, true}, {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true}, {{"highway", "service"}, kSpeedServiceKMpH, true}, {{"highway", "living_street"}, kSpeedLivingStreetKMpH, true}, {{"highway", "road"}, kSpeedRoadKMpH, true}, {{"highway", "track"}, kSpeedTrackKMpH, false} }; VehicleModel::LimitsInitList const g_carLimitsHungary = g_carLimitsNoPassThroughLivingStreet; VehicleModel::LimitsInitList const g_carLimitsIceland = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsNetherlands = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsNorway = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsOman = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsPoland = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsRomania = g_carLimitsNoPassThroughLivingStreet; VehicleModel::LimitsInitList const g_carLimitsRussia = g_carLimitsNoPassThroughLivingStreetAndService; VehicleModel::LimitsInitList const g_carLimitsSlovakia = g_carLimitsNoPassThroughLivingStreet; VehicleModel::LimitsInitList const g_carLimitsSpain = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsSwitzerland = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsTurkey = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsUkraine = g_carLimitsNoPassThroughLivingStreetAndService; VehicleModel::LimitsInitList const g_carLimitsUK = g_carLimitsDefault; VehicleModel::LimitsInitList const g_carLimitsUS = g_carLimitsDefault; vector const kAdditionalTags = { // {{highway tags}, {weightSpeed, etaSpeed}} {{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH}, {{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH}, {{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH}, {{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH}, {{"route", "ferry"}, kSpeedFerryMotorcarKMpH}, {{"man_made", "pier"}, kSpeedPierKMpH} }; VehicleModel::SurfaceInitList const g_carSurface = { // {{surfaceType, surfaceType}, {weightFactor, etaFactor}} {{"psurface", "paved_good"}, {1.0, 1.0}}, {{"psurface", "paved_bad"}, {0.5, 0.5}}, {{"psurface", "unpaved_good"}, {0.8, 0.8}}, {{"psurface", "unpaved_bad"}, {0.3, 0.3}} }; } // namespace namespace routing { CarModel::CarModel() : VehicleModel(classif(), g_carLimitsDefault, g_carSurface) { InitAdditionalRoadTypes(); } CarModel::CarModel(VehicleModel::LimitsInitList const & roadLimits) : VehicleModel(classif(), roadLimits, g_carSurface) { InitAdditionalRoadTypes(); } double CarModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; } void CarModel::InitAdditionalRoadTypes() { SetAdditionalRoadTypes(classif(), kAdditionalTags); } // static CarModel const & CarModel::AllLimitsInstance() { static CarModel const instance; return instance; } // static routing::VehicleModel::LimitsInitList const & CarModel::GetLimits() { return g_carLimitsDefault; } // static vector const & CarModel::GetAdditionalTags() { return kAdditionalTags; } CarModelFactory::CarModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn) : VehicleModelFactory(countryParentNameGetterFn) { // Names must be the same with country names from countries.txt m_models[""] = make_shared(g_carLimitsDefault); m_models["Australia"] = make_shared(g_carLimitsAustralia); m_models["Austria"] = make_shared(g_carLimitsAustria); m_models["Belarus"] = make_shared(g_carLimitsBelarus); m_models["Belgium"] = make_shared(g_carLimitsBelgium); m_models["Brazil"] = make_shared(g_carLimitsBrazil); m_models["Denmark"] = make_shared(g_carLimitsDenmark); m_models["France"] = make_shared(g_carLimitsFrance); m_models["Finland"] = make_shared(g_carLimitsFinland); m_models["Germany"] = make_shared(g_carLimitsGermany); m_models["Hungary"] = make_shared(g_carLimitsHungary); m_models["Iceland"] = make_shared(g_carLimitsIceland); m_models["Netherlands"] = make_shared(g_carLimitsNetherlands); m_models["Norway"] = make_shared(g_carLimitsNorway); m_models["Oman"] = make_shared(g_carLimitsOman); m_models["Poland"] = make_shared(g_carLimitsPoland); m_models["Romania"] = make_shared(g_carLimitsRomania); m_models["Russian Federation"] = make_shared(g_carLimitsRussia); m_models["Slovakia"] = make_shared(g_carLimitsSlovakia); m_models["Spain"] = make_shared(g_carLimitsSpain); m_models["Switzerland"] = make_shared(g_carLimitsSwitzerland); m_models["Turkey"] = make_shared(g_carLimitsTurkey); m_models["Ukraine"] = make_shared(g_carLimitsUkraine); m_models["United Kingdom"] = make_shared(g_carLimitsUK); m_models["United States of America"] = make_shared(g_carLimitsUS); } } // namespace routing