Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index out of range for stop_times last arrival of multi-section run #704

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/motis/tag_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ struct tag_lookup {
nigiri::source_idx_t get_src(std::string_view tag) const;
std::string_view get_tag(nigiri::source_idx_t) const;
std::string id(nigiri::timetable const&, nigiri::location_idx_t) const;
std::string id(nigiri::timetable const&, nigiri::rt::run_stop) const;
std::string id(nigiri::timetable const&,
nigiri::rt::run_stop,
nigiri::event_type) const;
nigiri::location_idx_t get_location(nigiri::timetable const&,
std::string_view) const;
std::pair<nigiri::rt::run, nigiri::trip_idx_t> get_trip(
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/stop_times.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ api::stoptimes_response stop_times::operator()(
.routeColor_ = to_str(s.get_route_color(ev_type).color_),
.routeTextColor_ =
to_str(s.get_route_color(ev_type).text_color_),
.tripId_ = tags_.id(tt_, s),
.tripId_ = tags_.id(tt_, s, ev_type),
.routeShortName_ = std::string{s.trip_display_name(ev_type)},
.source_ = fmt::format("{}", fmt::streamed(fr.dbg()))};
}),
Expand Down
2 changes: 1 addition & 1 deletion src/journey_to_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ api::Itinerary journey_to_response(osr::ways const* w,
.agencyName_ = {std::string{agency.long_name_}},
.agencyUrl_ = {std::string{agency.url_}},
.agencyId_ = {std::string{agency.short_name_}},
.tripId_ = tags.id(tt, enter_stop),
.tripId_ = tags.id(tt, enter_stop, n::event_type::kDep),
.routeShortName_ = {std::string{
enter_stop.trip_display_name()}},
.source_ = fmt::to_string(fr.dbg())});
Expand Down
2 changes: 1 addition & 1 deletion src/railviz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ api::trips_response get_trains(tag_lookup const& tags,
[&](auto&& p) { enc.push(p); });

return {.trips_ = {api::TripInfo{
.tripId_ = tags.id(tt, from),
.tripId_ = tags.id(tt, from, n::event_type::kDep),
.routeShortName_ =
std::string{from.trip_display_name(n::event_type::kDep)}}},
.routeColor_ =
Expand Down
5 changes: 3 additions & 2 deletions src/tag_lookup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ std::string tag_lookup::id(nigiri::timetable const& tt,
}

std::string tag_lookup::id(nigiri::timetable const& tt,
n::rt::run_stop s) const {
n::rt::run_stop s,
n::event_type const ev_type) const {
if (s.fr_->is_scheduled()) {
// trip id
auto const t = s.get_trip_idx(n::event_type::kDep);
auto const t = s.get_trip_idx(ev_type);
auto const id_idx = tt.trip_ids_[t].front();
auto const id = tt.trip_id_strings_[id_idx].view();
auto const src = tt.trip_id_src_[id_idx];
Expand Down
Loading