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
+30
View File
@@ -0,0 +1,30 @@
mod loader;
mod utils;
mod structs;
use std::{
collections::{HashMap, HashSet},
fs::File,
};
use crate::gtfs::{loader::load_gtfs, structs::Gtfs};
/// Load a GTFS structure from a zip file
pub fn load(src_file: &str, route_numbers: HashSet<String>, stop_codes: HashSet<String>) -> Gtfs {
// Open zip file
let mut zip_reader = zip::ZipArchive::new(File::open(src_file).unwrap()).unwrap();
let mut gtfs: Gtfs = Gtfs {
agencies: Vec::new(),
calendar: HashMap::new(),
calendar_dates: HashMap::new(),
routes: HashMap::new(),
stops: HashMap::new(),
trips: HashMap::new(),
stop_times: HashMap::new(),
};
load_gtfs(&mut gtfs, &mut zip_reader, route_numbers, stop_codes);
return gtfs;
}