Skip to content

Commit

Permalink
fix skip cancel (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Mar 8, 2024
1 parent 00e88c2 commit ea35f57
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/nigiri/stop.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct stop {
location_idx_t location_idx() const { return location_idx_t{location_}; }
bool in_allowed() const { return in_allowed_ != 0U; }
bool out_allowed() const { return out_allowed_ != 0U; }
bool is_cancelled() const { return !in_allowed() && !out_allowed(); }

cista::hash_t hash() const {
return cista::hash_combine(cista::BASE_HASH, value());
Expand Down
8 changes: 6 additions & 2 deletions src/rt/frun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ stop_idx_t frun::first_valid(stop_idx_t const from) const {
return i;
}
}
throw utl::fail("no first valid found: {} (dbg={})", name(), dbg());
log(log_lvl::error, "frun", "no first valid found: id={}, name={}, dbg={}",
fmt::streamed(id()), name(), fmt::streamed(dbg()));
return stop_range_.to_;
}

stop_idx_t frun::last_valid() const {
Expand All @@ -260,7 +262,9 @@ stop_idx_t frun::last_valid() const {
return i;
}
}
throw utl::fail("no last valid found: {} (dbg={})", name(), dbg());
log(log_lvl::error, "frun", "no last valid found: id={}, name={}, dbg={}",
fmt::streamed(id()), name(), fmt::streamed(dbg()));
return stop_range_.to_;
}

frun::iterator frun::begin() const noexcept {
Expand Down
7 changes: 7 additions & 0 deletions src/rt/gtfsrt_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ void update_run(
++upd_it;
}
}

auto const n_not_cancelled_stops = utl::count_if(
rtt.rt_transport_location_seq_[r.rt_],
[](stop::value_type const s) { return !stop{s}.is_cancelled(); });
if (n_not_cancelled_stops <= 1U) {
cancel_run(tt, rtt, r);
}
}

statistics gtfsrt_update_msg(timetable const& tt,
Expand Down

0 comments on commit ea35f57

Please sign in to comment.