Skip to content

Commit

Permalink
Fix loading GTFS frequencies with < 60 seconds headway (#156)
Browse files Browse the repository at this point in the history
* Fix loading GTFS frequencies with < 60 seconds headway

* wip

* wip

---------

Co-authored-by: Felix Gündling <[email protected]>
  • Loading branch information
jbruechert and felixguendling authored Nov 24, 2024
1 parent 6bf2a94 commit 802aaea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/loader/gtfs/trip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,18 @@ void read_frequencies(trip_data& trips, std::string_view file_content) {
if (!frequencies.has_value()) {
frequencies = std::vector<frequency>{};
}

// If the service operates multiple times per minute, make sure not
// to end up with zero.
auto const headway_minutes = duration_t{std::max(
static_cast<int>(
std::round(static_cast<float>(headway_secs) / 60.F)),
1)};
frequencies->emplace_back(
frequency{hhmm_to_min(freq.start_time_->view()),
hhmm_to_min(freq.end_time_->view()),
duration_t{headway_secs / 60}, schedule_relationship});
hhmm_to_min(freq.end_time_->view()), headway_minutes,
schedule_relationship});
});
}

} // namespace nigiri::loader::gtfs
} // namespace nigiri::loader::gtfs

0 comments on commit 802aaea

Please sign in to comment.