Skip to content

Commit

Permalink
add scheduled stop accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Oct 18, 2024
1 parent 1da3035 commit 93ba195
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nigiri/rt/frun.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ namespace nigiri::rt {
struct frun : public run {
struct run_stop {
stop get_stop() const noexcept;
stop get_scheduled_stop() const noexcept;
location get_location() const noexcept;
geo::latlng pos() const noexcept;
location_idx_t get_location_idx() const noexcept;
location_idx_t get_scheduled_location_idx() const noexcept;
std::string_view name() const noexcept;
std::string_view track() const noexcept;
std::string_view id() const noexcept;
Expand Down
14 changes: 14 additions & 0 deletions src/rt/frun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
namespace nigiri::rt {

stop frun::run_stop::get_stop() const noexcept {
assert(fr_->size() > stop_idx_);
return stop{
(fr_->is_rt() && rtt() != nullptr)
? rtt()->rt_transport_location_seq_[fr_->rt_][stop_idx_]
: tt().route_location_seq_[tt().transport_route_[fr_->t_.t_idx_]]
[stop_idx_]};
}

stop frun::run_stop::get_scheduled_stop() const noexcept {
assert(fr_->size() > stop_idx_);
return fr_->is_scheduled()
? tt().route_location_seq_[tt().transport_route_[fr_->t_.t_idx_]]
[stop_idx_]
: rtt()->rt_transport_location_seq_[fr_->rt_][stop_idx_];
}

std::string_view frun::run_stop::name() const noexcept {
auto const l = get_location_idx();
auto const type = tt().locations_.types_.at(l);
Expand Down Expand Up @@ -65,6 +74,11 @@ location_idx_t frun::run_stop::get_location_idx() const noexcept {
return get_stop().location_idx();
}

location_idx_t frun::run_stop::get_scheduled_location_idx() const noexcept {
assert(fr_->size() > stop_idx_);
return get_scheduled_stop().location_idx();
}

unixtime_t frun::run_stop::scheduled_time(
event_type const ev_type) const noexcept {
assert(fr_->size() > stop_idx_);
Expand Down

0 comments on commit 93ba195

Please sign in to comment.