Commit Graph

34 Commits

Author SHA1 Message Date
rstanciu
d4d3bd8ba5
Add tiles_with_hash view to normalized mbtiles files (#834)
Co-authored-by: rstanciu <rstanciu@rivian.com>
Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-08-23 17:21:46 -07:00
rstanciu
0907c8dc5b
Minor cleanup mbtiles tools (#833)
* Move tile validation to within `Mbtiles`
* Correct `apply-diff` documentation

---------

Co-authored-by: rstanciu <rstanciu@rivian.com>
2023-08-23 09:55:11 -07:00
rstanciu
3e2dceb4bf
Add ability to set mbtiles metadata value (#817)
* Add cli command `meta-set` to set metadata `value`

---------

Co-authored-by: rstanciu <rstanciu@rivian.com>
2023-08-17 11:36:46 -07:00
rstanciu
720b682b7e
Add flat hashing table format (#808)
* Add `MbtType::FlatWithHash`
* Support copying, diffing and applying diffs to and from any
`MbtTypes`s
* Support validating tile data if hash is contained in `*.mbtiles` file
(i.e it is of `MbtType::FlatWithHash` or `MbtType::Normalized`)

---------

Co-authored-by: rstanciu <rstanciu@rivian.com>
Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-08-16 10:22:01 -07:00
Lucas
629c6030c9
Downgrade log level for unknown MBTiles metadata (#800)
#799 Downgrade log level from `warn` to `info` when there is
unrecognized metadata value in `MBTiles` file .
2023-08-11 06:22:06 +00:00
Yuri Astrakhan
74c84fab1f
rename id_format to source_id_format, refactor (#794)
* rename configuration `auto_publish.tables.id_format` and
`auto_publish.functions.id_format` fields from `id_format` to
`source_id_format` fields. The `id_format` will continue to be supported
(read) from the configuration, but it will be auto-converted to the new
name on save. It is an error to have both in the same config file.
  * The rename was discussed in #682

* internal refactorings: consolidate PG-related utilities, rename a few
vars, move PG errors to their own file.

This is partially made due to #790 (thanks @Binabh!) - and should be
merged before that to make that PR easier.
2023-08-03 01:13:38 +00:00
rstanciu
27a0cae93b
Create primary keys on metadata and tiles tables when copying with force-simple (#786)
Co-authored-by: rstanciu <rstanciu@rivian.com>
2023-07-27 20:01:20 +00:00
rstanciu
42c2df46ef
Add ability to copy to existing mbtiles files (#778)
* Allow the `dst` in `mbtiles copy <src> <dst>` command to already
contain data, merging tilesets
* Add `mbtiles copy --on-duplicate (override|ignore|abort)`

---------

Co-authored-by: rstanciu <rstanciu@rivian.com>
Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-07-27 18:54:49 +00:00
Yuri Astrakhan
4664d5ad8a update lock, minor toml sort cleanup 2023-07-05 20:56:23 -04:00
rstanciu
1342b38e75
Add apply-diff command (#747)
Add command `apply-diff` to apply diff file generated from `copy`
command
2023-07-05 21:38:03 +00:00
rstanciu
e004908722
Add diff-with-file option to copy command (#729)
* Add ability to generate diff file by specifying `--diff-with-file` to
the `copy` tool

---------

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
2023-07-05 16:55:39 +00:00
Yuri Astrakhan
144e10ff20
Upgrade sqlx to v0.7 (#743)
This is mostly a noop, just updating to the new way of storing cached
queries and a few other changes per
https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#070---2023-06-30

Note that this uses some of the code from #729 (thanks @upsicleclown !)

A minor unrelated change - a reformat of `martin/release.toml`
2023-07-04 08:05:23 -04:00
Pirmin Kalberer
aabcb0aa0a
Add sqlx-rustls support (#720)
I'd like to add optional rustls support for SQLx. This PR implements the
required features, but tests using `--all-features` fail, because
runtime selection features are not additive. I didn't find a solution
apart from avoiding `--all-features`.

---------

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
2023-07-03 21:29:44 +00:00
Yuri Astrakhan
87b62cb223 update sources-sprites docs, minor lint 2023-06-22 23:53:59 -04:00
Yuri Astrakhan
71f9ee6c7d Ver bump, doc cleanup, readying for release 2023-06-22 23:24:31 -04:00
rstanciu
177b72e876
Add force-simple parameter when copying (#723)
Add `--force-simple` flag to `mbtiles copy` tool.
If supplied, ensures the destination file has a `tiles` _table_ (as
opposed to a `tiles` _view_ made up of `images` and `map` tables).
2023-06-23 02:21:11 +00:00
Yuri Astrakhan
8b3a589182
Minor cleanup of mbitels tools (#718)
Just a few inlining and minor things to keep things tidy

Feel free to push back on any of the proposed changes, e.g. if
unclear/complex/...
2023-06-20 17:49:05 -04:00
rstanciu
bc140e0216
Add basic copying functionality (#712)
Copy an existing `.mbtiles` file to a new file.

```shell
mbtiles copy  <src_file.mbtiles> <dst_file.mbtiles>
```

Optionally filters by zooms.  Supports de-duplicated and simple mbtiles

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-06-17 00:00:46 +00:00
Yuri Astrakhan
a187e6e1da cleanup cargo optional dep: in features 2023-06-16 19:31:51 -04:00
Yuri Astrakhan
7e20602079
Minor refactor and cleanup (#716)
* moved `IdResolver` to a separate file
* added `just fmt2` build target to format code using nightly mode
* moved all Actix `Data<AppState>` into individual state objects, e.g.
`Data<Sources>` (allows other source types, separate from `Sources`
type)
* move all Source-related code to a new `Sources` struct (a simple
wrapper over a HashMap)
2023-06-15 18:36:41 -04:00
rstanciu
6f32f0e7b4
Add feature to detect Mbtiles format (#713)
Feature for `Mbtiles` struct to detect which format a `.mbtiles` file is
in according to the [MBTiles
specfication](https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md#database).
The function `detect_type` identifies whether the `.mbtiles` file
contains a `tiles` _table_ OR if it contains `map` and `images` table
(which provide the data for a `tiles` _view_).

See also #667
2023-06-13 20:04:11 -04:00
Yuri Astrakhan
a419d77fca Bump versions for release 2023-06-04 15:04:42 -04:00
Yuri Astrakhan
73af185737 readme for all packages 2023-06-04 00:56:20 -04:00
Yuri Astrakhan
454d435589 Move invalid test fixture files 2023-06-03 23:06:37 -04:00
Yuri Astrakhan
b147c27380
Move Martin crate to its own subdir (#699)
This cleans up the code a bit, making all crates to be on the same
level.
2023-06-04 02:50:55 +00:00
Yuri Astrakhan
2cdd373044
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!
2023-06-04 00:54:50 +02:00
rstanciu
78e67c3ad2
Add mbtiles meta-get utility (#701)
* Add functionality to retrieve a metadata value in an mbtiles file by
key; simple implementation for one of the items in #667
* Also, disable TTY in docker-up `just` target
2023-06-03 00:40:22 +00:00
Yuri Astrakhan
278f46f772 Add just prepare-sqlite to simplify sqlite dev 2023-06-01 13:07:13 -04:00
Yuri Astrakhan
21e1efc9a3
Implement rudimentary mbtiles binary (#696)
This will be the entry point for #667
2023-06-01 10:13:20 -04:00
Yuri Astrakhan
18770664e1
Consolidate all crate dependencies (#694)
This moves all dependency version management to one location
2023-06-01 09:05:06 -04:00
Yuri Astrakhan
aedd037f6d martin-mbtiles/Cargo.toml publishing 2023-03-25 14:45:56 -04:00
Yuri Astrakhan
9cd71476db
Prepare for sub-crate publish, detection bug fix (#615)
* tile format detection would crash on a rare edge case
* add some formatting and info about utils and mbtiles crates
2023-03-25 18:37:42 +00:00
Yuri Astrakhan
3fcad46500
fix (re-)compression of images (#579)
Compression middleware turned out to be hard to use for image cases - it
simply looks at the content-encoding, and if not set, tries to compress
if accepted by the client.

Instead, now individual routes are configured with either that
middleware, or for tiles, I decompress and optionally recompress if
applicable.

Now encoding is tracked separately from the tile content, making it
cleaner too. Plus lots of tests for mbtiles & pmtiles.

Fixes #577
2023-02-20 10:44:22 -05:00
Yuri Astrakhan
9e5ed2fc02
Add .mbtiles support (#549)
Adds a new [.mbtiles](https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md)
backend, without the grid support. Uses extensive tile content
detection, i.e. if the content is gzipped, png, jpeg, gif, webp.

From CLI, can be as easy as adding a path to a directory that contains a
.mbtiles file (works just like pmtiles support)

```bash
# All *.mbtiles files in this dir will be published.
# The filename will be used as the source ID
martin ./tests/fixtures
```

From configuration file, the path can be specified in a number of ways
(same as pmtiles)

```yaml
mbtiles:
  paths:
    # scan this whole dir, matching all *.mbtiles files
    - /dir-path
    # specific mbtiles file will be published as mbtiles2 source
    - /path/to/mbtiles2.mbtiles
  sources:
      # named source matching source name to a single file
      pm-src1: /tmp/mbtiles.mbtiles
      # named source, where the filename is explicitly set. This way we will be able to add more options later
      pm-src2:
        path: /tmp/mbtiles.mbtiles
```

Fixes #494
2023-01-09 00:10:23 -05:00