diff --git a/web/config.yaml b/web/config.yaml index 93b58ea..3f82198 100644 --- a/web/config.yaml +++ b/web/config.yaml @@ -6,6 +6,12 @@ gtfs_zips: prefix: "SEPTABUS" subzip: "google_bus.zip" annotations: + parent_stop_blacklist: + - 'SEPTABUS_32993' + - 'SEPTABUS_31032' + stop_rename_rules: + - pattern: '(.*) Transportation Center' + replace: '\1 Transit Center' multiplatform_stops: - id: 'WTC' name: 'Wissahickon Transit Center' diff --git a/web/src/services/gtfs_pull.rs b/web/src/services/gtfs_pull.rs index 3056706..b6fe525 100644 --- a/web/src/services/gtfs_pull.rs +++ b/web/src/services/gtfs_pull.rs @@ -34,9 +34,18 @@ pub struct MultiplatformStopConfig { pub platform_station_ids: Vec, } +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] +pub struct StopRenameRule { + pub pattern: String, + pub replace: String, +} + #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct Annotations { pub multiplatform_stops: Vec, + pub parent_stop_blacklist: Vec, + pub stop_rename_rules: Vec + } #[derive(Serialize, Deserialize, PartialEq, Debug)] @@ -285,6 +294,7 @@ impl GtfsPullService { prefix: &String, gtfs: >fs_structures::Gtfs, ) -> anyhow::Result<()> { + let mut map: HashMap>= HashMap::new(); for stop in >fs.stops { let global_id = make_global_id!(prefix, stop.1.id.clone()); let platform = Arc::new(Platform { @@ -295,12 +305,21 @@ impl GtfsPullService { platform_location: libseptastic::stop::PlatformLocationType::Normal, }); + if let Some(parent) = &stop.1.parent_station { + let parent_global_id = make_global_id!(prefix, parent); + if !state.annotations.parent_stop_blacklist.contains(&parent_global_id) { + map.entry(parent_global_id) + .or_insert(vec![]).push(global_id.clone()); + } + } + let stop = Arc::new(libseptastic::stop::Stop { id: global_id.clone(), name: stop.1.name.clone().unwrap(), platforms: libseptastic::stop::StopType::SinglePlatform(platform.clone()), }); + state .transit_data .stops @@ -315,6 +334,16 @@ impl GtfsPullService { .insert(global_id.clone(), stop.clone()); } + for pair in &map { + let parent_stop = state.transit_data.stops.get(pair.0).unwrap().clone(); + //let child_stop: Vec = pair.1.iter().map(|stop_id| { + // state.transit_data.stops.get(stop_id).unwrap().clone() + //}).collect(); + state.annotations.multiplatform_stops.push( + MultiplatformStopConfig { id: parent_stop.id.clone(), name: parent_stop.name.clone(), platform_station_ids: pair.1.clone() } + ); + } + Ok(()) }