diff options
| author | Daniel Schadt <kingdread@gmx.de> | 2026-04-04 19:44:07 +0200 |
|---|---|---|
| committer | Daniel Schadt <kingdread@gmx.de> | 2026-04-04 19:44:07 +0200 |
| commit | 38118611513deced3617e3f581920125484923f0 (patch) | |
| tree | d808aa648e25b93c9fc61340bbb7d2df4cf2c1f6 /hittekaart-cli | |
| parent | a3b378fd66342ecf9a44f814acf1b18a49a05c42 (diff) | |
| download | hittekaart-38118611513deced3617e3f581920125484923f0.tar.gz hittekaart-38118611513deced3617e3f581920125484923f0.tar.bz2 hittekaart-38118611513deced3617e3f581920125484923f0.zip | |
add osmand sqlite output format (lib & cli)
Diffstat (limited to 'hittekaart-cli')
| -rw-r--r-- | hittekaart-cli/src/main.rs | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/hittekaart-cli/src/main.rs b/hittekaart-cli/src/main.rs index 11133af..880ea61 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, Sqlite, Storage, TableFormat}, }; 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, + Sqlite, + OsmAnd, +} + #[derive(Parser, Debug, Clone)] #[command(author, version, about)] struct Args { @@ -49,10 +57,9 @@ struct Args { #[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 +122,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::Sqlite => { + let output = args.output.unwrap_or_else(|| "tiles.sqlite".into()); + Box::new(Sqlite::connect(output, TableFormat::Simple)?) + } + Format::OsmAnd => { + let output = args.output.unwrap_or_else(|| "tiles.sqlitedb".into()); + Box::new(Sqlite::connect(output, TableFormat::OsmAnd)?) + } }; storage.prepare()?; |
