aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 7230dce..e5b835e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,7 +8,7 @@ use color_eyre::{
use hittekaart::{
gpx::{self, Compression},
renderer,
- storage::{Folder, Storage},
+ storage::{Folder, Sqlite, Storage},
};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use is_terminal::IsTerminal;
@@ -36,9 +36,15 @@ struct Args {
#[arg(long, short, default_value_t = 0)]
threads: usize,
- /// The output directory. Will be created if it does not exist.
- #[arg(long, short, default_value = "tiles")]
- output_directory: PathBuf,
+ /// The output directory. Will be created if it does not exist. Defaults to "tiles" for the
+ /// folder-based storage, and "tiles.sqlite" for the SQLite-based storage.
+ #[arg(long, short)]
+ output: Option<PathBuf>,
+
+ /// Store the tiles in a SQLite database. If given, `--output` will determine the SQLite
+ /// filename.
+ #[arg(long)]
+ sqlite: bool,
}
fn main() -> Result<()> {
@@ -85,7 +91,13 @@ fn main() -> Result<()> {
let tracks = tracks.into_iter().collect::<Result<Vec<_>>>()?;
bar.finish();
- let mut storage = Folder::new(args.output_directory.clone());
+ let mut storage: Box<dyn Storage + Send> = if args.sqlite {
+ let output = args.output.unwrap_or_else(|| "tiles.sqlite".into());
+ Box::new(Sqlite::connect(output)?)
+ } else {
+ let output = args.output.unwrap_or_else(|| "tiles".into());
+ Box::new(Folder::new(output))
+ };
storage.prepare()?;
let multibar = MultiProgress::new();