Skip to content

Commit

Permalink
fix gtfs directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Oct 21, 2024
1 parent bf53e60 commit 6c2776d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/maple/gtfs_handlers/fix_files.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::fs::File;
use std::io::Read;
use std::io::Write;

pub fn fix_files_in_gtfs_directory(path: &str) -> Result<(), anyhow::Error> {
//read stop file
let stops = format!("{}/stops.txt", path);

let mut f = File::open(&stops)?;

let mut buffer: Vec<u8> = Vec::new();

let read = f.read_to_end(&mut buffer)?;

let stops_string = String::from_utf8_lossy(&buffer);

//write stops string back

let mut f = File::create(&stops)?;

f.write_all(stops_string.as_bytes())?;

Ok(())
}
1 change: 1 addition & 0 deletions src/maple/gtfs_handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod colour_correction;
pub mod convex_hull;
pub mod fix_files;
pub mod flatten;
pub mod hull_from_gtfs;
pub mod rename_route_labels;
Expand Down
8 changes: 8 additions & 0 deletions src/maple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ async fn run_ingest() -> Result<(), Box<dyn Error + std::marker::Send + Sync>> {
rc_feed,
);

let fix_stops_file = gtfs_handlers::fix_files::fix_files_in_gtfs_directory(
format!(
"{}/{}",
gtfs_uncompressed_temp_storage, to_ingest_feed.feed_id
)
.as_str(),
);

(to_ingest_feed.feed_id.clone(), flatten_feed_result.is_ok())
}
}))
Expand Down

0 comments on commit 6c2776d

Please sign in to comment.