diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 77af69f..9c3250e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use clap::Parser; use color_eyre::eyre::{bail, Result}; use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle}; use is_terminal::IsTerminal; +use rayon::ThreadPoolBuilder; mod gpx; mod layer; @@ -16,11 +17,17 @@ struct Args { #[arg(required = true)] files: Vec<PathBuf>, + /// Minimum zoom level to generate tiles for. #[arg(long, default_value_t = 0)] min_zoom: u32, + /// Maximum zoom level to generate tiles for. #[arg(long, default_value_t = 19)] max_zoom: u32, + + /// Number of threads to use. Set to 0 to use all available CPU cores. + #[arg(long, short, default_value_t = 0)] + threads: usize, } fn main() -> Result<()> { @@ -32,6 +39,10 @@ fn main() -> Result<()> { bail!("Max zoom cannot be smaller than min zoom!"); } + ThreadPoolBuilder::new() + .num_threads(args.threads) + .build_global()?; + let progress_style = ProgressStyle::with_template("[{elapsed}] {prefix:.cyan} {wide_bar} {pos:.green}/{len}")?; let zoom_style = |