Struct gtfs_structures::GtfsReader
source · pub struct GtfsReader {
pub read_stop_times: bool,
pub read_shapes: bool,
pub unkown_enum_as_default: bool,
pub trim_fields: bool,
}
Expand description
Allows to parameterize how the parsing library behaves
let gtfs = gtfs_structures::GtfsReader::default()
.read_stop_times(false) // Won’t read the stop times to save time and memory
.read_shapes(false) // Won’t read shapes to save time and memory
.unkown_enum_as_default(false) // Won’t convert unknown enumerations into default (e.g. LocationType=42 considered as a stop point)
.read("fixtures/zips/gtfs.zip")?;
assert_eq!(0, gtfs.trips.get("trip1").unwrap().stop_times.len());
You can also get a RawGtfs by doing
let gtfs = gtfs_structures::GtfsReader::default()
.read_stop_times(false)
.raw()
.read("fixtures/zips/gtfs.zip")?;
assert_eq!(1, gtfs.trips?.len());
assert_eq!(0, gtfs.stop_times?.len());
Fields§
§read_stop_times: bool
crate::objects::StopTime are very large and not always needed. This allows to skip reading them
read_shapes: bool
crate::objects::Shape are very large and not always needed. This allows to skip reading them
unkown_enum_as_default: bool
If a an enumeration has an unknown value, should we use the default value
trim_fields: bool
Avoid trimming the fields
It is quite time consuming If performance is an issue, and if your data is high quality, you can switch it off
Implementations§
source§impl GtfsReader
impl GtfsReader
sourcepub fn read_stop_times(self, read_stop_times: bool) -> Self
pub fn read_stop_times(self, read_stop_times: bool) -> Self
Configures the reader to read or not the stop times (default: true)
This can be useful to save time and memory with large datasets when the timetable are not needed Returns Self and can be chained
sourcepub fn read_shapes(self, read_shapes: bool) -> Self
pub fn read_shapes(self, read_shapes: bool) -> Self
This can be useful to save time and memory with large datasets when shapes are not needed Returns Self and can be chained
sourcepub fn unkown_enum_as_default(self, unkown_enum_as_default: bool) -> Self
pub fn unkown_enum_as_default(self, unkown_enum_as_default: bool) -> Self
If a an enumeration has un unknown value, should we use the default value (default: false)
For instance, if crate::objects::Stop has a crate::objects::LocationType with a value 42 in the GTFS when true, we will parse it as StopPoint when false, we will parse it as Unknown(42) Returns Self and can be chained
sourcepub fn trim_fields(self, trim_fields: bool) -> Self
pub fn trim_fields(self, trim_fields: bool) -> Self
Should the fields be trimmed (default: true)
It is quite time consumming If performance is an issue, and if your data is high quality, you can set it to false
sourcepub fn read(self, gtfs: &str) -> Result<Gtfs, Error>
pub fn read(self, 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 read_from_path<P>(self, path: P) -> Result<Gtfs, Error>
pub fn read_from_path<P>(self, path: P) -> Result<Gtfs, Error>
Reads the raw GTFS from a local zip archive or local directory
sourcepub fn read_from_url<U: IntoUrl>(self, url: U) -> Result<Gtfs, Error>
pub fn read_from_url<U: IntoUrl>(self, url: U) -> Result<Gtfs, Error>
Reads the GTFS from a remote url
The library must be built with the read-url feature