aiomobilitydatabase 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/PKG-INFO +95 -9
  2. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/README.md +94 -8
  3. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/const.py +1 -1
  4. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/__init__.py +12 -0
  5. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/gbfs.py +221 -8
  6. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/geo.py +24 -11
  7. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/models.py +191 -9
  8. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/rt.py +306 -10
  9. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/static_index.py +188 -10
  10. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/transit.py +560 -33
  11. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/catalog/gbfs_feed.json +16 -0
  12. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/discovery_23.json +16 -0
  13. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/free_bike_status_23.json +6 -1
  14. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/station_info_23.json +7 -1
  15. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/station_status_23.json +7 -2
  16. aiomobilitydatabase-0.5.0/tests/feeds/data/gbfs/system_alerts.json +33 -0
  17. aiomobilitydatabase-0.5.0/tests/feeds/data/gbfs/system_info_23.json +22 -0
  18. aiomobilitydatabase-0.5.0/tests/feeds/data/gbfs/system_pricing_plans.json +19 -0
  19. aiomobilitydatabase-0.5.0/tests/feeds/data/gbfs/system_regions.json +15 -0
  20. aiomobilitydatabase-0.5.0/tests/feeds/data/gbfs/vehicle_types.json +24 -0
  21. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/fixtures.py +4 -0
  22. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_descriptive_attributes.py +16 -5
  23. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_gbfs_stations.py +136 -0
  24. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_gbfs_vehicles.py +68 -0
  25. aiomobilitydatabase-0.5.0/tests/feeds/test_geo.py +90 -0
  26. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_models.py +69 -4
  27. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_properties.py +35 -16
  28. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_rt.py +124 -6
  29. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_sample_feed.py +14 -3
  30. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_static_build.py +135 -0
  31. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_transit_arrivals.py +407 -3
  32. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_transit_frequencies.py +75 -0
  33. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_transit_trips.py +90 -2
  34. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_transit_vehicles_alerts.py +147 -1
  35. aiomobilitydatabase-0.4.0/tests/feeds/data/gbfs/system_info_23.json +0 -10
  36. aiomobilitydatabase-0.4.0/tests/feeds/test_geo.py +0 -38
  37. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/.github/workflows/ci.yml +0 -0
  38. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/.github/workflows/publish.yml +0 -0
  39. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/.gitignore +0 -0
  40. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/.pre-commit-config.yaml +0 -0
  41. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/LICENSE +0 -0
  42. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/pyproject.toml +0 -0
  43. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/scripts/generate_rt_fixtures.py +0 -0
  44. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/__init__.py +0 -0
  45. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/client.py +0 -0
  46. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/exceptions.py +0 -0
  47. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/client.py +0 -0
  48. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/const.py +0 -0
  49. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/feeds/exceptions.py +0 -0
  50. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/models.py +0 -0
  51. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/src/aiomobilitydatabase/py.typed +0 -0
  52. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/__init__.py +0 -0
  53. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/conftest.py +0 -0
  54. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/__init__.py +0 -0
  55. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/conftest.py +0 -0
  56. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/catalog/gtfs_feed.json +0 -0
  57. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/catalog/gtfs_rt_feed.json +0 -0
  58. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/catalog/token_response.json +0 -0
  59. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/discovery_30.json +0 -0
  60. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/system_info_30.json +0 -0
  61. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gbfs/vehicle_status_30.json +0 -0
  62. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/agency.txt +0 -0
  63. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/calendar.txt +0 -0
  64. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/calendar_dates.txt +0 -0
  65. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/routes.txt +0 -0
  66. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/stop_times.txt +0 -0
  67. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/stops.txt +0 -0
  68. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/gtfs/trips.txt +0 -0
  69. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/added_trips_s1.pb +0 -0
  70. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/alerts.pb +0 -0
  71. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/alerts_trip_scoped.pb +0 -0
  72. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_baseline.pb +0 -0
  73. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_freq_bare_cancel.pb +0 -0
  74. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_freq_canceled_tomorrow.pb +0 -0
  75. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_freq_matched.pb +0 -0
  76. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_freq_unmatched.pb +0 -0
  77. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_both_ends.pb +0 -0
  78. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_canceled.pb +0 -0
  79. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_canceled_tomorrow.pb +0 -0
  80. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_dated_tomorrow_delay.pb +0 -0
  81. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_delayed.pb +0 -0
  82. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_dest_arrival.pb +0 -0
  83. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_no_data_cut.pb +0 -0
  84. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_skip_s1.pb +0 -0
  85. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_skip_s2.pb +0 -0
  86. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_skip_s3.pb +0 -0
  87. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/trip_updates_t1_trip_delay.pb +0 -0
  88. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/vehicle_positions.pb +0 -0
  89. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/rt/vehicle_positions_status.pb +0 -0
  90. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/README.md +0 -0
  91. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/agency.txt +0 -0
  92. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/calendar.txt +0 -0
  93. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/calendar_dates.txt +0 -0
  94. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/fare_attributes.txt +0 -0
  95. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/fare_rules.txt +0 -0
  96. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/feed_info.txt +0 -0
  97. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/frequencies.txt +0 -0
  98. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/routes.txt +0 -0
  99. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/shapes.txt +0 -0
  100. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/stop_times.txt +0 -0
  101. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/stops.txt +0 -0
  102. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/transfers.txt +0 -0
  103. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/translations.txt +0 -0
  104. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/data/sample_feed/trips.txt +0 -0
  105. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_client.py +0 -0
  106. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_direct_urls.py +0 -0
  107. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_exceptions.py +0 -0
  108. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_extra_import_guard.py +0 -0
  109. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_static_arrivals.py +0 -0
  110. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_static_frequencies.py +0 -0
  111. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_static_trips.py +0 -0
  112. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_station_grouping.py +0 -0
  113. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/feeds/test_transit_resolution.py +0 -0
  114. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/fixtures.py +0 -0
  115. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/mock_server.py +0 -0
  116. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_catalog_properties.py +0 -0
  117. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_client_request.py +0 -0
  118. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_client_session.py +0 -0
  119. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_client_token.py +0 -0
  120. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_endpoints.py +0 -0
  121. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_exceptions.py +0 -0
  122. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_models.py +0 -0
  123. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_params.py +0 -0
  124. {aiomobilitydatabase-0.4.0 → aiomobilitydatabase-0.5.0}/tests/test_public_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: aiomobilitydatabase
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Async Python client for the Mobility Database catalog API
5
5
  Project-URL: Source Code, https://github.com/raman325/aiomobilitydatabase
6
6
  Project-URL: Bug Reports, https://github.com/raman325/aiomobilitydatabase/issues
@@ -147,7 +147,10 @@ async def main() -> None:
147
147
  for arrival in arrivals:
148
148
  when = arrival.predicted_departure or arrival.scheduled_departure
149
149
  live = "live" if arrival.realtime else "scheduled"
150
- print(f"{arrival.route_name} -> {arrival.headsign}: {when} ({live})")
150
+ # .stop and .route are the whole static records: platform codes,
151
+ # coordinates, route_type and route colours all come along.
152
+ route = arrival.route.display_name if arrival.route else arrival.route_id
153
+ print(f"{route} -> {arrival.headsign}: {when} ({live})")
151
154
 
152
155
  # Origin→destination: the next departures from stop A on trips that
153
156
  # later reach stop B, with the same realtime overlay. is_first/is_last
@@ -156,7 +159,8 @@ async def main() -> None:
156
159
  nearby_stops[0].id, nearby_stops[1].id, limit=2
157
160
  )
158
161
  for trip in trips:
159
- print(trip.route_name, trip.scheduled_departure, trip.is_last)
162
+ name = trip.route.display_name if trip.route else trip.route_id
163
+ print(name, trip.scheduled_departure, trip.is_last)
160
164
 
161
165
  vehicles = await transit.get_vehicles()
162
166
  alerts = await transit.get_alerts()
@@ -253,6 +257,19 @@ Notes on direct mode:
253
257
  information, `NO_DATA` makes a stop schedule-only, `SKIPPED` suppresses it
254
258
  (and any origin→destination row boarding or alighting there), and the
255
259
  trip-level delay covers stops no StopTimeUpdate reaches.
260
+ - **Rows carry whole records, not copied columns**: `StopArrival`,
261
+ `UpcomingTrip`, and `VehiclePosition` each expose the full `Stop` and
262
+ `Route` they refer to, so platform codes, coordinates, route colours and
263
+ `route_type` are reachable without a second lookup — use
264
+ `route.display_name` / `stop.name` for the human-readable strings. The raw
265
+ `stop_id`/`route_id` stay alongside, since those are what feeds reference
266
+ and what filters key on; a `route_id` naming a route absent from
267
+ `routes.txt` leaves `route` as `None` rather than inventing one.
268
+ - **Vehicle positions name their trip instance**: `VehiclePosition` carries
269
+ the parsed `trip_start_date`/`trip_start_secs`, the pair a GTFS-RT
270
+ `TripDescriptor` uses to address one run. That is what lets two buses out
271
+ on the same headway-based trip be told apart — without it, concurrent
272
+ repetitions of one template trip are indistinguishable.
256
273
  - **The full descriptive surface is exposed, typed by shape**: closed GTFS
257
274
  vocabularies are enums (`WheelchairAccess`, `BikesAllowed`,
258
275
  `PickupDropOffType`, `StopLocationType`, alert cause/effect/severity,
@@ -268,14 +285,44 @@ Notes on direct mode:
268
285
  fails the build, because a wrong departure time or a wrong call order is
269
286
  worse than no feed at all. A malformed **descriptive** cell still degrades
270
287
  to `None`.
288
+ - **Detours are applied, not annotated**: a GTFS-RT `TripModifications`
289
+ entity REPLACES a span of a trip's calls, so a board that ignored it
290
+ would keep showing departures at stops the vehicle no longer serves, and
291
+ would miss `propagated_modification_delay` on every stop after the
292
+ detour. Replacement times are measured from the reference stop the spec
293
+ names, a replacement stop may be defined only by an RT `Stop` entity, and
294
+ a detour that routes a trip through a stop its static schedule never
295
+ served shows up there.
296
+ - **Schedule over a range**: `scheduled_departures(stops, start, end)` is
297
+ the calendar query — every departure between two instants, schedule only,
298
+ no limit and no grace, rather than `get_arrivals` stretched to days.
299
+ - **Service calendars are answerable**: `services_on(date)` returns the
300
+ service ids running on a GTFS service date — `calendar.txt` resolved
301
+ against `calendar_dates` exceptions, removals winning when a producer
302
+ lists both types for one date — and every row carries its `service_id`,
303
+ so "does this trip run next Tuesday" needs no second arrivals query.
304
+ - **GBFS ids resolve**: `get_vehicle_types()`, `get_pricing_plans()`,
305
+ `get_regions()`, and `get_system_alerts()` turn the `vehicle_type_id`,
306
+ `pricing_plan_id`, and `region_id` on stations and vehicles into records.
307
+ All four documents are optional in GBFS, so an unpublished one is `[]`
308
+ rather than an error.
271
309
  - **Static metadata accessors**: `transit.agencies`, `transit.feed_info`
272
310
  (publisher, version, validity dates — useful for staleness checks), and
273
311
  `headsigns_serving()` alongside the stop/route helpers.
274
- - **Alert scoping**: `ServiceAlert` carries `route_ids`, `stop_ids`, and
275
- `trip_ids`; an alert is agency-wide only when all three are empty.
276
- `is_active(at)` evaluates its active periods.
277
- - **GBFS extras**: `rental_uris` deep links on stations and vehicles,
278
- `get_system_info()`, and TTL-based document caching.
312
+ - **Alert scoping covers every selector GTFS-RT offers**: `ServiceAlert`
313
+ carries `agency_ids`, `route_ids`, `route_types`, `direction_ids`,
314
+ `stop_ids`, and `trip_ids` — an alert is feed-wide only when *all* of them
315
+ are empty. Collecting a subset is not a missing nicety but a correctness
316
+ bug: an alert scoped to one agency, or to a whole mode, would otherwise
317
+ read as applying everywhere. `is_active(at)` evaluates its active periods.
318
+ - **GBFS exposes what the documents carry**: the full station surface
319
+ (`is_installed` alongside `is_renting`/`is_returning` — a station removed
320
+ from the street is not "operational"; disabled counts, address, region,
321
+ virtual-station flag), free-floating vehicle docking and fuel state, and a
322
+ `SystemInfo` with the operator's contact, licensing, and terms URLs.
323
+ `last_reported` is exposed on both stations and vehicles so you can tell
324
+ fresh data from stale, and is parsed from either GBFS 2.x POSIX seconds or
325
+ 3.0 RFC3339. Plus `rental_uris` deep links and TTL-based document caching.
279
326
  - **`cache_dir` strongly recommended**: the static index is cached on disk
280
327
  keyed by feed, validated against the dataset ID, so restarts are instant and
281
328
  rebuilds only happen when the agency publishes a new dataset
@@ -306,6 +353,45 @@ Notes on direct mode:
306
353
  design, with no server-side geo-query.
307
354
  - **Timestamps are tz-aware UTC** throughout the feeds layer.
308
355
 
356
+ ## What this does not expose
357
+
358
+ Deliberate omissions, so you can tell "not supported" from "not found yet".
359
+
360
+ **GTFS files not ingested.** The static index reads `agency.txt`, `stops.txt`,
361
+ `routes.txt`, `trips.txt`, `stop_times.txt`, `calendar.txt`,
362
+ `calendar_dates.txt`, `frequencies.txt`, and `feed_info.txt`. Everything else
363
+ in the zip is ignored:
364
+
365
+ - `shapes.txt` — route geometry. Nothing here draws a line on a map, so trips
366
+ carry no `shape_id`.
367
+ - `transfers.txt` — no transfer rules, minimum transfer times, or
368
+ trip-to-trip continuations, and no journey planning across a transfer.
369
+ - `pathways.txt` / `levels.txt` — no in-station walking graph.
370
+ - `fare_attributes.txt` / `fare_rules.txt` and all GTFS-Fares v2 files — no
371
+ fares, zone pricing, or rider categories. (`Stop.zone_id` is exposed as a
372
+ raw cell, but nothing interprets it.)
373
+ - `translations.txt` — text is returned as the feed wrote it.
374
+
375
+ Service calendars **are** answerable — `services_on(date)` resolves
376
+ `calendar.txt` against `calendar_dates` exceptions, and rows carry their
377
+ `service_id` — but the raw weekday pattern and validity range behind a
378
+ service are not exposed as a model. `scheduled_departures(stops, start, end)`
379
+ covers the range query a calendar view needs.
380
+
381
+ **GTFS-RT: trip shapes.** The RT `shape` entity (a detour's new geometry) is
382
+ not read, for the same reason `shapes.txt` is not: nothing here draws a line
383
+ on a map. Detours themselves ARE applied — see *Detours are applied, not
384
+ annotated* — and the `stop` entities they define are read.
385
+
386
+ **GBFS endpoints not fetched.** `geofencing_zones`, because it is GeoJSON
387
+ polygon geometry while zones here are deliberately circles — supporting it
388
+ means polygon containment, which is a geometry feature rather than another
389
+ document. And `system_hours`, which GBFS 3.0 removed in favour of
390
+ `system_information.opening_hours` (exposed as `SystemInfo.opening_hours`).
391
+
392
+ **Behaviour, not data.** There is no polling loop or scheduler (see *Pull, not
393
+ push*), no write access of any kind, and no cross-feed journey planning.
394
+
309
395
  ## Error handling
310
396
 
311
397
  All errors derive from `MobilityDatabaseError`. The catalog and feeds layers
@@ -391,7 +477,7 @@ The suite combines example-based, property-based, and conformance testing:
391
477
  resolver at volume), and `start_date`/`start_time` instance matching over
392
478
  windows containing two service-day instances of the same trip;
393
479
  - the circular-zone geometry (`in_circle`'s bbox prefilter is checked
394
- against the exact haversine distance at generated boundary points);
480
+ against the exact great-circle distance at generated boundary points);
395
481
  - GBFS field parsing (`_localized`, `_version_key`, station/vehicle merging)
396
482
  and GTFS-RT protobuf parsing, both checked for **totality** — every
397
483
  generated input must produce a typed result or a documented
@@ -123,7 +123,10 @@ async def main() -> None:
123
123
  for arrival in arrivals:
124
124
  when = arrival.predicted_departure or arrival.scheduled_departure
125
125
  live = "live" if arrival.realtime else "scheduled"
126
- print(f"{arrival.route_name} -> {arrival.headsign}: {when} ({live})")
126
+ # .stop and .route are the whole static records: platform codes,
127
+ # coordinates, route_type and route colours all come along.
128
+ route = arrival.route.display_name if arrival.route else arrival.route_id
129
+ print(f"{route} -> {arrival.headsign}: {when} ({live})")
127
130
 
128
131
  # Origin→destination: the next departures from stop A on trips that
129
132
  # later reach stop B, with the same realtime overlay. is_first/is_last
@@ -132,7 +135,8 @@ async def main() -> None:
132
135
  nearby_stops[0].id, nearby_stops[1].id, limit=2
133
136
  )
134
137
  for trip in trips:
135
- print(trip.route_name, trip.scheduled_departure, trip.is_last)
138
+ name = trip.route.display_name if trip.route else trip.route_id
139
+ print(name, trip.scheduled_departure, trip.is_last)
136
140
 
137
141
  vehicles = await transit.get_vehicles()
138
142
  alerts = await transit.get_alerts()
@@ -229,6 +233,19 @@ Notes on direct mode:
229
233
  information, `NO_DATA` makes a stop schedule-only, `SKIPPED` suppresses it
230
234
  (and any origin→destination row boarding or alighting there), and the
231
235
  trip-level delay covers stops no StopTimeUpdate reaches.
236
+ - **Rows carry whole records, not copied columns**: `StopArrival`,
237
+ `UpcomingTrip`, and `VehiclePosition` each expose the full `Stop` and
238
+ `Route` they refer to, so platform codes, coordinates, route colours and
239
+ `route_type` are reachable without a second lookup — use
240
+ `route.display_name` / `stop.name` for the human-readable strings. The raw
241
+ `stop_id`/`route_id` stay alongside, since those are what feeds reference
242
+ and what filters key on; a `route_id` naming a route absent from
243
+ `routes.txt` leaves `route` as `None` rather than inventing one.
244
+ - **Vehicle positions name their trip instance**: `VehiclePosition` carries
245
+ the parsed `trip_start_date`/`trip_start_secs`, the pair a GTFS-RT
246
+ `TripDescriptor` uses to address one run. That is what lets two buses out
247
+ on the same headway-based trip be told apart — without it, concurrent
248
+ repetitions of one template trip are indistinguishable.
232
249
  - **The full descriptive surface is exposed, typed by shape**: closed GTFS
233
250
  vocabularies are enums (`WheelchairAccess`, `BikesAllowed`,
234
251
  `PickupDropOffType`, `StopLocationType`, alert cause/effect/severity,
@@ -244,14 +261,44 @@ Notes on direct mode:
244
261
  fails the build, because a wrong departure time or a wrong call order is
245
262
  worse than no feed at all. A malformed **descriptive** cell still degrades
246
263
  to `None`.
264
+ - **Detours are applied, not annotated**: a GTFS-RT `TripModifications`
265
+ entity REPLACES a span of a trip's calls, so a board that ignored it
266
+ would keep showing departures at stops the vehicle no longer serves, and
267
+ would miss `propagated_modification_delay` on every stop after the
268
+ detour. Replacement times are measured from the reference stop the spec
269
+ names, a replacement stop may be defined only by an RT `Stop` entity, and
270
+ a detour that routes a trip through a stop its static schedule never
271
+ served shows up there.
272
+ - **Schedule over a range**: `scheduled_departures(stops, start, end)` is
273
+ the calendar query — every departure between two instants, schedule only,
274
+ no limit and no grace, rather than `get_arrivals` stretched to days.
275
+ - **Service calendars are answerable**: `services_on(date)` returns the
276
+ service ids running on a GTFS service date — `calendar.txt` resolved
277
+ against `calendar_dates` exceptions, removals winning when a producer
278
+ lists both types for one date — and every row carries its `service_id`,
279
+ so "does this trip run next Tuesday" needs no second arrivals query.
280
+ - **GBFS ids resolve**: `get_vehicle_types()`, `get_pricing_plans()`,
281
+ `get_regions()`, and `get_system_alerts()` turn the `vehicle_type_id`,
282
+ `pricing_plan_id`, and `region_id` on stations and vehicles into records.
283
+ All four documents are optional in GBFS, so an unpublished one is `[]`
284
+ rather than an error.
247
285
  - **Static metadata accessors**: `transit.agencies`, `transit.feed_info`
248
286
  (publisher, version, validity dates — useful for staleness checks), and
249
287
  `headsigns_serving()` alongside the stop/route helpers.
250
- - **Alert scoping**: `ServiceAlert` carries `route_ids`, `stop_ids`, and
251
- `trip_ids`; an alert is agency-wide only when all three are empty.
252
- `is_active(at)` evaluates its active periods.
253
- - **GBFS extras**: `rental_uris` deep links on stations and vehicles,
254
- `get_system_info()`, and TTL-based document caching.
288
+ - **Alert scoping covers every selector GTFS-RT offers**: `ServiceAlert`
289
+ carries `agency_ids`, `route_ids`, `route_types`, `direction_ids`,
290
+ `stop_ids`, and `trip_ids` — an alert is feed-wide only when *all* of them
291
+ are empty. Collecting a subset is not a missing nicety but a correctness
292
+ bug: an alert scoped to one agency, or to a whole mode, would otherwise
293
+ read as applying everywhere. `is_active(at)` evaluates its active periods.
294
+ - **GBFS exposes what the documents carry**: the full station surface
295
+ (`is_installed` alongside `is_renting`/`is_returning` — a station removed
296
+ from the street is not "operational"; disabled counts, address, region,
297
+ virtual-station flag), free-floating vehicle docking and fuel state, and a
298
+ `SystemInfo` with the operator's contact, licensing, and terms URLs.
299
+ `last_reported` is exposed on both stations and vehicles so you can tell
300
+ fresh data from stale, and is parsed from either GBFS 2.x POSIX seconds or
301
+ 3.0 RFC3339. Plus `rental_uris` deep links and TTL-based document caching.
255
302
  - **`cache_dir` strongly recommended**: the static index is cached on disk
256
303
  keyed by feed, validated against the dataset ID, so restarts are instant and
257
304
  rebuilds only happen when the agency publishes a new dataset
@@ -282,6 +329,45 @@ Notes on direct mode:
282
329
  design, with no server-side geo-query.
283
330
  - **Timestamps are tz-aware UTC** throughout the feeds layer.
284
331
 
332
+ ## What this does not expose
333
+
334
+ Deliberate omissions, so you can tell "not supported" from "not found yet".
335
+
336
+ **GTFS files not ingested.** The static index reads `agency.txt`, `stops.txt`,
337
+ `routes.txt`, `trips.txt`, `stop_times.txt`, `calendar.txt`,
338
+ `calendar_dates.txt`, `frequencies.txt`, and `feed_info.txt`. Everything else
339
+ in the zip is ignored:
340
+
341
+ - `shapes.txt` — route geometry. Nothing here draws a line on a map, so trips
342
+ carry no `shape_id`.
343
+ - `transfers.txt` — no transfer rules, minimum transfer times, or
344
+ trip-to-trip continuations, and no journey planning across a transfer.
345
+ - `pathways.txt` / `levels.txt` — no in-station walking graph.
346
+ - `fare_attributes.txt` / `fare_rules.txt` and all GTFS-Fares v2 files — no
347
+ fares, zone pricing, or rider categories. (`Stop.zone_id` is exposed as a
348
+ raw cell, but nothing interprets it.)
349
+ - `translations.txt` — text is returned as the feed wrote it.
350
+
351
+ Service calendars **are** answerable — `services_on(date)` resolves
352
+ `calendar.txt` against `calendar_dates` exceptions, and rows carry their
353
+ `service_id` — but the raw weekday pattern and validity range behind a
354
+ service are not exposed as a model. `scheduled_departures(stops, start, end)`
355
+ covers the range query a calendar view needs.
356
+
357
+ **GTFS-RT: trip shapes.** The RT `shape` entity (a detour's new geometry) is
358
+ not read, for the same reason `shapes.txt` is not: nothing here draws a line
359
+ on a map. Detours themselves ARE applied — see *Detours are applied, not
360
+ annotated* — and the `stop` entities they define are read.
361
+
362
+ **GBFS endpoints not fetched.** `geofencing_zones`, because it is GeoJSON
363
+ polygon geometry while zones here are deliberately circles — supporting it
364
+ means polygon containment, which is a geometry feature rather than another
365
+ document. And `system_hours`, which GBFS 3.0 removed in favour of
366
+ `system_information.opening_hours` (exposed as `SystemInfo.opening_hours`).
367
+
368
+ **Behaviour, not data.** There is no polling loop or scheduler (see *Pull, not
369
+ push*), no write access of any kind, and no cross-feed journey planning.
370
+
285
371
  ## Error handling
286
372
 
287
373
  All errors derive from `MobilityDatabaseError`. The catalog and feeds layers
@@ -367,7 +453,7 @@ The suite combines example-based, property-based, and conformance testing:
367
453
  resolver at volume), and `start_date`/`start_time` instance matching over
368
454
  windows containing two service-day instances of the same trip;
369
455
  - the circular-zone geometry (`in_circle`'s bbox prefilter is checked
370
- against the exact haversine distance at generated boundary points);
456
+ against the exact great-circle distance at generated boundary points);
371
457
  - GBFS field parsing (`_localized`, `_version_key`, station/vehicle merging)
372
458
  and GTFS-RT protobuf parsing, both checked for **totality** — every
373
459
  generated input must produce a typed result or a documented
@@ -1,6 +1,6 @@
1
1
  """Constants for aiomobilitydatabase."""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.5.0"
4
4
 
5
5
  PROD_BASE_URL = "https://api.mobilitydatabase.org"
6
6
  QA_BASE_URL = "https://api-qa.mobilitydatabase.org"
@@ -26,14 +26,18 @@ from .models import (
26
26
  Agency,
27
27
  AlertCause,
28
28
  AlertEffect,
29
+ AlertImage,
29
30
  AlertSeverity,
30
31
  ArrivalsQuery,
31
32
  BikesAllowed,
33
+ CarriageDetail,
32
34
  CongestionLevel,
33
35
  FeedInfo,
36
+ GbfsAlert,
34
37
  GbfsVehicle,
35
38
  OccupancyStatus,
36
39
  PickupDropOffType,
40
+ PricingPlan,
37
41
  Route,
38
42
  ServiceAlert,
39
43
  StaticBuildProgress,
@@ -43,9 +47,11 @@ from .models import (
43
47
  StopArrival,
44
48
  StopLocationType,
45
49
  SystemInfo,
50
+ SystemRegion,
46
51
  UpcomingTrip,
47
52
  VehiclePosition,
48
53
  VehicleStopStatus,
54
+ VehicleType,
49
55
  WheelchairAccess,
50
56
  )
51
57
  from .transit import TransitFeedHandle
@@ -54,19 +60,23 @@ __all__ = [
54
60
  "Agency",
55
61
  "AlertCause",
56
62
  "AlertEffect",
63
+ "AlertImage",
57
64
  "AlertSeverity",
58
65
  "ArrivalsQuery",
59
66
  "BikesAllowed",
67
+ "CarriageDetail",
60
68
  "Circle",
61
69
  "CongestionLevel",
62
70
  "FeedInfo",
63
71
  "FeedParseError",
72
+ "GbfsAlert",
64
73
  "GbfsFeedHandle",
65
74
  "GbfsVehicle",
66
75
  "MobilityFeedsClient",
67
76
  "MobilityFeedsError",
68
77
  "OccupancyStatus",
69
78
  "PickupDropOffType",
79
+ "PricingPlan",
70
80
  "Route",
71
81
  "ServiceAlert",
72
82
  "SourceAuthenticationError",
@@ -79,9 +89,11 @@ __all__ = [
79
89
  "StopArrival",
80
90
  "StopLocationType",
81
91
  "SystemInfo",
92
+ "SystemRegion",
82
93
  "TransitFeedHandle",
83
94
  "UpcomingTrip",
84
95
  "VehiclePosition",
85
96
  "VehicleStopStatus",
97
+ "VehicleType",
86
98
  "WheelchairAccess",
87
99
  ]
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import math
6
6
  import time
7
7
  from collections.abc import Mapping
8
+ from datetime import UTC, date, datetime
8
9
  from http import HTTPStatus
9
10
  from typing import TYPE_CHECKING, Any
10
11
 
@@ -13,7 +14,15 @@ import aiohttp
13
14
  from .const import GBFS_LANGUAGE_PREFERENCE
14
15
  from .exceptions import FeedParseError, SourceConnectionError
15
16
  from .geo import Circle, in_circle
16
- from .models import GbfsVehicle, Station, SystemInfo
17
+ from .models import (
18
+ GbfsAlert,
19
+ GbfsVehicle,
20
+ PricingPlan,
21
+ Station,
22
+ SystemInfo,
23
+ SystemRegion,
24
+ VehicleType,
25
+ )
17
26
  from .rt import _require_http_url # deliberate friend access: shared URL guard
18
27
 
19
28
  if TYPE_CHECKING:
@@ -127,6 +136,97 @@ def _vehicle_types(value: Any) -> dict[str, int] | None:
127
136
  return types or None
128
137
 
129
138
 
139
+ def _reported_at(value: Any) -> datetime | None:
140
+ """Parse a GBFS ``last_reported``, which changed type across versions.
141
+
142
+ 2.x ships POSIX seconds, 3.0 ships an RFC3339 string. Anything else --
143
+ including a bool, which is an int in Python -- degrades to None like
144
+ every other malformed scalar at this boundary.
145
+ """
146
+ if isinstance(value, bool):
147
+ return None
148
+ if isinstance(value, int | float):
149
+ try:
150
+ return datetime.fromtimestamp(value, tz=UTC)
151
+ except (OverflowError, OSError, ValueError):
152
+ return None
153
+ if isinstance(value, str):
154
+ try:
155
+ parsed = datetime.fromisoformat(value)
156
+ except ValueError:
157
+ return None
158
+ # A naive RFC3339 value is UTC by GBFS's own definition.
159
+ return parsed if parsed.tzinfo else parsed.replace(tzinfo=UTC)
160
+ return None
161
+
162
+
163
+ def _iso_date(value: Any) -> date | None:
164
+ """Parse a GBFS ``YYYY-MM-DD`` cell, degrading to None on anything else."""
165
+ if not isinstance(value, str):
166
+ return None
167
+ try:
168
+ return date.fromisoformat(value)
169
+ except ValueError:
170
+ return None
171
+
172
+
173
+ def _languages(data: Mapping[str, Any]) -> list[str]:
174
+ """GBFS 3.0 ``languages`` (array) or 2.x ``language`` (single string)."""
175
+ raw = data.get("languages")
176
+ if isinstance(raw, list):
177
+ return [item for item in raw if isinstance(item, str) and item]
178
+ single = data.get("language")
179
+ return [single] if isinstance(single, str) and single else []
180
+
181
+
182
+ def _plain_text(value: Any) -> str | None:
183
+ """Return a verbatim string cell; empty or non-string degrades to None."""
184
+ return value if isinstance(value, str) and value else None
185
+
186
+
187
+ def _count(value: Any) -> int | None:
188
+ """Return a non-negative count; bools and junk degrade to None."""
189
+ if isinstance(value, bool) or not isinstance(value, int):
190
+ return None
191
+ return value if value >= 0 else None
192
+
193
+
194
+ def _number(value: Any) -> float | None:
195
+ """Return a finite number; bools, strings and junk degrade to None.
196
+
197
+ An int wider than a float can hold raises OverflowError from
198
+ ``float()``, so the conversion is guarded rather than the result
199
+ checked -- a producer's absurd integer is malformed input like any
200
+ other, and this boundary degrades instead of raising (see
201
+ ``_ttl_seconds``).
202
+ """
203
+ if isinstance(value, bool) or not isinstance(value, int | float):
204
+ return None
205
+ try:
206
+ converted = float(value)
207
+ except (OverflowError, ValueError):
208
+ return None
209
+ return converted if math.isfinite(converted) else None
210
+
211
+
212
+ def _id_list(value: Any) -> list[str]:
213
+ """Ids from a GBFS array, dropping entries that are not usable ids."""
214
+ if not isinstance(value, list):
215
+ return []
216
+ return [found for item in value if (found := _record_id(item)) is not None]
217
+
218
+
219
+ def _alert_times(value: Any) -> list[tuple[datetime | None, datetime | None]]:
220
+ """Return a GBFS alert's ``times`` array as (start, end) pairs."""
221
+ if not isinstance(value, list):
222
+ return []
223
+ return [
224
+ (_reported_at(item.get("start")), _reported_at(item.get("end")))
225
+ for item in value
226
+ if isinstance(item, Mapping)
227
+ ]
228
+
229
+
130
230
  def _rows(document: Mapping[str, Any], key: str) -> list[Mapping[str, Any]]:
131
231
  """Extract the ``data.<key>`` row list, keeping object-shaped rows only.
132
232
 
@@ -337,10 +437,93 @@ class GbfsFeedHandle:
337
437
  return SystemInfo(
338
438
  system_id=system_id,
339
439
  name=_localized(data.get("name")),
440
+ short_name=_localized(data.get("short_name")),
340
441
  operator=_localized(data.get("operator")),
341
- timezone=data.get("timezone"),
442
+ timezone=_plain_text(data.get("timezone")),
443
+ languages=_languages(data),
444
+ url=_plain_text(data.get("url")),
445
+ purchase_url=_plain_text(data.get("purchase_url")),
446
+ start_date=_iso_date(data.get("start_date")),
447
+ phone_number=_plain_text(data.get("phone_number")),
448
+ email=_plain_text(data.get("email")),
449
+ feed_contact_email=_plain_text(data.get("feed_contact_email")),
450
+ license_url=_plain_text(data.get("license_url")),
451
+ terms_url=_plain_text(data.get("terms_url")),
452
+ privacy_url=_plain_text(data.get("privacy_url")),
453
+ opening_hours=_plain_text(data.get("opening_hours")),
342
454
  )
343
455
 
456
+ async def _optional_rows(self, name: str, key: str) -> list[Mapping[str, Any]]:
457
+ """Rows from a document a system need not publish at all.
458
+
459
+ Every one of these endpoints is optional in GBFS, and discovery
460
+ only lists what a system actually serves -- so "not published"
461
+ is a normal answer meaning "no such records", not a failure.
462
+ """
463
+ if name not in self._endpoints:
464
+ return []
465
+ return _rows(await self._document(name), key)
466
+
467
+ async def get_vehicle_types(self) -> list[VehicleType]:
468
+ """Vehicle types, resolving the ids stations and vehicles reference."""
469
+ return [
470
+ VehicleType(
471
+ id=type_id,
472
+ form_factor=_plain_text(row.get("form_factor")),
473
+ propulsion_type=_plain_text(row.get("propulsion_type")),
474
+ name=_localized(row.get("name")),
475
+ max_range_m=_number(row.get("max_range_meters")),
476
+ rider_capacity=_count(row.get("rider_capacity")),
477
+ )
478
+ for row in await self._optional_rows("vehicle_types", "vehicle_types")
479
+ if (type_id := _record_id(row.get("vehicle_type_id"))) is not None
480
+ ]
481
+
482
+ async def get_pricing_plans(self) -> list[PricingPlan]:
483
+ """Pricing plans, resolving a vehicle's ``pricing_plan_id``."""
484
+ return [
485
+ PricingPlan(
486
+ id=plan_id,
487
+ name=_localized(row.get("name")),
488
+ currency=_plain_text(row.get("currency")),
489
+ price=_number(row.get("price")),
490
+ is_taxable=_as_bool(row.get("is_taxable")),
491
+ description=_localized(row.get("description")),
492
+ )
493
+ for row in await self._optional_rows("system_pricing_plans", "plans")
494
+ if (plan_id := _record_id(row.get("plan_id"))) is not None
495
+ ]
496
+
497
+ async def get_regions(self) -> list[SystemRegion]:
498
+ """Service regions, resolving a station's ``region_id``."""
499
+ return [
500
+ SystemRegion(id=region_id, name=_localized(row.get("name")))
501
+ for row in await self._optional_rows("system_regions", "regions")
502
+ if (region_id := _record_id(row.get("region_id"))) is not None
503
+ ]
504
+
505
+ async def get_system_alerts(self) -> list[GbfsAlert]:
506
+ """GBFS system alerts.
507
+
508
+ Named apart from the GTFS-RT ``get_alerts`` on the transit handle:
509
+ these scope to GBFS stations and regions, not routes and trips.
510
+ """
511
+ return [
512
+ GbfsAlert(
513
+ id=alert_id,
514
+ type=_plain_text(row.get("type")),
515
+ summary=_localized(row.get("summary")),
516
+ description=_localized(row.get("description")),
517
+ url=_plain_text(row.get("url")),
518
+ station_ids=_id_list(row.get("station_ids")),
519
+ region_ids=_id_list(row.get("region_ids")),
520
+ last_updated=_reported_at(row.get("last_updated")),
521
+ active_periods=_alert_times(row.get("times")),
522
+ )
523
+ for row in await self._optional_rows("system_alerts", "alerts")
524
+ if (alert_id := _record_id(row.get("alert_id"))) is not None
525
+ ]
526
+
344
527
  async def get_stations(self, zone: Circle | None = None) -> list[Station]:
345
528
  """Stations with information and status merged by station_id.
346
529
 
@@ -371,15 +554,36 @@ class GbfsFeedHandle:
371
554
  Station(
372
555
  id=station_id,
373
556
  name=_localized(info.get("name")),
557
+ short_name=_localized(info.get("short_name")),
374
558
  latitude=latitude,
375
559
  longitude=longitude,
376
- capacity=info.get("capacity"),
377
- bikes_available=status.get(
378
- "num_bikes_available", status.get("num_vehicles_available")
560
+ # Same _count guard as the disabled counts beside them:
561
+ # these are declared int | None, and a producer string
562
+ # would otherwise flow straight through the type.
563
+ capacity=_count(info.get("capacity")),
564
+ bikes_available=_count(
565
+ status.get(
566
+ "num_bikes_available",
567
+ status.get("num_vehicles_available"),
568
+ )
569
+ ),
570
+ docks_available=_count(status.get("num_docks_available")),
571
+ bikes_disabled=_count(
572
+ status.get(
573
+ "num_bikes_disabled",
574
+ status.get("num_vehicles_disabled"),
575
+ )
379
576
  ),
380
- docks_available=status.get("num_docks_available"),
577
+ docks_disabled=_count(status.get("num_docks_disabled")),
578
+ is_installed=_as_bool(status.get("is_installed")),
381
579
  is_renting=_as_bool(status.get("is_renting")),
382
580
  is_returning=_as_bool(status.get("is_returning")),
581
+ is_virtual_station=_as_bool(info.get("is_virtual_station")),
582
+ last_reported=_reported_at(status.get("last_reported")),
583
+ address=_plain_text(info.get("address")),
584
+ cross_street=_plain_text(info.get("cross_street")),
585
+ post_code=_plain_text(info.get("post_code")),
586
+ region_id=_record_id(info.get("region_id")),
383
587
  vehicle_types_available=_vehicle_types(
384
588
  status.get("vehicle_types_available")
385
589
  ),
@@ -421,8 +625,17 @@ class GbfsFeedHandle:
421
625
  longitude=longitude,
422
626
  is_reserved=_as_bool(row.get("is_reserved")),
423
627
  is_disabled=_as_bool(row.get("is_disabled")),
424
- vehicle_type_id=row.get("vehicle_type_id"),
425
- current_range_m=row.get("current_range_meters"),
628
+ # _record_id, matching _vehicle_types and
629
+ # get_vehicle_types: a producer using numeric type ids
630
+ # would otherwise yield int 7 here and "7" there, and
631
+ # the VehicleType join would never match.
632
+ vehicle_type_id=_record_id(row.get("vehicle_type_id")),
633
+ current_range_m=_number(row.get("current_range_meters")),
634
+ current_fuel_percent=_number(row.get("current_fuel_percent")),
635
+ last_reported=_reported_at(row.get("last_reported")),
636
+ station_id=_record_id(row.get("station_id")),
637
+ home_station_id=_record_id(row.get("home_station_id")),
638
+ pricing_plan_id=_record_id(row.get("pricing_plan_id")),
426
639
  rental_uris=_rental_uris(row.get("rental_uris")),
427
640
  )
428
641
  )