gistools/readers/gtfs/schedule/
location_groups.rs

1use crate::readers::csv::parse_csv_as_record;
2use alloc::{collections::BTreeMap, string::String};
3use s2json::MValueCompatible;
4
5/// # Location Groups
6///
7/// **Optional**
8/// Defines groups of stops where a rider may request pickup or drop off.
9/// `location_group_id` must be unique across:
10/// - stops.stop_id
11/// - locations.geojson ID
12/// - location_groups.location_group_id
13#[derive(Debug, Default, Clone, PartialEq, MValueCompatible)]
14pub struct GTFSLocationGroup {
15    /// **Required**
16    /// Identifies a location group. Must be unique (e.g., "zoneA", "northSideGroup").
17    pub location_group_id: String,
18    /// **Optional**
19    /// The name of the location group as displayed to the rider.
20    pub location_group_name: Option<String>,
21}
22impl GTFSLocationGroup {
23    /// Create a new GTFSLocationGroup
24    pub fn new(source: &str) -> BTreeMap<String, GTFSLocationGroup> {
25        let mut res = BTreeMap::new();
26        for record in parse_csv_as_record::<GTFSLocationGroup>(source, None, None) {
27            res.insert(record.location_group_id.clone(), record);
28        }
29        res
30    }
31}