From 8cfbb810c82dc6765d026823f3a1ca5af36ba36a Mon Sep 17 00:00:00 2001 From: Jeremy Steele Date: Mon, 30 Sep 2024 16:06:54 -0400 Subject: [PATCH] Stops without lat/lon are valid, return None for lat/lon getter instead of throwing --- gtfs_loader/schema.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gtfs_loader/schema.py b/gtfs_loader/schema.py index b80d760..8ebcaf7 100644 --- a/gtfs_loader/schema.py +++ b/gtfs_loader/schema.py @@ -211,7 +211,7 @@ class Stop(Entity): @cached_property def location(self): if self.stop_lat is None or self.stop_lon is None: - raise ValueError(f'Stop {self.stop_id} missing location') + return None return LatLon(self.stop_lat, self.stop_lon) @@ -285,8 +285,11 @@ def last_stop_time(self): @property def stop_shape(self): - return tuple(self._gtfs.stops[st.stop_id].location - for st in self._gtfs.stop_times[self.trip_id]) + locations = tuple(self._gtfs.stops[st.stop_id].location for st in self._gtfs.stop_times[self.trip_id]) + + if None in locations: + return None + return locations @cached_property def shift_days(self):