Import structure
The GTFS import takes as input a zip file containing csv files.
The CSV files processed by the import :
- agencies.txt
- stops.txt
- routes.txt
- trips.txt
- stop_times.txt
- calendars.txt
- calendar_dates.txt
Theses files won't be processed :
- fare_attributes.txt
- fare_rules.txt
- shapes.txt
- frequencies.txt
- transfers.txt
- feed_info.txt
The CSV files must be compliant with the GTFS standard as defined in the official documentation.
Google's official documentation: https://developers.google.com/transit/gtfs/reference/
Some example GTFS files can be found at the following adress: https://developers.google.com/transit/gtfs/examples/gtfs-feed
Files processing
Files are processed in that order :
- agencies.txt
- stops.txt
- routes.txt
- calendars.txt
- calendar_dates.txt
- trips.txt
- stop_times.txt
agencies.txt
GTFS data validation
Mandatory attributes:
- agency_id
- agency_name
- agency_url
- agency_timezone
The agency_id attribute isn't mandatory in the GTFS profile, but Chouette::Companies are indexed with this identifier.
GTFS model to Chouette model conversion
A GTFS Agency is converted in a Chouette Company.
| GTFS Agency | Chouette::Company |
|---|---|
| agency_id | registration_number |
| agency_name | name |
| agency_url | url |
| agency_timezone | time_zone |
stops.txt
GTFS data validation
Mandatory attributes:
- stop_id
- stop_name
- stop_lat
- stop_lon
GTFS model to Chouette model conversion
A GTFS Stop is converted in a Chouette StopArea.
| GTFS Stop | Chouette::StopArea | GTFS | GTFS Strict |
|---|---|---|---|
| stop_id | registration_number | Mandatory | Mandatory |
| stop_name | name | Mandatory | Mandatory |
| stop_lat | latitude | Optionnal | Optionnal |
| stop_lon | longitude | Optionnal | Optionnal |
| location_type | area_type | Optionnal | Optionnal |
The Chouette StopArea default kind is "Commercial" and its confirmed_at attribute is the import time.
We use the parent_station GTFS attribute to find and associate the StopArea parent.
If the location_type GTFS attribut is "1" the area_type Chouette attribute will be "zdlp", otherwise it will be "zdep".
routes.txt
GTFS data validation
Mandatory attributes:
- route_id
- route_short_name
- route_long_name
The route_type attribute is mandatory in the GTFS profile but isn't imported in Chouette.
GTFS model to Chouette model conversion
A GTFS Route is converted in a Chouette Line.
| GTFS Route | Chouette::Line |
|---|---|
| route_id | registration_number |
| route_short_name | number |
| route_long_name | name |
| route_long_name | published_name |
| route_desc | comment |
| route_url | url |
We use the agency_id GTFS attribute to find and associate the Company to the Line.
calendars.txt
GTFS data validation
Mandatory attributes:
- service_id
- monday
- thuesday
- wednesday
- thursday
- friday
- saturday
- sunday
- start_date
- end_date
GTFS model to Chouette model conversion
A GTFS Calendar is converted in a combination of a Chouette Timetable and Period. The Timetable will define the Calendar service days, and its Period the begining and ending dates of the GTFS Calendar.
| GTFS Route | Chouette::TimeTable | Chouette::Period |
|---|---|---|
| monday | monday | - |
| thuesday | thuesday | - |
| wednesday | wednesday | - |
| thursday | thursday | - |
| friday | friday | - |
| saturday | saturday | - |
| sunday | sunday | - |
| start_date | - | period_start |
| end_date | - | period_end |
The service_id GTFS attribute is stored in the Chouette TimeTable comment attribute as: "Calendar [service_id]".
calendar_dates.txt
GTFS data validation
Mandatory attributes:
- service_id
- date
- exception_type
GTFS model to Chouette model conversion
A GTFS CalendarDate is converted in a Chouette Date associated with a TimeTable.
| GTFS CalendarDate | Chouette::Date |
|---|---|
| date | date |
| exception_type | in_out |
We use the service_id GTFS attribute to find and associate the TimeTable to the Date.
The in_out Chouette attribute is a boolean. If the exception_type GTFS attribute is "1" in_out will be "true", otherwise in_out will be "false".
trips.txt
GTFS data validation
Mandatory attributes:
- route_id
- service_id
- trip_id
GTFS model to Chouette model conversion
A GTFS Trip is converted in a combination of a Chouette Route, JourneyPattern, and VehicleJourney.
If the direction_id GTFS attribute is "1" then the Chouette Route wayback attribute will be "outbound", otherwise wayback will be "outbound".
The Chouette Route published_name and name attributes will be equal to the trip_short_name GTFS attribute if it's present, else to the trip_headsign attribute if it's present, or else to "OUTBOUND" or "INBOUND" depending on the direction_id GTFS attribute.
The Chouette JourneyPattern name attribute is equal to the Chouette Route name.
The Chouette VehicleJourney published_journey_name attribute is will be equal to the trip_headsign GTFS attribute if it exists, or else to the trip_id GTFS attribute.
We use the GTFS attribute route_id to find and associate the Line to the Chouette objects.
We use the GTFS attribute service_id to find and associate the TimeTeble to the VehicleJourney.
stop_times.txt
GTFS data validation
Mandatory attributes:
- trip_id
- arrival_time
- departure_time
- stop_id
- stop_sequence
GTFS model to Chouette model conversion
A GTFS StopTime is converted in a Chouette VehicleJourneyAtStop.
| GTFS StopTime | Chouette::VehicleJourneyAtStop |
|---|---|
| arrival_time | arrival_time |
| departure_time | departure_time |
We use the GTFS attribute trip_id to find and associate the VehicleJourney to the VehicleJourneyAtStop.
We use the GTFS attribute stop_id to find and associate the StopArea to the VehicleJourneyAtStop.
The Chouette VehicleJourneyAtStop are ordered in the JourneyPattern associated with the VehicleJourney based on the stop_sequence GTFS attribute.
For times occurring after midnight on the service day, the arrival_time and departure_time GTFS attributes can contain a value greater than 24:00:00. In the Chouette VehicleAtStop, arrival_time and departure_time are stored in a 24h format but we use the arrival_day_offset and departure_day_offset attributes to represent such times. If an hour in the GTFS file is greater than 24:00:00 its corresponding offset will be "1", otherwise it'll be "0".