From 76cb444aba65aa04105f83e33a039f3b873e758b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Fri, 17 Dec 2021 11:48:24 +0100 Subject: [PATCH] gtfs: make parser more robust by not requiring every trip in stop_times.txt to exist --- base/loader/src/gtfs/stop_time.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/loader/src/gtfs/stop_time.cc b/base/loader/src/gtfs/stop_time.cc index 04d9d72ee..14e522eaf 100644 --- a/base/loader/src/gtfs/stop_time.cc +++ b/base/loader/src/gtfs/stop_time.cc @@ -70,7 +70,13 @@ void read_stop_times(loaded_file const& file, trip_map& trips, if (last_trip != nullptr && t_id == last_trip_id) { t = last_trip; } else { - t = trips.at(t_id).get(); + auto const trip_it = trips.find(t_id); + if (trip_it == end(trips)) { + LOG(logging::error) << "trip \"" << t_id << "\" in " << file.name() + << ":" << i << " not found"; + continue; + } + t = trip_it->second.get(); last_trip_id = t_id; last_trip = t; }