Rearranged the existing code to make it more manageable.

This commit is contained in:
2026-03-28 09:17:49 +00:00
parent 774d4e4c80
commit a22e1ee3fa
5 changed files with 105 additions and 82 deletions
+27
View File
@@ -0,0 +1,27 @@
use std::collections::HashSet;
use crate::gtfs::structs::Gtfs;
pub fn stop_ids_from_codes(gtfs: &Gtfs, stop_codes: &HashSet<String>) -> HashSet<String> {
let mut ids: HashSet<String> = HashSet::new();
for stop in &gtfs.stops {
let stop_number = stop.1.code.as_ref();
if stop_number.is_some() && stop_codes.contains(stop_number.unwrap().as_str()) {
ids.insert(stop.0.clone());
}
}
return ids;
}
pub fn route_ids_from_numbers(gtfs: &Gtfs, route_numbers: &HashSet<String>) -> HashSet<String> {
let mut ids: HashSet<String> = HashSet::new();
for route in &gtfs.routes {
let route_number = route.1.short_name.as_ref();
if route_number.is_some() && route_numbers.contains(route_number.unwrap().as_str()) {
ids.insert(route.0.clone());
}
}
return ids;
}