From 007fb29bc5182cd677955456a27fbfcdaa37a6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Wed, 15 Jan 2025 17:53:07 +0100 Subject: [PATCH] output exactly what nigiri routed --- src/street_routing.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/street_routing.cc b/src/street_routing.cc index 5d4c0d5f2..b72260866 100644 --- a/src/street_routing.cc +++ b/src/street_routing.cc @@ -295,7 +295,8 @@ api::Itinerary route(osr::ways const& w, .count() : path->cost_, .startTime_ = start_time, - .endTime_ = start_time + std::chrono::seconds{path->cost_}, + .endTime_ = + end_time ? *end_time : start_time + std::chrono::seconds{path->cost_}, .transfers_ = 0}; auto t = std::chrono::time_point_cast(start_time); @@ -368,6 +369,23 @@ api::Itinerary route(osr::ways const& w, pred_end_time = t; }); + if (end_time && !itinerary.legs_.empty()) { + itinerary.legs_.back().to_.arrival_ = + itinerary.legs_.back().to_.scheduledArrival_ = + itinerary.legs_.back().endTime_ = + itinerary.legs_.back().scheduledEndTime_ = *end_time; + for (auto& leg : itinerary.legs_) { + auto const before = leg.duration_; + leg.duration_ = (leg.endTime_.time_ - leg.startTime_.time_).count(); + if (leg.duration_ != before) { + std::cout << "leg duration: before=" << before + << ", after=" << leg.duration_ + << ", start_time=" << leg.startTime_ + << ", end_time=" << leg.endTime_ << "\n"; + } + } + } + return itinerary; }