bolster.data_sources.translink.timetable
Translink timetable — trip stop sequences from ATCO-CIF archives.
Parses the QD/QS/QO/QI/QT records from the Metro/Glider and Ulsterbus/GoldLine CIF zips to build a queryable trip database: for any stop you can find all services that call there, and for any pair of stops you can find direct services that serve both in order.
Record formats parsed: - QD Journey header: operator, line number, description - QS Journey schedule: departure time, date range, days of week, direction - QO7 Origin timing point: first stop ATCO, departure time - QI7 Intermediate timing point: stop ATCO, arrival, departure times - QT7 Terminus timing point: last stop ATCO, arrival time
ATCO code mapping: trip records store 11-digit codes (e.g. 00000009264)
while QL/QB stop records use 12-digit codes starting with 7
(e.g. 700000009264). The relation is stop_atco = '7' + trip_atco[0:11].
Example
>>> trips = get_trip_index()
>>> trips["700000001661"] # stops serving Victoria Square
[TripStop(...), ...]
Attributes
Classes
A single stop within a trip's stop sequence. |
|
A single scheduled trip (one journey on one day pattern). |
Functions
|
Return the stop → [(Trip, TripStop)] inverted index. |
|
Return all scheduled trips that call at stop_atco. |
|
Return all direct trips that serve origin_atco then dest_atco. |
Module Contents
- class bolster.data_sources.translink.timetable.TripStop[source]
A single stop within a trip’s stop sequence.
- class bolster.data_sources.translink.timetable.Trip[source]
A single scheduled trip (one journey on one day pattern).
- bolster.data_sources.translink.timetable.get_trip_index(force_refresh=False)[source]
Return the stop → [(Trip, TripStop)] inverted index.
Built on first call and cached in-process for the lifetime of the Python process. The underlying CIF zips are cached on disk for one week.
- bolster.data_sources.translink.timetable.find_services_at_stop(stop_atco, force_refresh=False)[source]
Return all scheduled trips that call at stop_atco.
- bolster.data_sources.translink.timetable.find_direct_trips(origin_atco, dest_atco, force_refresh=False)[source]
Return all direct trips that serve origin_atco then dest_atco.
A trip is considered direct if both stops appear in its stop sequence and the origin stop appears before the destination stop.
- Parameters:
- Returns:
List of
(Trip, origin_TripStop, dest_TripStop)tuples, ordered by the trip’s origin departure time. Empty list if no direct service runs between the two stops.- Return type: