Skip to content
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
1 change: 1 addition & 0 deletions include/nigiri/rt/frun.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct run_stop {
std::string_view route_long_name(event_type, lang_t const&) const;
std::string_view trip_short_name(event_type, lang_t const&) const;
std::string_view display_name(event_type, lang_t const&) const;
run_stop get_first_trip_stop(event_type) const;
run_stop get_last_trip_stop(event_type) const;

unixtime_t scheduled_time(event_type) const;
Expand Down
19 changes: 19 additions & 0 deletions src/rt/frun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ location_idx_t run_stop::get_scheduled_location_idx() const {
return get_scheduled_stop().location_idx();
}

run_stop run_stop::get_first_trip_stop(event_type const ev_type) const {
if (!fr_->is_scheduled()) {
return run_stop{fr_, stop_idx_t{0U}};
}

auto const trip = get_trip_idx(ev_type);
auto copy = *this;

while (copy.stop_idx_ > 0U && copy.get_trip_idx(event_type::kDep) == trip) {
--copy.stop_idx_;
}

if (copy.get_trip_idx(event_type::kDep) != trip) {
++copy.stop_idx_;
}

return copy;
}

run_stop run_stop::get_last_trip_stop(event_type const ev_type) const {
auto const end = fr_->size();
if (!fr_->is_scheduled()) {
Expand Down
Loading