From 7171d56dfae30910d6113e583c329ee3b23a9e2b Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 11 Sep 2019 16:49:32 +0300 Subject: [PATCH] [routing] Review fixes. --- routing/edge_estimator.cpp | 4 ++-- routing/index_graph.cpp | 15 +-------------- routing_common/car_model.cpp | 2 +- routing_common/vehicle_model.hpp | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 7540b6dc63..43e3fab2cd 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -103,7 +103,7 @@ EdgeEstimator::EdgeEstimator(double maxWeightSpeedKMpH, SpeedKMpH const & offroa CHECK_GREATER(m_offroadSpeedKMpH.m_eta, 0.0, ()); CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KMPH2MPS(m_offroadSpeedKMpH.m_weight), ()); - if (m_offroadSpeedKMpH.m_eta != kUndefinedSpeed) + if (m_offroadSpeedKMpH.m_eta != kNotUsed) CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KMPH2MPS(m_offroadSpeedKMpH.m_eta), ()); } @@ -126,7 +126,7 @@ double EdgeEstimator::CalcOffroad(m2::PointD const & from, m2::PointD const & to { auto const offroadSpeedKMpH = purpose == Purpose::Weight ? m_offroadSpeedKMpH.m_weight : m_offroadSpeedKMpH.m_eta; - if (offroadSpeedKMpH == kUndefinedSpeed) + if (offroadSpeedKMpH == kNotUsed) return 0.0; return TimeBetweenSec(from, to, KMPH2MPS(offroadSpeedKMpH)); diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index 03cb0d47de..74412fefd7 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -458,20 +458,7 @@ RouteWeight IndexGraph::CalculateEdgeWeight(EdgeEstimator::Purpose purpose, bool auto const getWeight = [this, isOutgoing, &to, &from, purpose]() { auto const & segment = isOutgoing ? to : from; auto const & road = m_geometry->GetRoad(segment.GetFeatureId()); - switch (purpose) - { - case EdgeEstimator::Purpose::Weight: - { - return RouteWeight( - m_estimator->CalcSegmentWeight(segment, road, EdgeEstimator::Purpose::Weight)); - } - case EdgeEstimator::Purpose::ETA: - { - return RouteWeight( - m_estimator->CalcSegmentWeight(segment, road, EdgeEstimator::Purpose::ETA)); - } - } - UNREACHABLE(); + return RouteWeight(m_estimator->CalcSegmentWeight(segment, road, purpose)); }; auto const & weight = getWeight(); diff --git a/routing_common/car_model.cpp b/routing_common/car_model.cpp index e6e741ebc3..ab67871802 100644 --- a/routing_common/car_model.cpp +++ b/routing_common/car_model.cpp @@ -69,7 +69,7 @@ std::array constexpr kCountries = {"Australia", // 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 */}; +SpeedKMpH constexpr kSpeedOffroadKMpH = {0.01 /* weight */, kNotUsed /* eta */}; VehicleModel::LimitsInitList const kCarOptionsDefault = { // {{roadType, roadType} passThroughAllowed} diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index 456e9bc399..cea735b592 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -25,7 +25,7 @@ namespace feature { class TypesHolder; } namespace routing { -double constexpr kUndefinedSpeed = std::numeric_limits::max(); +double constexpr kNotUsed = std::numeric_limits::max(); struct InOutCityFactor; struct InOutCitySpeedKMpH;