aboutsummaryrefslogtreecommitdiff
path: root/hittekaart-cli/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'hittekaart-cli/src/main.rs')
-rw-r--r--hittekaart-cli/src/main.rs39
1 files changed, 27 insertions, 12 deletions
diff --git a/hittekaart-cli/src/main.rs b/hittekaart-cli/src/main.rs
index 11133af..e4a227c 100644
--- a/hittekaart-cli/src/main.rs
+++ b/hittekaart-cli/src/main.rs
@@ -7,8 +7,8 @@ use color_eyre::{
};
use hittekaart::{
gpx::{self, Compression},
- renderer::{self, heatmap, marktile, tilehunt, Renderer},
- storage::{Folder, Sqlite, Storage},
+ renderer::{self, Renderer, heatmap, marktile, tilehunt},
+ storage::{Folder, MbTiles, OsmAnd, Storage},
};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use is_terminal::IsTerminal;
@@ -25,6 +25,14 @@ enum Mode {
Tilehunter,
}
+/// Output format.
+#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq, Hash)]
+enum Format {
+ Folder,
+ OsmAnd,
+ MbTiles,
+}
+
#[derive(Parser, Debug, Clone)]
#[command(author, version, about)]
struct Args {
@@ -45,14 +53,14 @@ struct Args {
threads: usize,
/// 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.
+ /// folder-based storage, "tiles.sqlitedb" for the OsmAnd format, and "tiles.mbtiles" for the
+ /// MBTiles format.
#[arg(long, short)]
output: Option<PathBuf>,
- /// Store the tiles in a SQLite database. If given, `--output` will determine the SQLite
- /// filename.
+ /// Output format.
#[arg(long)]
- sqlite: bool,
+ format: Format,
/// Generation mode.
#[arg(value_enum, long, short, default_value_t = Mode::Heatmap)]
@@ -115,12 +123,19 @@ fn run<R: Renderer>(renderer: R, args: Args) -> Result<()> {
let tracks = tracks.into_iter().collect::<Result<Vec<_>>>()?;
bar.finish();
- 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))
+ let mut storage: Box<dyn Storage + Send> = match args.format {
+ Format::Folder => {
+ let output = args.output.unwrap_or_else(|| "tiles".into());
+ Box::new(Folder::new(output))
+ }
+ Format::MbTiles => {
+ let output = args.output.unwrap_or_else(|| "tiles.mbtiles".into());
+ Box::new(MbTiles::open(output)?)
+ }
+ Format::OsmAnd => {
+ let output = args.output.unwrap_or_else(|| "tiles.sqlitedb".into());
+ Box::new(OsmAnd::open(output)?)
+ }
};
storage.prepare()?;