pub struct Gtfs {
pub read_duration: Duration,
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 fare_rules: HashMap<String, Vec<FareRule>>,
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 or Shape), 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);
Fields§
§read_duration: Duration
Time needed to read and parse the archive
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>>
§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
fare_rules: HashMap<String, Vec<FareRule>>
All fare rules by fare_id
feed_info: Vec<FeedInfo>
All feed information. There is no identifier
Implementations§
Source§impl Gtfs
impl Gtfs
Sourcepub fn print_stats(&self)
pub fn print_stats(&self)
Prints on stdout some basic statistics about the GTFS file (numbers of elements for each object). Mostly to be sure that everything was read
Sourcepub fn new(gtfs: &str) -> Result<Gtfs, Error>
pub fn new(gtfs: &str) -> Result<Gtfs, Error>
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
Sourcepub fn from_path<P>(path: P) -> Result<Gtfs, Error>
pub fn from_path<P>(path: P) -> Result<Gtfs, Error>
Reads the GTFS from a local zip archive or local directory
Sourcepub fn from_url<U: IntoUrl>(url: U) -> Result<Gtfs, Error>
pub fn from_url<U: IntoUrl>(url: U) -> Result<Gtfs, Error>
Reads the GTFS from a remote url
The library must be built with the read-url feature
Sourcepub async fn from_url_async<U: IntoUrl>(url: U) -> Result<Gtfs, Error>
pub async fn from_url_async<U: IntoUrl>(url: U) -> Result<Gtfs, Error>
Asynchronously reads the GTFS from a remote url
The library must be built with the read-url feature
Sourcepub fn from_reader<T: Read + Seek>(reader: T) -> Result<Gtfs, Error>
pub fn from_reader<T: Read + Seek>(reader: T) -> Result<Gtfs, Error>
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
Sourcepub fn trip_days(&self, service_id: &str, start_date: NaiveDate) -> Vec<u16>
pub fn trip_days(&self, service_id: &str, start_date: NaiveDate) -> Vec<u16>
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)
Sourcepub fn get_route<'a>(&'a self, id: &str) -> Result<&'a Route, Error>
pub fn get_route<'a>(&'a self, id: &str) -> Result<&'a Route, Error>
Gets a Route by its route_id
Sourcepub fn get_calendar<'a>(&'a self, id: &str) -> Result<&'a Calendar, Error>
pub fn get_calendar<'a>(&'a self, id: &str) -> Result<&'a Calendar, Error>
Gets a Calendar by its service_id
Sourcepub fn get_calendar_date<'a>(
&'a self,
id: &str,
) -> Result<&'a Vec<CalendarDate>, Error>
pub fn get_calendar_date<'a>( &'a self, id: &str, ) -> Result<&'a Vec<CalendarDate>, Error>
Gets all CalendarDate of a service_id
Sourcepub fn get_shape<'a>(&'a self, id: &str) -> Result<&'a Vec<Shape>, Error>
pub fn get_shape<'a>(&'a self, id: &str) -> Result<&'a Vec<Shape>, Error>
Gets all Shape points of a shape_id
Sourcepub fn get_fare_attributes<'a>(
&'a self,
id: &str,
) -> Result<&'a FareAttribute, Error>
pub fn get_fare_attributes<'a>( &'a self, id: &str, ) -> Result<&'a FareAttribute, Error>
Gets a FareAttribute by its fare_id