Struct gtfs_structures::Gtfs

source ·
pub struct Gtfs {
    pub read_duration: i64,
    pub calendar: HashMap<String, Calendar>,
    pub calendar_dates: HashMap<String, Vec<CalendarDate>>,
    pub stops: HashMap<String, Arc<Stop>>,
    pub routes: HashMap<String, Route>,
    pub trips: HashMap<String, Trip>,
    pub agencies: Vec<Agency>,
    pub shapes: HashMap<String, Vec<Shape>>,
    pub fare_attributes: HashMap<String, FareAttribute>,
    pub feed_info: Vec<FeedInfo>,
}
Expand description

Data structure with all the GTFS objects

This structure is easier to use than the RawGtfs structure as some relationships are parsed to be easier to use.

If you want to configure the behaviour (e.g. skipping : StopTime), see crate::GtfsReader for more personalisation

This is probably the entry point you want to use:

let gtfs = gtfs_structures::Gtfs::new("fixtures/zips/gtfs.zip")?;
assert_eq!(gtfs.stops.len(), 5);

The StopTime are accessible from the Trip

Fields§

§read_duration: i64

Time needed to read and parse the archive in milliseconds

§calendar: HashMap<String, Calendar>

All Calendar by service_id

§calendar_dates: HashMap<String, Vec<CalendarDate>>

All calendar dates grouped by service_id

§stops: HashMap<String, Arc<Stop>>

All stop by stop_id. Stops are in an Arc because they are also referenced by each StopTime

§routes: HashMap<String, Route>

All routes by route_id

§trips: HashMap<String, Trip>

All trips by trip_id

§agencies: Vec<Agency>

All agencies. They can not be read by agency_id, as it is not a required field

§shapes: HashMap<String, Vec<Shape>>

All shapes by shape_id

§fare_attributes: HashMap<String, FareAttribute>

All fare attributes by fare_id

§feed_info: Vec<FeedInfo>

All feed information. There is no identifier

Implementations§

Prints on stdout some basic statistics about the GTFS file (numbers of elements for each object). Mostly to be sure that everything was read

Reads from an url (if starts with "http"), or a local path (either a directory or zipped file)

To read from an url, build with read-url feature See also Gtfs::from_url and Gtfs::from_path if you don’t want the library to guess

 Reads the GTFS from a local zip archive or local directory

Reads the GTFS from a remote url

The library must be built with the read-url feature

Asynchronously reads the GTFS from a remote url

The library must be built with the read-url feature

Reads for any object implementing std::io::Read and std::io::Seek

Mostly an internal function that abstracts reading from an url or local file

For a given a service_id and a starting date returns all the following day offset the vehicle runs

For instance if the start_date is 2021-12-20, [0, 4] means that the vehicle will run the 20th and 24th

It will consider use both Calendar and CalendarDate (both added and removed)

Gets a Stop by its stop_id

Gets a Trip by its trip_id

Gets a Route by its route_id

Gets a Calendar by its service_id

Gets all CalendarDate of a service_id

Gets all Shape points of a shape_id

Gets a FareAttribute by its fare_id

Trait Implementations§

Returns the “default value” for a type. Read more

Tries to build a Gtfs from a RawGtfs

It might fail if some mandatory files couldn’t be read or if there are references to other objects that are invalid.

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more