forked from organicmaps/organicmaps
[routing] Car model for all the world.
This commit is contained in:
parent
99d4d1d199
commit
43207f2a61
7 changed files with 86 additions and 260 deletions
|
@ -30,7 +30,7 @@ namespace
|
|||
|
||||
HighwayBasedFactors const kDefaultFactors{};
|
||||
|
||||
HighwayBasedMeanSpeeds const kDefaultSpeeds = {
|
||||
HighwayBasedSpeeds const kDefaultSpeeds = {
|
||||
// {highway class : InOutCitySpeedKMpH(in city(weight, eta), out city(weight eta))}
|
||||
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH(SpeedKMpH(3.0, 18.0))},
|
||||
{HighwayType::HighwayTrunkLink, InOutCitySpeedKMpH(SpeedKMpH(3.0, 18.0))},
|
||||
|
|
|
@ -20,49 +20,6 @@ namespace
|
|||
// See road types here:
|
||||
// https://wiki.openstreetmap.org/wiki/Key:highway
|
||||
|
||||
// // Names must be the same with country names from countries.txt
|
||||
std::array<char const *, 41> constexpr kCountries = {"Australia",
|
||||
"Austria",
|
||||
"Belarus",
|
||||
"Belgium",
|
||||
"Brazil",
|
||||
"Canada",
|
||||
"Colombia",
|
||||
"Czech Republic",
|
||||
"Denmark",
|
||||
"Ecuador",
|
||||
"Finland",
|
||||
"France",
|
||||
"Germany",
|
||||
"Hungary",
|
||||
"Indonesia",
|
||||
"Ireland",
|
||||
"Italy",
|
||||
"Kuwait",
|
||||
"Luxembourg",
|
||||
"Mexico",
|
||||
"Netherlands",
|
||||
"New Zealand",
|
||||
"Norway",
|
||||
"Poland",
|
||||
"Portugal",
|
||||
"Romania",
|
||||
"Russian Federation",
|
||||
"Saudi Arabia",
|
||||
"Singapore",
|
||||
"Slovakia",
|
||||
"South Africa",
|
||||
"Spain",
|
||||
"Sweden",
|
||||
"Switzerland",
|
||||
"Thailand",
|
||||
"Turkey",
|
||||
"Ukraine",
|
||||
"United Arab Emirates",
|
||||
"United Kingdom",
|
||||
"United States of America",
|
||||
"Venezuela"};
|
||||
|
||||
// |kSpeedOffroadKMpH| is a speed which is used for edges that don't lie on road features.
|
||||
// For example for pure fake edges. In car routing, off road speed for calculation ETA is not used.
|
||||
// The weight of such edges is considered as 0 seconds. It's especially actual when an airport is
|
||||
|
@ -172,12 +129,12 @@ VehicleModel::LimitsInitList const kCarOptionsGermany = {
|
|||
|
||||
vector<VehicleModel::AdditionalRoadTags> const kAdditionalTags = {
|
||||
// {{highway tags}, {weightSpeed, etaSpeed}}
|
||||
{{"route", "ferry", "motorcar"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::RouteFerryMotorcar)},
|
||||
{{"route", "ferry", "motor_vehicle"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::RouteFerryMotorVehicle)},
|
||||
{{"railway", "rail", "motor_vehicle"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::RailwayRailMotorVehicle)},
|
||||
{{"route", "shuttle_train"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::RouteShuttleTrain)},
|
||||
{{"route", "ferry"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::RouteFerryMotorcar)},
|
||||
{{"man_made", "pier"}, kGlobalHighwayBasedMeanSpeeds.at(HighwayType::ManMadePier)}};
|
||||
{{"route", "ferry", "motorcar"}, kHighwayBasedSpeeds.at(HighwayType::RouteFerryMotorcar)},
|
||||
{{"route", "ferry", "motor_vehicle"}, kHighwayBasedSpeeds.at(HighwayType::RouteFerryMotorVehicle)},
|
||||
{{"railway", "rail", "motor_vehicle"}, kHighwayBasedSpeeds.at(HighwayType::RailwayRailMotorVehicle)},
|
||||
{{"route", "shuttle_train"}, kHighwayBasedSpeeds.at(HighwayType::RouteShuttleTrain)},
|
||||
{{"route", "ferry"}, kHighwayBasedSpeeds.at(HighwayType::RouteFerryMotorcar)},
|
||||
{{"man_made", "pier"}, kHighwayBasedSpeeds.at(HighwayType::ManMadePier)}};
|
||||
|
||||
VehicleModel::SurfaceInitList const kCarSurface = {
|
||||
// {{surfaceType, surfaceType}, {weightFactor, etaFactor}}
|
||||
|
@ -187,6 +144,7 @@ VehicleModel::SurfaceInitList const kCarSurface = {
|
|||
{{"psurface", "unpaved_bad"}, {0.3, 0.3}}
|
||||
};
|
||||
|
||||
// Names must be the same with country names from countries.txt
|
||||
std::unordered_map<char const *, VehicleModel::LimitsInitList> const kCarOptionsByCountries = {
|
||||
{"Austria", kCarOptionsNoPassThroughLivingStreet},
|
||||
{"Belarus", kCarOptionsNoPassThroughLivingStreet},
|
||||
|
@ -204,7 +162,7 @@ namespace routing
|
|||
{
|
||||
CarModel::CarModel()
|
||||
: VehicleModel(classif(), kCarOptionsDefault, kCarSurface,
|
||||
{kGlobalHighwayBasedMeanSpeeds, kGlobalHighwayBasedFactors})
|
||||
{kHighwayBasedSpeeds, kHighwayBasedFactors})
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
@ -258,23 +216,16 @@ VehicleModel::SurfaceInitList const & CarModel::GetSurfaces() { return kCarSurfa
|
|||
CarModelFactory::CarModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn)
|
||||
: VehicleModelFactory(countryParentNameGetterFn)
|
||||
{
|
||||
auto const & speeds = kCountryToHighwayBasedMeanSpeeds;
|
||||
auto const & factors = kCountryToHighwayBasedFactors;
|
||||
m_models[""] = make_shared<CarModel>(
|
||||
kCarOptionsDefault,
|
||||
HighwayBasedInfo(kGlobalHighwayBasedMeanSpeeds, kGlobalHighwayBasedFactors));
|
||||
for (auto const * country : kCountries)
|
||||
HighwayBasedInfo(kHighwayBasedSpeeds, kHighwayBasedFactors));
|
||||
|
||||
for (auto const & kv : kCarOptionsByCountries)
|
||||
{
|
||||
auto const limitIt = kCarOptionsByCountries.find(country);
|
||||
auto const & limit = limitIt == kCarOptionsByCountries.cend() ? kCarOptionsDefault : limitIt->second;
|
||||
auto const speedIt = speeds.find(country);
|
||||
auto const & speed = speedIt == speeds.cend() ? kGlobalHighwayBasedMeanSpeeds : speedIt->second;
|
||||
auto const factorIt = factors.find(country);
|
||||
auto const & factor =
|
||||
factorIt == factors.cend() ? kGlobalHighwayBasedFactors : factorIt->second;
|
||||
m_models[country] = make_shared<CarModel>(
|
||||
limit,
|
||||
HighwayBasedInfo(speed, kGlobalHighwayBasedMeanSpeeds, factor, kGlobalHighwayBasedFactors));
|
||||
auto const * country = kv.first;
|
||||
auto const & limit = kv.second;
|
||||
m_models[country] =
|
||||
make_shared<CarModel>(limit, HighwayBasedInfo(kHighwayBasedSpeeds, kHighwayBasedFactors));
|
||||
}
|
||||
}
|
||||
} // namespace routing
|
||||
|
|
|
@ -7,102 +7,49 @@
|
|||
|
||||
namespace routing
|
||||
{
|
||||
HighwayBasedFactors const kGlobalHighwayBasedFactors = {
|
||||
{HighwayType::HighwayMotorway, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(1.0)}
|
||||
}},
|
||||
{HighwayType::HighwayTrunk, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(1.0)}
|
||||
}},
|
||||
{HighwayType::HighwayPrimary /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.95)}
|
||||
}},
|
||||
{HighwayType::HighwaySecondary /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
{HighwayType::HighwayTertiary /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.85)}
|
||||
}},
|
||||
{HighwayType::HighwayResidential /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.75)}
|
||||
}},
|
||||
{HighwayType::HighwayUnclassified /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.80)}
|
||||
}},
|
||||
{HighwayType::HighwayService /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.80)}
|
||||
}},
|
||||
{HighwayType::HighwayLivingStreet /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.75)}
|
||||
}},
|
||||
{HighwayType::HighwayRoad /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.30)}
|
||||
}},
|
||||
{HighwayType::HighwayTrack /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.30)}
|
||||
}},
|
||||
{HighwayType::HighwayTrack /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.30)}
|
||||
}},
|
||||
{HighwayType::RouteFerryMotorcar /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
{HighwayType::RouteFerryMotorVehicle /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
{HighwayType::RailwayRailMotorVehicle /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
{HighwayType::RouteShuttleTrain /* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
{HighwayType::ManMadePier/* highway class */, {
|
||||
// {maxspeed : InOutCityFactor(in city, out city)}
|
||||
{kCommonMaxSpeedValue, InOutCityFactor(0.90)}
|
||||
}},
|
||||
HighwayBasedFactors const kHighwayBasedFactors = {
|
||||
// {highway class : InOutCityFactor(in city, out city)}
|
||||
{HighwayType::HighwayLivingStreet, InOutCityFactor(0.75)},
|
||||
{HighwayType::HighwayMotorway, InOutCityFactor(0.90, 0.94)},
|
||||
{HighwayType::HighwayPrimary, InOutCityFactor(0.86, 0.89)},
|
||||
{HighwayType::HighwayResidential, InOutCityFactor(0.75)},
|
||||
{HighwayType::HighwayRoad, InOutCityFactor(0.30)},
|
||||
{HighwayType::HighwaySecondary, InOutCityFactor(0.84, 0.82)},
|
||||
{HighwayType::HighwayService, InOutCityFactor(0.80)},
|
||||
{HighwayType::HighwayTertiary, InOutCityFactor(0.82, 0.76)},
|
||||
{HighwayType::HighwayTrack, InOutCityFactor(0.30)},
|
||||
{HighwayType::HighwayTrack, InOutCityFactor(0.30)},
|
||||
{HighwayType::HighwayTrunk, InOutCityFactor(0.90, 0.91)},
|
||||
{HighwayType::HighwayTrunkLink, InOutCityFactor(0.77, 0.81)},
|
||||
{HighwayType::HighwayUnclassified, InOutCityFactor(0.80)},
|
||||
{HighwayType::ManMadePier, InOutCityFactor(0.90)}
|
||||
{HighwayType::RailwayRailMotorVehicle, InOutCityFactor(0.90)},
|
||||
{HighwayType::RouteFerryMotorcar, InOutCityFactor(0.90)},
|
||||
{HighwayType::RouteFerryMotorVehicle, InOutCityFactor(0.90)},
|
||||
{HighwayType::RouteShuttleTrain, InOutCityFactor(0.90)},
|
||||
};
|
||||
|
||||
HighwayBasedMeanSpeeds const kGlobalHighwayBasedMeanSpeeds = {
|
||||
// {highway class : InOutCitySpeedKMpH(in city, out city)}
|
||||
{HighwayType::HighwayMotorway, InOutCitySpeedKMpH({117.80, 104.70} /* in city */, {123.40, 111.79} /* out city */)},
|
||||
{HighwayType::HighwayMotorwayLink, InOutCitySpeedKMpH({106.02, 94.23} /* in city */, {111.06, 100.61} /* out city */)},
|
||||
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH({83.40, 78.55} /* in city */, {100.20, 92.55} /* out city */)},
|
||||
{HighwayType::HighwayTrunkLink, InOutCitySpeedKMpH({75.06, 70.69} /* in city */, {90.18, 83.30} /* out city */)},
|
||||
{HighwayType::HighwayPrimary, InOutCitySpeedKMpH({63.10, 58.81} /* in city */, {75.20, 69.60} /* out city */)},
|
||||
{HighwayType::HighwayPrimaryLink, InOutCitySpeedKMpH({56.79, 52.93} /* in city */, {67.68, 62.64} /* out city */)},
|
||||
{HighwayType::HighwaySecondary, InOutCitySpeedKMpH({52.80, 47.63} /* in city */, {60.30, 56.99} /* out city */)},
|
||||
{HighwayType::HighwaySecondaryLink, InOutCitySpeedKMpH({47.52, 42.87} /* in city */, {54.27, 51.29} /* out city */)},
|
||||
{HighwayType::HighwayTertiary, InOutCitySpeedKMpH({45.50, 38.86} /* in city */, {50.50, 44.14} /* out city */)},
|
||||
{HighwayType::HighwayTertiaryLink, InOutCitySpeedKMpH({40.95, 34.97} /* in city */, {45.45, 39.73} /* out city */)},
|
||||
{HighwayType::HighwayResidential, InOutCitySpeedKMpH({20.00, 20.00} /* in city */, {25.00, 25.00} /* out city */)},
|
||||
{HighwayType::HighwayUnclassified, InOutCitySpeedKMpH({30.00, 30.00} /* in city */, {40.00, 40.00} /* out city */)},
|
||||
{HighwayType::HighwayService, InOutCitySpeedKMpH({15.00, 15.00} /* in city */, {15.00, 15.00} /* out city */)},
|
||||
{HighwayType::HighwayLivingStreet, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::HighwayRoad, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::HighwayTrack, InOutCitySpeedKMpH({5.00, 5.00} /* in city */, {5.00, 5.00} /* out city */)},
|
||||
{HighwayType::RouteFerryMotorcar, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RouteFerryMotorVehicle, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RailwayRailMotorVehicle, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RouteShuttleTrain, InOutCitySpeedKMpH({25.00, 25.00} /* in city */, {25.00, 25.00} /* out city */)},
|
||||
{HighwayType::ManMadePier, InOutCitySpeedKMpH({17.00, 10.00} /* in city */, {17.00, 10.00} /* out city */)},
|
||||
HighwayBasedSpeeds const kHighwayBasedSpeeds = {
|
||||
// {highway class : InOutCitySpeedKMpH(in city, out city)}
|
||||
{HighwayType::HighwayLivingStreet, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::HighwayMotorway, InOutCitySpeedKMpH(110.00 /* in city */, 120.00 /* out city */)},
|
||||
{HighwayType::HighwayMotorwayLink, InOutCitySpeedKMpH(88.00 /* in city */, 96.00 /* out city */)},
|
||||
{HighwayType::HighwayPrimary, InOutCitySpeedKMpH(60.00 /* in city */, 90.00 /* out city */)},
|
||||
{HighwayType::HighwayPrimaryLink, InOutCitySpeedKMpH(48.00 /* in city */, 72.00 /* out city */)},
|
||||
{HighwayType::HighwayResidential, InOutCitySpeedKMpH({20.00, 20.00} /* in city */, {25.00, 25.00} /* out city */)},
|
||||
{HighwayType::HighwayRoad, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::HighwaySecondary, InOutCitySpeedKMpH(60.00 /* in city */, 70.00 /* out city */)},
|
||||
{HighwayType::HighwaySecondaryLink, InOutCitySpeedKMpH(48.00 /* in city */, 56.00 /* out city */)},
|
||||
{HighwayType::HighwayService, InOutCitySpeedKMpH({15.00, 15.00} /* in city */, {15.00, 15.00} /* out city */)},
|
||||
{HighwayType::HighwayTertiary, InOutCitySpeedKMpH(60.00 /* in city */, 50.00 /* out city */)},
|
||||
{HighwayType::HighwayTrack, InOutCitySpeedKMpH({5.00, 5.00} /* in city */, {5.00, 5.00} /* out city */)},
|
||||
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH(90.00 /* in city */, 90.00 /* out city */)},
|
||||
{HighwayType::HighwayTrunkLink, InOutCitySpeedKMpH(72.00 /* in city */, 72.00 /* out city */)},
|
||||
{HighwayType::HighwayUnclassified, InOutCitySpeedKMpH({30.00, 30.00} /* in city */, {40.00, 40.00} /* out city */)},
|
||||
{HighwayType::ManMadePier, InOutCitySpeedKMpH({17.00, 10.00} /* in city */, {17.00, 10.00} /* out city */)}
|
||||
{HighwayType::RailwayRailMotorVehicle, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RouteFerryMotorcar, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RouteFerryMotorVehicle, InOutCitySpeedKMpH({10.00, 10.00} /* in city */, {10.00, 10.00} /* out city */)},
|
||||
{HighwayType::RouteShuttleTrain, InOutCitySpeedKMpH({25.00, 25.00} /* in city */, {25.00, 25.00} /* out city */)},
|
||||
};
|
||||
|
||||
CountryToHighwayBasedFactors const kCountryToHighwayBasedFactors{};
|
||||
CountryToHighwayBasedMeanSpeeds const kCountryToHighwayBasedMeanSpeeds{};
|
||||
} // namespace routing
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace
|
|||
|
||||
HighwayBasedFactors const kDefaultFactors{};
|
||||
|
||||
HighwayBasedMeanSpeeds const kDefaultSpeeds = {
|
||||
HighwayBasedSpeeds const kDefaultSpeeds = {
|
||||
// {highway class : InOutCitySpeedKMpH(in city(weight, eta), out city(weight eta))}
|
||||
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH(SpeedKMpH(1.0, 5.0))},
|
||||
{HighwayType::HighwayTrunkLink, InOutCitySpeedKMpH(SpeedKMpH(1.0, 5.0))},
|
||||
|
|
|
@ -19,7 +19,7 @@ using namespace std;
|
|||
|
||||
namespace
|
||||
{
|
||||
HighwayBasedMeanSpeeds const kDefaultSpeeds = {
|
||||
HighwayBasedSpeeds const kDefaultSpeeds = {
|
||||
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH(100.0 /* in city */, 150.0 /* out city */)},
|
||||
{HighwayType::HighwayPrimary, InOutCitySpeedKMpH(90.0 /* in city */, 120.0 /* out city */)},
|
||||
{HighwayType::HighwaySecondary,
|
||||
|
@ -32,12 +32,9 @@ HighwayBasedMeanSpeeds const kDefaultSpeeds = {
|
|||
SpeedKMpH(50.0 /* weight */, 40.0 /* eta */) /* out city */)}};
|
||||
|
||||
HighwayBasedFactors const kDefaultFactors = {
|
||||
{HighwayType::HighwayPrimary,
|
||||
{// maxspeed : InOutCityFactor(in and out city factor value)
|
||||
{70, InOutCityFactor(1.0)},
|
||||
{90, InOutCityFactor(1.0)}}},
|
||||
{HighwayType::HighwaySecondary, {{90, InOutCityFactor(1.0)}}},
|
||||
{HighwayType::HighwayResidential, {{60, InOutCityFactor(0.5)}}}};
|
||||
{HighwayType::HighwayPrimary, InOutCityFactor(1.0)},
|
||||
{HighwayType::HighwaySecondary, InOutCityFactor(1.0)},
|
||||
{HighwayType::HighwayResidential, InOutCityFactor(0.5)}};
|
||||
|
||||
VehicleModel::LimitsInitList const kTestLimits = {{{"highway", "trunk"}, true},
|
||||
{{"highway", "primary"}, true},
|
||||
|
@ -66,8 +63,7 @@ class TestVehicleModel : public VehicleModel
|
|||
|
||||
public:
|
||||
TestVehicleModel()
|
||||
: VehicleModel(classif(), kTestLimits, kCarSurface,
|
||||
{kDefaultSpeeds, kDefaultSpeeds, kDefaultFactors, kDefaultFactors})
|
||||
: VehicleModel(classif(), kTestLimits, kCarSurface, {kDefaultSpeeds, kDefaultFactors})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,6 @@ InOutCitySpeedKMpH Max(InOutCitySpeedKMpH const & lhs, InOutCitySpeedKMpH const
|
|||
return {Pick<max>(lhs.m_inCity, rhs.m_inCity), Pick<max>(lhs.m_outCity, rhs.m_outCity)};
|
||||
}
|
||||
|
||||
MaxspeedType GetMaxspeedKey(double maxspeedValue)
|
||||
{
|
||||
return base::asserted_cast<MaxspeedType>(10 * static_cast<MaxspeedType>((maxspeedValue + 5) / 10));
|
||||
}
|
||||
|
||||
HighwayType GetHighwayTypeKey(HighwayType type)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -176,53 +171,19 @@ SpeedKMpH VehicleModel::GetSpeedOnFeatureWithMaxspeed(HighwayType const & type,
|
|||
CHECK(speedParams.m_maxspeed.IsValid(), ());
|
||||
bool const isCityRoad = speedParams.m_inCity;
|
||||
SpeedKMpH const & maxModelSpeed = m_maxModelSpeed.GetSpeed(isCityRoad);
|
||||
auto const maxspeedKmPH = static_cast<double>(speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward));
|
||||
auto const maxSpeedType = speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward);
|
||||
CHECK(maxSpeedType != kInvalidSpeed, (type, speedParams.m_forward, speedParams.m_maxspeed));
|
||||
auto const maxspeedKmPH = static_cast<double>(maxSpeedType);
|
||||
SpeedKMpH speed = Pick<min>(SpeedKMpH(maxspeedKmPH, maxspeedKmPH), maxModelSpeed);
|
||||
|
||||
// We assume that all link roads are equal to its parents and drop "_link" suffix
|
||||
// while searching for the particular factor.
|
||||
auto const maxspeedKey = GetMaxspeedKey(maxspeedKmPH);
|
||||
SpeedFactor maxspeedFactor(kInvalidModelValue, kInvalidModelValue);
|
||||
auto const typeKey = GetHighwayTypeKey(type);
|
||||
auto const local = m_highwayBasedInfo.m_localFactors.find(typeKey);
|
||||
if (local != m_highwayBasedInfo.m_localFactors.cend())
|
||||
{
|
||||
auto const & maxspeedsToFactors = local->second;
|
||||
auto const it = maxspeedsToFactors.find(maxspeedKey);
|
||||
if (it != maxspeedsToFactors.cend())
|
||||
maxspeedFactor = it->second.GetFactor(isCityRoad);
|
||||
}
|
||||
|
||||
if (maxspeedFactor.m_weight != kInvalidModelValue && maxspeedFactor.m_eta != kInvalidModelValue)
|
||||
return Pick<min>(speed * maxspeedFactor, maxModelSpeed);
|
||||
|
||||
auto const global = m_highwayBasedInfo.m_globalFactors.find(typeKey);
|
||||
if (global != m_highwayBasedInfo.m_globalFactors.cend())
|
||||
{
|
||||
auto const & maxspeedsToFactors = global->second;
|
||||
auto const it = maxspeedsToFactors.find(maxspeedKey);
|
||||
if (it != maxspeedsToFactors.cend())
|
||||
{
|
||||
auto const & factor = it->second.GetFactor(isCityRoad);
|
||||
if (factor.m_weight != kInvalidModelValue && maxspeedFactor.m_weight == kInvalidModelValue)
|
||||
maxspeedFactor.m_weight = factor.m_weight;
|
||||
|
||||
if (factor.m_eta != kInvalidModelValue && maxspeedFactor.m_weight == kInvalidModelValue)
|
||||
maxspeedFactor.m_eta = factor.m_eta;
|
||||
}
|
||||
|
||||
auto const defaultIt = maxspeedsToFactors.find(kCommonMaxSpeedValue);
|
||||
CHECK(defaultIt != maxspeedsToFactors.cend(), ());
|
||||
SpeedFactor const & defaultFactor = defaultIt->second.GetFactor(isCityRoad);
|
||||
if (maxspeedFactor.m_weight == kInvalidModelValue)
|
||||
maxspeedFactor.m_weight = defaultFactor.m_weight;
|
||||
|
||||
if (maxspeedFactor.m_eta == kInvalidModelValue)
|
||||
maxspeedFactor.m_eta = defaultFactor.m_eta;
|
||||
}
|
||||
|
||||
CHECK_NOT_EQUAL(maxspeedFactor.m_weight, kInvalidModelValue, ());
|
||||
CHECK_NOT_EQUAL(maxspeedFactor.m_eta, kInvalidModelValue, ());
|
||||
return Pick<min>(speed * maxspeedFactor, maxModelSpeed);
|
||||
auto const factorIt = m_highwayBasedInfo.m_globalFactors.find(typeKey);
|
||||
CHECK(factorIt != m_highwayBasedInfo.m_globalFactors.cend(), ("Key:", typeKey, "is not found."));
|
||||
auto const & factor = factorIt->second;
|
||||
return Pick<min>(speed * factor.GetFactor(isCityRoad), maxModelSpeed);
|
||||
}
|
||||
|
||||
SpeedKMpH VehicleModel::GetSpeedOnFeatureWithoutMaxspeed(HighwayType const & type,
|
||||
|
@ -231,25 +192,17 @@ SpeedKMpH VehicleModel::GetSpeedOnFeatureWithoutMaxspeed(HighwayType const & typ
|
|||
CHECK(!speedParams.m_maxspeed.IsValid(), ());
|
||||
auto const isCityRoad = speedParams.m_inCity;
|
||||
SpeedKMpH const & maxModelSpeed = m_maxModelSpeed.GetSpeed(isCityRoad);
|
||||
SpeedKMpH speed(kInvalidModelValue, kInvalidModelValue);
|
||||
auto const local = m_highwayBasedInfo.m_localSpeeds.find(type);
|
||||
if (local != m_highwayBasedInfo.m_localSpeeds.cend())
|
||||
speed = local->second.GetSpeed(isCityRoad);
|
||||
|
||||
if (speed.m_weight != kInvalidModelValue && speed.m_eta != kInvalidModelValue)
|
||||
return speed;
|
||||
auto const speedIt = m_highwayBasedInfo.m_globalSpeeds.find(type);
|
||||
CHECK(speedIt != m_highwayBasedInfo.m_globalSpeeds.cend(), ("Key:", type, "is not found."));
|
||||
|
||||
auto const globalIt = m_highwayBasedInfo.m_globalSpeeds.find(type);
|
||||
CHECK(globalIt != m_highwayBasedInfo.m_globalSpeeds.cend(), ("Can't find type in global speeds", type));
|
||||
SpeedKMpH const & global = globalIt->second.GetSpeed(isCityRoad);
|
||||
CHECK_NOT_EQUAL(global.m_weight, kInvalidModelValue, ());
|
||||
CHECK_NOT_EQUAL(global.m_eta, kInvalidModelValue, ());
|
||||
if (speed.m_weight == kInvalidModelValue)
|
||||
speed.m_weight = global.m_weight;
|
||||
|
||||
if (speed.m_eta == kInvalidModelValue)
|
||||
speed.m_eta = global.m_eta;
|
||||
auto const typeKey = GetHighwayTypeKey(type);
|
||||
auto const factorIt = m_highwayBasedInfo.m_globalFactors.find(typeKey);
|
||||
CHECK(factorIt != m_highwayBasedInfo.m_globalFactors.cend(), ("Key:", typeKey, "is not found."));
|
||||
|
||||
SpeedKMpH const speed = factorIt->second.GetFactor(isCityRoad) * speedIt->second.GetSpeed(isCityRoad);
|
||||
CHECK_NOT_EQUAL(speed.m_weight, kInvalidModelValue, ());
|
||||
CHECK_NOT_EQUAL(speed.m_eta, kInvalidModelValue, ());
|
||||
return Pick<min>(speed, maxModelSpeed);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,14 +63,8 @@ enum class HighwayType : uint32_t
|
|||
RouteShuttleTrain = 1054,
|
||||
};
|
||||
|
||||
using SpeedToFactor = std::unordered_map<MaxspeedType /* maxspeed km/h */, InOutCityFactor>;
|
||||
using HighwayBasedFactors = std::unordered_map<HighwayType, SpeedToFactor, base::EnumClassHash>;
|
||||
using HighwayBasedMeanSpeeds =
|
||||
std::unordered_map<HighwayType, InOutCitySpeedKMpH, base::EnumClassHash>;
|
||||
using CountryToHighwayBasedMeanSpeeds =
|
||||
std::unordered_map<std::string /* country */, HighwayBasedMeanSpeeds>;
|
||||
using CountryToHighwayBasedFactors =
|
||||
std::unordered_map<std::string /* country */, HighwayBasedFactors>;
|
||||
using HighwayBasedFactors = std::unordered_map<HighwayType, InOutCityFactor, base::EnumClassHash>;
|
||||
using HighwayBasedSpeeds = std::unordered_map<HighwayType, InOutCitySpeedKMpH, base::EnumClassHash>;
|
||||
|
||||
/// \brief Params for calculation of an approximate speed on a feature.
|
||||
struct SpeedParams
|
||||
|
@ -181,28 +175,13 @@ struct InOutCityFactor
|
|||
|
||||
struct HighwayBasedInfo
|
||||
{
|
||||
HighwayBasedInfo(HighwayBasedMeanSpeeds const & speeds, HighwayBasedFactors const & factors)
|
||||
: m_localSpeeds(speeds)
|
||||
, m_globalSpeeds(speeds)
|
||||
, m_localFactors(factors)
|
||||
HighwayBasedInfo(HighwayBasedSpeeds const & speeds, HighwayBasedFactors const & factors)
|
||||
: m_globalSpeeds(speeds)
|
||||
, m_globalFactors(factors)
|
||||
{
|
||||
}
|
||||
|
||||
HighwayBasedInfo(HighwayBasedMeanSpeeds const & localSpeeds,
|
||||
HighwayBasedMeanSpeeds const & globalSpeeds,
|
||||
HighwayBasedFactors const & localFactors,
|
||||
HighwayBasedFactors const & globalFactors)
|
||||
: m_localSpeeds(localSpeeds)
|
||||
, m_globalSpeeds(globalSpeeds)
|
||||
, m_localFactors(localFactors)
|
||||
, m_globalFactors(globalFactors)
|
||||
{
|
||||
}
|
||||
|
||||
HighwayBasedMeanSpeeds const & m_localSpeeds;
|
||||
HighwayBasedMeanSpeeds const & m_globalSpeeds;
|
||||
HighwayBasedFactors const & m_localFactors;
|
||||
HighwayBasedSpeeds const & m_globalSpeeds;
|
||||
HighwayBasedFactors const & m_globalFactors;
|
||||
};
|
||||
|
||||
|
@ -353,7 +332,7 @@ protected:
|
|||
|
||||
SpeedKMpH GetSpeedWihtoutMaxspeed(FeatureType & f, SpeedParams const & speedParams) const;
|
||||
|
||||
/// \brief maximum within all the speed limits set in a model (car model, bicycle modle and so on).
|
||||
/// \brief maximum within all the speed limits set in a model (car model, bicycle model and so on).
|
||||
/// It shouldn't be mixed with maxspeed value tag which defines maximum legal speed on a feature.
|
||||
InOutCitySpeedKMpH m_maxModelSpeed;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue