Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C chouette-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 36
    • Merge requests 36
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Administrator
  • chouette-core
  • Wiki
  • GTFS Import

Last edited by Luc Donnet Oct 18, 2018
Page history
This is an old version of this page. You can view the most recent version or browse the history.

GTFS Import

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

Chouette try to import all GTFS datas that it can import in our internal models. We call GTFS checks for mandatories attributes or verify links between models.

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 checks Strict GTFS Check
stop_id registration_number Mandatory Mandatory
stop_name name Mandatory Mandatory
stop_lat latitude Optionnal Mandatory
stop_lon longitude Optionnal Mandatory
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_headsign GTFS attribute if it's present, else to the trip_short_name 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_short_name 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".

Clone repository

Architecture

  • Data Models
  • Class Diagram

Install and configure

  • installation manual
  • Optional Feature flags
  • Policy management (TODO)

Best practices in code

Rails code rules

  • Writing a migration
  • Writing a model
  • Writing a controller
  • Writing a view
  • Writing a policy (TODO)
  • Writing a feature (TODO)
  • I18n

Test code rules

  • Writing a spec
  • Writing a javascript test

Exchange format

Neptune

  • Import TODO
  • Export TODO

GTFS

  • Import
  • Export

Netex

  • Import TODO
  • Export TODO