use std::{env, fs, path::PathBuf}; use color_eyre::eyre::Result; use indicatif::ProgressBar; mod gpx; mod layer; mod renderer; fn main() -> Result<()> { color_eyre::install()?; let gpx_folder = env::args().nth(1).unwrap(); println!("Reading from {gpx_folder}"); let mut tracks = Vec::new(); for file in fs::read_dir(gpx_folder).unwrap() { let file = file.unwrap(); let data = gpx::extract_from_file(file.path(), gpx::Compression::None).unwrap(); tracks.push(data); } for zoom in 0..=19 { println!("Doing level {zoom}"); let bar = ProgressBar::new(tracks.len().try_into().unwrap()); let counter = renderer::render_heatcounter(zoom, &tracks, |x| bar.inc(x.try_into().unwrap())); bar.finish(); let target = ["tiles", &zoom.to_string()].iter().collect::(); fs::create_dir(&target)?; let bar = ProgressBar::new(counter.tile_count().try_into().unwrap()); renderer::lazy_colorization(&counter, &target, |x| bar.inc(x.try_into().unwrap()))?; bar.finish(); } Ok(()) }