gistools/readers/gtfs/schedule/agency.rs
1use crate::readers::csv::parse_csv_as_record;
2use alloc::{collections::BTreeMap, string::String};
3use s2json::MValueCompatible;
4
5/// # Agency Information
6///
7/// ## Details
8/// **Required** - Transit agencies with service represented in this dataset.
9#[derive(Debug, Default, Clone, PartialEq, MValueCompatible)]
10pub struct GTFSAgency {
11 /// **Required**
12 /// Identifies a location: stop/platform, station, entrance/exit, generic node or boarding area (see location_type).
13 /// ID must be unique across all stops. `stop_id`, locations.geojson id, and location_groups.location_group_id values.
14 /// Multiple routes may use the same `stop_id`.
15 pub agency_id: String,
16 /// **Required**
17 /// Full name of the transit agency.
18 pub agency_name: String,
19 /// **Required**
20 /// URL of the transit agency.
21 pub agency_url: String,
22 /// **Required**
23 /// Timezone where the transit agency is located.
24 /// If multiple agencies are specified in the dataset, each must have the same `agency_timezone`.
25 pub agency_timezone: String,
26 /// **Optional**
27 /// Primary language used by this transit agency.
28 /// Should be provided to help GTFS consumers choose capitalization rules and other language-specific settings for the dataset.
29 /// See [ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) for language codes.
30 pub agency_lang: Option<String>,
31 /// **Optional**
32 /// A voice telephone number for the specified agency.
33 /// This field is a string value that presents the telephone number as typical for the agency's service area.
34 pub agency_phone: Option<String>,
35 /// **Optional**
36 /// URL of a web page that allows a rider to purchase tickets or other fare instruments for that
37 /// agency online.
38 pub agency_fare_url: Option<String>,
39 /// **Optional**
40 /// Email address actively monitored by the agency’s customer service department. This email
41 /// address should be a direct contact point where transit riders can reach a customer service
42 /// representative at the agency.
43 pub agency_email: Option<String>,
44}
45impl GTFSAgency {
46 /// Create a new GTFSAgency
47 pub fn new(source: &str) -> BTreeMap<String, GTFSAgency> {
48 let mut res = BTreeMap::new();
49 for record in parse_csv_as_record::<GTFSAgency>(source, None, None) {
50 res.insert(record.agency_id.clone(), record);
51 }
52 res
53 }
54}