Rearranged the existing code to make it more manageable.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user