-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor mbtiles lib, mbtiles tool tests & CI (#702)
* Broke up martin-mbtiles into multiple files * Made all mbtiles functions take a `SqliteExecutor` -- this way they can be used with any SQLX connection structs - either a pool connection or an individual non-pooled connection. * Simplified mbtiles bin a bit - I realized there is really no need to pretty print the output for the single value retrieval. Easier to just dump it to console as is. * Bump martin-mbtiles to v0.2.0 * Minor fixes in tools docs, cargo.toml, and justfile * MBTiles tool Integration tests and release publishing Major thanks to the [stackoverflow](https://stackoverflow.com/questions/76394665/how-to-pass-sqlx-connection-a-mut-trait-as-a-fn-parameter-in-rust/76395111) quick reply by @cafce25 on how to use generic sql executor!
- Loading branch information
Showing
20 changed files
with
577 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
# Tools | ||
|
||
Martin has a few additional tools that can be used to interact with the data. | ||
|
||
## MBTiles tools | ||
A small utility that allows users to interact with mbtiles files from the CLI as follows: `mbtiles <command> ...` | ||
A small utility that allows users to interact with the `*.mbtiles` files from the command line. Use `mbtiles --help` to see a list of available commands, and `mbtiles <command> --help` to see help for a specific command. | ||
|
||
### meta-get | ||
Retrieve raw metadata value by its name. The value is printed to stdout without any modifications. | ||
|
||
#### `meta-get` | ||
Retrieve a metadata value by its name: `mbtiles meta-get <file.mbtiles> <key>`. See `mbtiles meta-get --help` to see available options. | ||
```shell | ||
mbtiles meta-get <file.mbtiles> <key> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "martin-mbtiles" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["Yuri Astrakhan <[email protected]>", "MapLibre contributors"] | ||
description = "A simple low-level MbTiles access and processing library, with some tile format detection and other relevant heuristics." | ||
keywords = ["mbtiles", "maps", "tiles", "mvt", "tilejson"] | ||
|
@@ -13,19 +13,24 @@ rust-version.workspace = true | |
repository.workspace = true | ||
license.workspace = true | ||
|
||
[features] | ||
# TODO: Disable "tools" feature in default builds | ||
default = ["tools"] | ||
tools = ["anyhow", "clap", "tokio"] | ||
|
||
[dependencies] | ||
futures.workspace = true | ||
log.workspace = true | ||
martin-tile-utils = { path = "../martin-tile-utils", version = "0.1.0" } | ||
martin-tile-utils.workspace = true | ||
serde_json.workspace = true | ||
sqlx.workspace = true | ||
thiserror.workspace = true | ||
tilejson.workspace = true | ||
|
||
# Bin dependencies | ||
anyhow.workspace = true | ||
clap.workspace = true | ||
tokio.workspace = true | ||
anyhow = { workspace = true, optional = true } | ||
clap = { workspace = true, optional = true } | ||
tokio = { workspace = true, optional = true } | ||
|
||
[dev-dependencies] | ||
# For testing, might as well use the same async framework as the Martin itself | ||
|
@@ -37,3 +42,4 @@ path = "src/lib.rs" | |
[[bin]] | ||
name = "mbtiles" | ||
path = "src/bin/main.rs" | ||
required-features = ["tools"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::path::PathBuf; | ||
|
||
use martin_tile_utils::TileInfo; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum MbtError { | ||
#[error("SQL Error {0}")] | ||
SqlError(#[from] sqlx::Error), | ||
|
||
#[error("MBTile filepath contains unsupported characters: {}", .0.display())] | ||
UnsupportedCharsInFilepath(PathBuf), | ||
|
||
#[error("Inconsistent tile formats detected: {0} vs {1}")] | ||
InconsistentMetadata(TileInfo, TileInfo), | ||
|
||
#[error("No tiles found")] | ||
NoTilesFound, | ||
} | ||
|
||
pub type MbtResult<T> = Result<T, MbtError>; |
Oops, something went wrong.