Skip to content

Commit

Permalink
Fix loading GTFS frequencies with < 60 seconds headway
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Nov 24, 2024
1 parent 6bf2a94 commit dce5ad2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/loader/gtfs/trip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,17 @@ 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 headway_minutes = duration_t{
std::max(int(std::lround((float)headway_secs / 60)), 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 dce5ad2

Please sign in to comment.