Expand description
The General Transit Feed Specification (GTFS) is a commonly used model to represent public transit data.
This crates brings serde structures of this model and helpers to read GTFS files.
To get started, see Gtfs.
§What is GTFS
A Gtfs feed is a collection of CSV files (often bundled as a zip file). Each file represents a collection of one type (stops, lines, etc.) that have relationships through unique identifiers.
This crate reads a feed, deserializes the objects into Rust structs and verifies the relationships.
§Design decisions
§Two representations
The RawGtfs representation holds the objects as close as possible to their CSV representation. This allows to check invalid references.
Gtfs re-organizes a bit the data. For instance all the StopTime are included within their corresponding Trip and cannot be accessed directly. If an object references a non existing Id it will be an error.
§Use of Enum
Many values are integers that are actually enumerations of certain values. We always use Rust enums, like LocationType to represent them, and not the integer value.
§Reference
We try to stick as closely as possible to the reference. Optional fields are std::option, while missing mandatory elements will result in an error. If a default value is defined, we will use it.
There are two references https://gtfs.org/reference/static and https://developers.google.com/transit/gtfs/reference. They are mostly the same, even if google’s specification has some extensions.
§Renaming
We kept some names even if they can be confusing (a Calendar will be referenced by service_id
), but we strip the object type (route_short_name
is Route::short_name).
Re-exports§
pub use error::Error;
Modules§
- error
- Module for the error management
Structs§
- Agency
- General informations about the agency running the network. See https://gtfs.org/reference/static/#agencytxt
- Calendar
- A calender describes on which days the vehicle runs. See https://gtfs.org/reference/static/#calendartxt
- Calendar
Date - Defines a specific date that can be added or removed from a Calendar. See https://gtfs.org/reference/static/#calendar_datestxt
- Fare
Attribute - Defines one possible fare. See https://gtfs.org/reference/static/#fare_attributestxt
- Fare
Rule - Defines one possible fare. See https://gtfs.org/schedule/reference/#fare_rulestxt
- Feed
Info - Meta-data about the feed. See https://gtfs.org/reference/static/#feed_infotxt
- Frequency
- Timetables can be defined by the frequency of their vehicles. See <https://gtfs.org/reference/static/#frequenciestxt>
- Gtfs
- Data structure with all the GTFS objects
- Gtfs
Reader - Allows to parameterize how the parsing library behaves
- Pathway
- Pathway going from a stop to another.
- RawFrequency
- A Frequency before being merged into the corresponding Trip
- RawGtfs
- Data structure that map the GTFS csv with little intelligence
- RawPathway
- A graph representation to describe subway or train, with nodes (the locations) and edges (the pathways).
- RawStop
Time - A StopTime where the relations with Trip and Stop have not been tested
- RawTransfer
- Transfer information between stops before merged into Stop
- RawTranslation
- Raw structure to hold translations as defined in the GTFS file. See https://gtfs.org/schedule/reference/#translationstxt
- RawTrip
- A Trip where the relationships with other objects have not been checked
- Route
- A route is a commercial line (there can be various stop sequences for a same line). See https://gtfs.org/reference/static/#routestxt
- Shape
- A single geographical point decribing the shape of a Trip. See https://gtfs.org/reference/static/#shapestxt
- Stop
- A physical stop, station or area. See https://gtfs.org/reference/static/#stopstxt
- Stop
Time - The moment where a vehicle, running on Trip stops at a Stop. See https://gtfs.org/reference/static/#stopstxt
- Stop
Transfer - Transfer information between stops
- Trip
- A Trip is a vehicle that follows a sequence of StopTime on certain days. See https://gtfs.org/reference/static/#tripstxt
Enums§
- Availability
- Generic enum to define if a service (like wheelchair boarding) is available
- Bikes
Allowed Type - Is the [Trip] accessible with a bike. See https://gtfs.org/reference/static/#tripstxt
bikes_allowed
- Continuous
Pickup Drop Off - Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path
- Direction
Type - Defines the direction of a [Trip], only for display, not for routing. See https://gtfs.org/reference/static/#tripstxt
direction_id
- Exact
Times - Defines if the [Frequency] is exact (the vehicle runs exactly every n minutes) or not
- Exception
- Defines if a [CalendarDate] is added or deleted from a [Calendar]
- Location
Type - Describes the kind of [Stop]. See https://gtfs.org/reference/static/#stopstxt
location_type
- Object
Type - All the objects type from the GTFS specification that this library reads
- Pathway
Direction Type - Indicates in which direction the pathway can be used
- Pathway
Mode - Type of pathway between [from_stop] and [to_stop]
- Payment
Method - Defines where a [FareAttribute] can be paid
- Pickup
Drop OffType - Describes if and how a traveller can board or alight the vehicle. See https://gtfs.org/reference/static/#stop_timestxt
pickup_type
anddropoff_type
- Route
Type - Describes the kind of [Route]. See https://gtfs.org/reference/static/#routestxt
route_type
- Source
Format - Format of the data
- Timepoint
Type - Describes if the stop time is exact or not. See https://gtfs.org/reference/static/#stop_timestxt
timepoint
- Transfer
Type - Defines the type of a [StopTransfer]
- Transfers
- Defines how many transfers can be done with on [FareAttribute]