add parent stations
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 5m41s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 5m41s
This commit is contained in:
parent
e9e486efcc
commit
ab8e4656c9
2 changed files with 35 additions and 0 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -34,9 +34,18 @@ pub struct MultiplatformStopConfig {
|
|||
pub platform_station_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[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<MultiplatformStopConfig>,
|
||||
pub parent_stop_blacklist: Vec<String>,
|
||||
pub stop_rename_rules: Vec<StopRenameRule>
|
||||
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
|
|
@ -285,6 +294,7 @@ impl GtfsPullService {
|
|||
prefix: &String,
|
||||
gtfs: >fs_structures::Gtfs,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut map: HashMap<String, Vec<String>>= 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<libseptastic::stop::Stop> = 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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue