diff --git a/routing_common/car_model_coefs_default.hpp b/routing_common/car_model_coefs_default.hpp index 9c8a7a8946..eb87cec85a 100644 --- a/routing_common/car_model_coefs_default.hpp +++ b/routing_common/car_model_coefs_default.hpp @@ -11,12 +11,16 @@ HighwayBasedFactors const kHighwayBasedFactors = { // {highway class : InOutCityFactor(in city, out city)} {HighwayType::HighwayLivingStreet, InOutCityFactor(0.75)}, {HighwayType::HighwayMotorway, InOutCityFactor(0.90, 0.94)}, + {HighwayType::HighwayMotorwayLink, InOutCityFactor(0.90, 0.94)}, {HighwayType::HighwayPrimary, InOutCityFactor(0.86, 0.89)}, + {HighwayType::HighwayPrimaryLink, InOutCityFactor(0.86, 0.89)}, {HighwayType::HighwayResidential, InOutCityFactor(0.75)}, {HighwayType::HighwayRoad, InOutCityFactor(0.30)}, {HighwayType::HighwaySecondary, InOutCityFactor(0.84, 0.82)}, + {HighwayType::HighwaySecondaryLink, InOutCityFactor(0.84, 0.82)}, {HighwayType::HighwayService, InOutCityFactor(0.80)}, {HighwayType::HighwayTertiary, InOutCityFactor(0.82, 0.76)}, + {HighwayType::HighwayTertiaryLink, InOutCityFactor(0.82, 0.76)}, {HighwayType::HighwayTrack, InOutCityFactor(0.30)}, {HighwayType::HighwayTrack, InOutCityFactor(0.30)}, {HighwayType::HighwayTrunk, InOutCityFactor(0.90, 0.91)}, @@ -42,6 +46,7 @@ HighwayBasedSpeeds const kHighwayBasedSpeeds = { {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::HighwayTertiaryLink, InOutCitySpeedKMpH({40.95, 34.97} /* in city */, {45.45, 39.73} /* 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 */)}, diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index aa33a3c587..1bac80405f 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -67,8 +67,8 @@ VehicleModel::VehicleModel(Classificator const & c, LimitsInitList const & featu { auto const classificatorType = c.GetTypeByPath(v.m_types); auto const highwayType = static_cast(c.GetIndexForType(classificatorType)); - auto const speedIt = info.m_globalSpeeds.find(highwayType); - CHECK(speedIt != info.m_globalSpeeds.cend(), ("Can't found speed for", highwayType)); + auto const speedIt = info.m_speeds.find(highwayType); + CHECK(speedIt != info.m_speeds.cend(), ("Can't found speed for", highwayType)); // TODO: Consider using not only highway class speed but max sped * max speed factor. m_maxModelSpeed = Max(m_maxModelSpeed, speedIt->second); m_roadTypes.emplace(classificatorType, RoadType(highwayType, v.m_isPassThroughAllowed)); @@ -170,20 +170,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 maxSpeedType = speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward); - CHECK(maxSpeedType != kInvalidSpeed, (type, speedParams.m_forward, speedParams.m_maxspeed)); - auto const maxspeedKmPH = static_cast(maxSpeedType); - SpeedKMpH speed = Pick(SpeedKMpH(maxspeedKmPH, maxspeedKmPH), maxModelSpeed); + auto const featureMaxSpeedKmPH = speedParams.m_maxspeed.GetSpeedKmPH(speedParams.m_forward); + CHECK(featureMaxSpeedKmPH != kInvalidSpeed, (type, speedParams.m_forward, speedParams.m_maxspeed)); // We assume that all link roads are equal to its parents and drop "_link" suffix // while searching for the particular factor. - auto const typeKey = GetHighwayTypeKey(type); + auto const highwayType = GetHighwayTypeKey(type); - auto const factorIt = m_highwayBasedInfo.m_globalFactors.find(typeKey); - CHECK(factorIt != m_highwayBasedInfo.m_globalFactors.cend(), ("Key:", typeKey, "is not found.")); + auto const factorIt = m_highwayBasedInfo.m_factors.find(highwayType); + CHECK(factorIt != m_highwayBasedInfo.m_factors.cend(), ("Key:", highwayType, "is not found.")); auto const & factor = factorIt->second; - return Pick(speed * factor.GetFactor(isCityRoad), maxModelSpeed); + SpeedKMpH const & maxModelSpeed = m_maxModelSpeed.GetSpeed(isCityRoad); + return Pick(SpeedKMpH(static_cast(featureMaxSpeedKmPH)) * factor.GetFactor(isCityRoad), + maxModelSpeed); } SpeedKMpH VehicleModel::GetSpeedOnFeatureWithoutMaxspeed(HighwayType const & type, @@ -193,17 +192,17 @@ SpeedKMpH VehicleModel::GetSpeedOnFeatureWithoutMaxspeed(HighwayType const & typ auto const isCityRoad = speedParams.m_inCity; SpeedKMpH const & maxModelSpeed = m_maxModelSpeed.GetSpeed(isCityRoad); - auto const speedIt = m_highwayBasedInfo.m_globalSpeeds.find(type); - CHECK(speedIt != m_highwayBasedInfo.m_globalSpeeds.cend(), ("Key:", type, "is not found.")); + auto const speedIt = m_highwayBasedInfo.m_speeds.find(type); + CHECK(speedIt != m_highwayBasedInfo.m_speeds.cend(), ("Key:", type, "is not found.")); 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.")); + auto const factorIt = m_highwayBasedInfo.m_factors.find(typeKey); + CHECK(factorIt != m_highwayBasedInfo.m_factors.cend(), ("Key:", typeKey, "is not found.")); - SpeedKMpH const speed = factorIt->second.GetFactor(isCityRoad) * speedIt->second.GetSpeed(isCityRoad); + SpeedKMpH const speed = speedIt->second.GetSpeed(isCityRoad); CHECK_NOT_EQUAL(speed.m_weight, kInvalidModelValue, ()); CHECK_NOT_EQUAL(speed.m_eta, kInvalidModelValue, ()); - return Pick(speed, maxModelSpeed); + return Pick(factorIt->second.GetFactor(isCityRoad) * speed, maxModelSpeed); } SpeedKMpH VehicleModel::GetTypeSpeed(feature::TypesHolder const & types, diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index 00a5b8627c..7bb175f279 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -176,13 +176,13 @@ struct InOutCityFactor struct HighwayBasedInfo { HighwayBasedInfo(HighwayBasedSpeeds const & speeds, HighwayBasedFactors const & factors) - : m_globalSpeeds(speeds) - , m_globalFactors(factors) + : m_speeds(speeds) + , m_factors(factors) { } - HighwayBasedSpeeds const & m_globalSpeeds; - HighwayBasedFactors const & m_globalFactors; + HighwayBasedSpeeds const & m_speeds; + HighwayBasedFactors const & m_factors; }; class VehicleModelInterface