From df13e279b62fb05f84507f352d546d48ea82712c Mon Sep 17 00:00:00 2001 From: mvglasow Date: Thu, 12 Jun 2025 00:36:17 +0300 Subject: [PATCH] [traffic] Override EdgeEstimator::CalcOffroad() Signed-off-by: mvglasow --- routing/edge_estimator.hpp | 2 +- traffxml/traff_decoder.cpp | 15 +++++++++++++++ traffxml/traff_decoder.hpp | 12 ++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/routing/edge_estimator.hpp b/routing/edge_estimator.hpp index 1a9fc83b5..4df9c934b 100644 --- a/routing/edge_estimator.hpp +++ b/routing/edge_estimator.hpp @@ -106,7 +106,7 @@ public: * @param purpose The purpose for which the result is to be used. * @return Travel time in seconds. */ - double CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, Purpose purpose) const; + virtual double CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, Purpose purpose) const; /** * @brief Returns the travel time along a segment. diff --git a/traffxml/traff_decoder.cpp b/traffxml/traff_decoder.cpp index 632354b7d..1e0ca3d9e 100644 --- a/traffxml/traff_decoder.cpp +++ b/traffxml/traff_decoder.cpp @@ -470,6 +470,21 @@ double RoutingTraffDecoder::TraffEstimator::GetFerryLandingPenalty(Purpose purpo UNREACHABLE(); } +double RoutingTraffDecoder::TraffEstimator::CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, + Purpose purpose) const +{ + if (purpose == Purpose::ETA) + return 0.0; + + double result = ms::DistanceOnEarth(from, to); + + LOG(LINFO, ("Distance:", result, "weighted:", result * kOffroadPenalty)); + + result *= kOffroadPenalty; + + return result; +} + double RoutingTraffDecoder::TraffEstimator::CalcSegmentWeight(routing::Segment const & segment, routing::RoadGeometry const & road, Purpose purpose) const { double result = road.GetDistance(segment.GetSegmentIdx()); diff --git a/traffxml/traff_decoder.hpp b/traffxml/traff_decoder.hpp index 81524f06c..252b219bb 100644 --- a/traffxml/traff_decoder.hpp +++ b/traffxml/traff_decoder.hpp @@ -273,6 +273,18 @@ public: } // EdgeEstimator overrides: + + /** + * @brief Estimates travel time between two points along a direct fake edge. + * + * Estimates time in seconds it takes to go from point `from` to point `to` along direct fake edge. + * + * @param from The start point. + * @param to The destination point. + * @param purpose The purpose for which the result is to be used. + * @return Travel time in seconds. + */ + double CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, Purpose purpose) const override; double CalcSegmentWeight(routing::Segment const & segment, routing::RoadGeometry const & road, Purpose purpose) const override; double GetUTurnPenalty(Purpose /* purpose */) const override; double GetFerryLandingPenalty(Purpose purpose) const override;