Skip to content

Commit

Permalink
output exactly what nigiri routed
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Jan 15, 2025
1 parent adfd859 commit 007fb29
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/street_routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::chrono::seconds>(start_time);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 007fb29

Please sign in to comment.