diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 1a75726c18..7540b6dc63 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -102,7 +102,9 @@ EdgeEstimator::EdgeEstimator(double maxWeightSpeedKMpH, SpeedKMpH const & offroa CHECK_GREATER(m_offroadSpeedKMpH.m_weight, 0.0, ()); CHECK_GREATER(m_offroadSpeedKMpH.m_eta, 0.0, ()); CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KMPH2MPS(m_offroadSpeedKMpH.m_weight), ()); - CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KMPH2MPS(m_offroadSpeedKMpH.m_eta), ()); + + if (m_offroadSpeedKMpH.m_eta != kUndefinedSpeed) + CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KMPH2MPS(m_offroadSpeedKMpH.m_eta), ()); } double EdgeEstimator::CalcHeuristic(m2::PointD const & from, m2::PointD const & to) const @@ -119,11 +121,15 @@ double EdgeEstimator::CalcLeapWeight(m2::PointD const & from, m2::PointD const & return TimeBetweenSec(from, to, m_maxWeightSpeedMpS / 2.0); } -double EdgeEstimator::CalcOffroad(m2::PointD const & from, m2::PointD const & to, Purpose purpose) const +double EdgeEstimator::CalcOffroad(m2::PointD const & from, m2::PointD const & to, + Purpose purpose) const { - return TimeBetweenSec(from, to, - KMPH2MPS(purpose == Purpose::Weight ? m_offroadSpeedKMpH.m_weight - : m_offroadSpeedKMpH.m_eta)); + auto const offroadSpeedKMpH = purpose == Purpose::Weight ? m_offroadSpeedKMpH.m_weight + : m_offroadSpeedKMpH.m_eta; + if (offroadSpeedKMpH == kUndefinedSpeed) + return 0.0; + + return TimeBetweenSec(from, to, KMPH2MPS(offroadSpeedKMpH)); } // PedestrianEstimator ----------------------------------------------------------------------------- diff --git a/routing_common/car_model.cpp b/routing_common/car_model.cpp index 5028b84371..d3a23a57d2 100644 --- a/routing_common/car_model.cpp +++ b/routing_common/car_model.cpp @@ -64,12 +64,12 @@ std::array constexpr kCountries = {"Australia", "Venezuela"}; // |kSpeedOffroadKMpH| is a speed which is used for edges that don't lie on road features. -// For example for pure fake edges. The speed for building route and the speed for -// ETA calculation is significant different for cars. The idea behind that is -// to use the closest edge for the start and the finish of the route except for some edge cases. -// And when ETA is calculated not to take into account fake edges. It's actual -// when an airport is a start of finish. -SpeedKMpH constexpr kSpeedOffroadKMpH = {0.01 /* weight */, 100.0 /* eta */}; +// 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 +// a start or finish. On the other hand, while route calculation the fake edges are considered +// as quite heavy. The idea behind that is to use the closest edge for the start and the finish +// of the route except for some edge cases. +SpeedKMpH constexpr kSpeedOffroadKMpH = {0.01 /* weight */, kUndefinedSpeed /* eta */}; VehicleModel::LimitsInitList const kCarOptionsDefault = { // {{roadType, roadType} passThroughAllowed} diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index 2b58b1cd66..c43b3aa969 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,8 @@ namespace feature { class TypesHolder; } namespace routing { +double constexpr kUndefinedSpeed = std::numeric_limits::max(); + struct InOutCityFactor; struct InOutCitySpeedKMpH;