gistools/readers/gtfs/schedule/stop_areas.rs
1use crate::readers::csv::parse_csv_as_record;
2use alloc::{string::String, vec::Vec};
3use s2json::MValueCompatible;
4
5/// # Stop Areas
6///
7/// **Optional**
8/// Assigns stops to areas. Multiple rows can reference the same `area_id` to
9/// indicate that different stops belong to the same area. Conversely, a single
10/// `stop_id` can appear in multiple areas if needed.
11#[derive(Debug, Default, Clone, PartialEq, MValueCompatible)]
12pub struct GTFSStopArea {
13 /// **Required**
14 /// Identifies an area (`areas.area_id`).
15 pub area_id: String,
16 /// **Required**
17 /// Identifies a stop (`stops.stop_id`). If a station is defined (location_type=1),
18 /// it implies all its child platforms (location_type=0) also belong to this area,
19 /// unless otherwise assigned.
20 pub stop_id: String,
21}
22impl GTFSStopArea {
23 /// Create a new GTFSStopArea
24 pub fn new(source: &str) -> Vec<GTFSStopArea> {
25 let mut res = Vec::new();
26 for record in parse_csv_as_record::<GTFSStopArea>(source, None, None) {
27 res.push(record);
28 }
29 res
30 }
31}