use std::{env, fs, path::PathBuf}; use color_eyre::eyre::Result; use indicatif::{ProgressBar, ProgressStyle}; mod gpx; mod layer; mod renderer; fn main() -> Result<()> { color_eyre::install()?; let progress_style = ProgressStyle::with_template("[{elapsed}] {prefix:.cyan} {wide_bar} {pos:.green}/{len}")?; 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()).with_style(progress_style.clone()); bar.set_prefix("Rendering heat zones"); 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()) .with_style(progress_style.clone()); bar.set_prefix("Saving heat tiles"); renderer::lazy_colorization(counter, &target, |x| bar.inc(x.try_into().unwrap()))?; bar.finish(); } Ok(()) }