[traffic] Override EdgeEstimator::CalcOffroad()

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-06-12 00:36:17 +03:00
parent b48310e6a5
commit df13e279b6
3 changed files with 28 additions and 1 deletions

View File

@@ -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.

View File

@@ -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());

View File

@@ -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;