Commit Graph

67 Commits

Author SHA1 Message Date
Frank Elsinga
12e51675cd
chore(tests): re-blessed all tests (#1582)
Some checks failed
Documentation / Build Docs (push) Has been cancelled
CI / Lint and Unit test (push) Has been cancelled
CI / Build and test docker images (push) Has been cancelled
CI / Build ${{ matrix.target }} (.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Build ${{ matrix.target }} (macos-13, x86_64-apple-darwin) (push) Has been cancelled
CI / Build ${{ matrix.target }} (macos-latest, aarch64-apple-darwin) (push) Has been cancelled
CI / Build ${{ matrix.target }} (ubuntu-latest, debian-x86_64) (push) Has been cancelled
CI / Build ${{ matrix.target }} (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
Demo / Demo (push) Has been cancelled
Code coverage / grcov (push) Has been cancelled
CI / Test AWS Lambda (push) Has been cancelled
CI / Test on ${{ matrix.os }} (.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Test on ${{ matrix.os }} (macos-13, x86_64-apple-darwin) (push) Has been cancelled
CI / Test on ${{ matrix.os }} (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI / Test postgis:${{ matrix.img_ver }} sslmode=${{ matrix.sslmode }} (postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key, 15-3.3, require) (push) Has been cancelled
CI / Test postgis:${{ matrix.img_ver }} sslmode=${{ matrix.sslmode }} (postgres, 11-3.0-alpine, disable) (push) Has been cancelled
CI / Test postgis:${{ matrix.img_ver }} sslmode=${{ matrix.sslmode }} (postgres, 14-3.3-alpine, disable) (push) Has been cancelled
CI / Package (push) Has been cancelled
CI / CI Finished (push) Has been cancelled
insta currently produces this (quite annoying) warning:


![image](https://github.com/user-attachments/assets/253af8dd-c3f0-47e9-9812-8df377c8af47)

=> this PR re-blesses all files to get rid of it
2024-12-13 22:51:35 +01:00
Frank Elsinga
9331f1c4b9
chore(tests): update thiserror to v2 (#1581)
This mainly follows
https://github.com/dtolnay/thiserror/releases/tag/2.0.0 and should be
fairly straightforeward
2024-12-11 00:19:54 +00:00
Yuri Astrakhan
7446f54bc1
Minor lints (#1412) 2024-07-11 10:04:58 -04:00
Yuri Astrakhan
8ec040665f
Optimize produced release binaries (#1385)
Minor optimization to create a slightly more compact code (should be the
same performance, or possibly even faster)
2024-06-26 20:31:41 -04:00
Yuri Astrakhan
b71c846abc
fix for mbtiles apply-patch with raw bindiff (#1384)
When applying raw (no gzip) patches, `mbtiles` was trying to un-gzip
them first. Now handles it properly.  Also adds a number of tests to catch these cases.
2024-06-26 20:37:20 +00:00
Yuri Astrakhan
ccd550a2cf
Add binary diff for mbtiles (#1358)
* `mbtiles diff` now has an additional `--patch-type` param with
`whole`, `bin-diff-raw` and `bin-diff-gz` values:
* `whole` stores different tiles as before - as whole tiles in the
`tiles` table
* `bin-diff-raw` computes binary difference between tiles, and stores
them as brotli-encoded value in a `bsdiffraw` table, together with a
`xxh3_64` hash of the tile as it will be stored after patching
* `bin-diff-gz` same as `bin-diff-raw`, but assumes the tiles are
gzip-compressed, so it uncompresses them before comparing. The `xxh3_64`
stores the hash of the uncompressed tile. The data will be stored in the
`bsdiffrawgz` table (identical structure with above)

* `mbtiles copy --apply-patch` will automatically detect if
`bsdiffrawgz` or `bsdiffraw` tables exist, and will use binary patching.
* `mbtiles apply-patch` does not support binary patching yet
* `mbtiles copy --diff-with-file ... --patch-type ...` is an alias to
`mbtiles diff --patch-type ...`
2024-06-25 19:34:14 +00:00
Yuri Astrakhan
6320e0fff3
Add agg_tiles_hash_before_apply, warnings, and validate on patch (#1266)
Implement #1244
2024-05-30 18:28:34 +00:00
Yuri Astrakhan
df8880fe4c
Fix a few CI issues and bump deps (#1341) 2024-05-17 01:05:19 -04:00
Yuri Astrakhan
566f91d4cd
upgrade dependencies, Nasm on Windows (#1295)
* Install `nasm` when running CI on Windows (required by rustls new
faster crypto-provider)
* In integration testing, wrap connection in mutex due to `rstest` now
requiring `once` fixtures to be `Sync`
* Upgrade to Brotli v4, and disable FFI due to compilation conflict
2024-04-09 19:36:40 -04:00
Yuri Astrakhan
115c976c92
Update sqlite-hashes dependency (#1268)
Minor internal breaking changes
2024-03-22 17:04:16 -04:00
Yuri Astrakhan
f454113a50
noop: refactor mbtiles copy to support new cases (#1265)
There should be no functionality change - this will just allow for more
changes later.
2024-03-19 02:56:18 -04:00
Yuri Astrakhan
7107db5887
Fix apply-patch documentation (#1261) 2024-03-18 09:17:30 +08:00
Yuri Astrakhan
60ae6cf168
chore: rename agg_tiles_hash_in_diff to agg_tiles_hash_after_apply (#1243)
This is just a documentation change - the actual value stored in the
mbtiles was always `agg_tiles_hash_after_apply`, but accidentally the
constant in the code was not renamed, nor were the docs updated.
2024-03-11 04:29:50 -04:00
Yuri Astrakhan
db094400bb
bug: ensure agg_tiles_hash_after_apply is added even on empty mbtiles (#1242)
If a diff between two mbtiles is empty, `agg_tiles_hash_after_apply`
must still be generated. It was not before because two identical
tilesets would have the same `agg_tiles_hash`, thus skipping the
generation of `agg_tiles_hash_after_apply`
2024-03-11 02:52:26 -04:00
Yuri Astrakhan
1c95c60ebd
Update lock, insta version deprecation, some test changes (#1240)
* Some small test cleanups
* A bump to dependencies
* Disable sprite generation test - PNGs tests are too flaky
* Add an mbtiles copy test for empty diffs
2024-03-11 01:14:27 -04:00
Yuri Astrakhan
e0c960a1b6
test: add tests for empty mbtiles (#1218)
They all seem to pass, but good to ensure we test the usecase of empty
mbtiles
2024-02-27 07:48:06 +00:00
Yuri Astrakhan
7421a99c83
feature: improve diff cmd with copy opts (#1183)
* add most of the `mbtiles copy` options to the `mbtiles diff` command
* reworked the book
2024-02-08 00:35:31 -05:00
Lucas
79a89125ed
Add mbtiles diff command (#1068)
Implement `mbtiles diff a.mbtiles b.mbtiles diff.mbtiles` command

This should behave exactly the same as `mbtiles copy a.mbtiles
--diff-with-file b.mbtiles diff.mbtiles`.

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2024-02-08 03:08:47 +00:00
Yuri Astrakhan
74c67a3812
Use ORDERBY in calc_agg_tiles_hash - SQLite v3.44 (#1156)
Require SQLite v3.44+ ORDER BY clause inside aggregate function instead
of the windowing one - might solve out of memory issues reported by
users - see #1154
2024-01-27 21:48:54 -05:00
Yuri Astrakhan
3dc54d7f9e
Implement tile caching (#1105)
Add a top level config parameter -- the size of cache memory (in MB) to
use for caching tiles and PMT directories, defaulting to 512, and 0 to
disable. This also removes the `pmtiles.dir_cache_size_mb` parameter (it
will be ignored, but will give a warning)

```
cache_size_mb: 512
```

The new cache will contain all tiles as provided by the source. So if
PostgreSQL returns a non-compressed tile, the cache will contain the
uncompressed variant, and will be compressed for each response. This
will be fixed in the later releases.

Note that fonts and sprites are not cached at this time, and are still a
TODO.
2023-12-30 22:48:23 -05:00
Yuri Astrakhan
4f7487b448
Deprecate few things, lock and lints (#1111)
* Remove `CA_ROOT_FILE` env var support (has been deprecated for a
while)
* Remove `WATCH_MODE` env var warning - has not been in use since a long
time ago
* minor lints/clippy suggestions, lock update
2023-12-30 12:47:23 -05:00
Yuri Astrakhan
61d3286815
Lots of small refactorings (#1107)
* Use `Option<&T>` instead of `&Option<T>` in function arguments.
* Cleaner var names
* Slight optimization of `get_tile` with query params
* Split up srv/server.rs into fonts, sprites, tiles, and tiles_info
files
* better error reporting in tests
2023-12-26 07:43:47 +00:00
Yuri Astrakhan
4bf206bd7f doc links 2023-12-25 01:49:39 -05:00
Yuri Astrakhan
2def6288f1
PMTiles cache, refactor file configs, modularize (#1094)
* Make it possible to have configuration specific to the file-based
config sections: pmtiles, mbtiles, and sprites.
* Implement PMTiles directory cache shared between all pmtiles (both
http and local), with configurable max cache size (in MB), or 0 to
disable. Defaults to 32MB (?)
* PMTiles now share web client instance, which optimizes connection
reuse in case multiple pmtiles reside on the same host
* Major refactoring to allow modular reuse, enabling the following build
features:
    * **postgres** - enable PostgreSQL/PostGIS tile sources
    * **pmtiles** - enable PMTile tile sources
    * **mbtiles** - enable MBTile tile sources
    * **fonts** - enable font sources
    * **sprites** - enable sprite sources
* Use justfile in the CI

Fixes #1093
2023-12-25 05:52:04 +00:00
Yuri Astrakhan
f13c3f7514
Improve mbtiles update, update min/max zoom on martin-cp (#1096)
* `mbtiles update` now allows different types of zoom updates - reset to
content, grow only, or skip (dry run)
* `martin-cp` will now update (grow-only) metadata zooms

Addresses a few concerns in the #1081
2023-12-24 17:30:45 +08:00
Yuri Astrakhan
1a8e7c89a4
Implement http pmtiles (#991)
PMTiles is a web-optimized format, allowing the actual file to be read
with HTTP range requests. Supporting this use case instantly allows
Martin to function as a lambda executable accessing PMTiles, but without
any significant investment into devops or hosting large file.

PMTiles config now also allows `http` and `https` protocol.

```
# Publish PMTiles files
pmtiles:
  paths:
    # specific pmtiles file will be published as mypmtiles source
    # (use last portion of the URL without extension)
    - http://example.org/path/to/mypmtiles.pmtiles
  sources:
    # named source matching source name to a single file
    pm-src1: https://example.org/path/to/some_pmtiles.pmtiles
 ```

fixes #884

---------

Co-authored-by: Kyle Slugg-Urbino <35903887+kyleslugg@users.noreply.github.com>
2023-12-22 06:01:50 +00:00
Yuri Astrakhan
24819bdb45
Multiple mbtiles and martin-cp fixes (#1083)
* BREAKING: `martin-cp` will now set `format=pbf` instead of `mvt`. This
is what QGIS and possibly others expect, and this is what tools like
tilelive generates.
* `martin-cp` sets `minzoom` and `maxzoom` metadata values based on the
zoom parameters
* Add `mbtiles meta-update` command to refresh zoom levels based on the
present tiles.

Partially addresses items in #1081
2023-12-18 23:19:36 -05:00
Yuri Astrakhan
fc15e0da5e Preparing release, version bump 2023-12-18 20:24:43 -05:00
Lucas
f21119d548
Fix bbox_to_xyz (#1070)
Figure out and fix the bug with `tile-grid` crate or remove the crate
and implement it ourself.

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-12-18 00:02:49 -05:00
Yuri Astrakhan
de6b681d74
New mbtiles copy --copy (all|tiles|metadata) flag to limit what gets copied (#1073)
Limit what gets copied from one mbtiles to another.

Closes #1069
2023-12-16 14:59:52 -05:00
Yuri Astrakhan
b77bc892bf
Minor test snapshot cleanup (#1074) 2023-12-16 11:49:21 -05:00
Yuri Astrakhan
16fbfa58ff
Split Clap code from MbtilesCopier into CopyArgs (#1072)
This allows easier reuse of the copy functionality without affecting CLI
commands.

Closes #1071
2023-12-16 02:25:50 -05:00
Yuri Astrakhan
bb802c5688
Feature: mbtiles copy --bbox ... to copy tiles within a bbox only (#1060)
Allow users to copy tiles between mbtiles files that are only within a
bounding box. Multiple `--bbox` params are allowed.
2023-12-15 23:13:57 -05:00
Yuri Astrakhan
886358e93f
Fix bbox to xyz roundtrip computation (#1059)
Add `tile-grid` as a dependency to use its webmercator tile math.

---------

Co-authored-by: sharkAndshark <zhangyijunmetro@hotmail.com>
2023-12-15 06:11:31 +00:00
Yuri Astrakhan
9e19691aa0
Require --on-duplicate when adding to existing mbtiles files (#1064)
When using `martin-cp` or `mbtiles copy` into an existing file, require
the user to set `--on-duplicate (override|ignore|abort)`. This prevents
accidental writing to an existing file.
2023-12-14 16:44:37 +00:00
Yuri Astrakhan
4a3e612fac
add a few aliases to mbtiles commands (#1063)
* `mbtiles copy`:  can also use `cp`
* `mbtiles validate`:  can also use `verify` and `check`
2023-12-14 08:27:10 +08:00
Yuri Astrakhan
54f5a8daf0
Add tiles table/view validation to mbtiles validate (#1057)
Make sure all values in the `tiles` table or view are correct:

* zoom_level is between 0 and 30 (max allowed zoom)
* the x,y values are within the limits for the corresponding zoom level
* the column type of z,x,y are all integers
* the `tile_data` is a NULL or a BLOB
2023-12-10 10:59:14 +08:00
Yuri Astrakhan
b97f1ccdbe Move utils to v0.2, MAX_ZOOM 2023-12-09 10:19:49 -05:00
Yuri Astrakhan
ad8770a6e5 Minor test update for tile copying 2023-12-09 00:54:23 -05:00
Yuri Astrakhan
280dbe162f
Move math utils to martin-tile-utils (#1056)
Mathematics should be consolidated in the utils crate. Eventually, I
hope we will move it to [tile-grid](https://crates.io/crates/tile-grid)
or [utiles](https://crates.io/crates/utiles) crates and consolidate our
efforts there.

Also, modify earth circumference by a few centimeters (to match various
other implementations): from `.7` to `.685_578_5`. This modified a few
unit tests.
2023-12-09 04:38:15 +00:00
Yuri Astrakhan
aeaa1e070b
Add extra CLI help string about RUST_LOG (#1053)
Improve CLI help screen
2023-12-08 16:45:37 +08:00
Yuri Astrakhan
7ab3f5e21a
Clean up mbtiles tool output (#1048)
* Now by default mbtiles will not print internal warnings (e.g. that
something is taking too long to execute)
* remove mbtiles --help test - not really needed, but adds complexity
because it has to be updated every time a version changes.
2023-12-08 08:15:31 +08:00
Yuri Astrakhan
a33f980d12 update versions 2023-12-05 23:48:59 -05:00
Yuri Astrakhan
aeb08c8b22
add agg-tiles-hash calc to martin-cp (#1033)
* Automatically computes `agg-tiles-hash` metadata value after copying
tiles
* Add a `--skip-agg-tiles-hash` option
2023-12-02 09:12:19 +08:00
Yuri Astrakhan
d6219a6526
Add compression and query to martin-cp (#1019)
* Use gzip compression for MVT tiles by default
* Allow user to set compression with `--encoding` parameter (same as
browser's header, e.g. use `br,gzip' to encode with brotli as first
choice, unless already encoded as gzip)
* Allow user to pass a query to the Postgres functions with
`--url-query`
* A bit of a cleanup for `mbtiles summary` output
2023-11-22 05:26:53 +00:00
Lucas
566e8fa948
Revert doc book links - may break a few new ones (#1018)
- [x] Remove chapter numbers
- [x] Update file name of `using-endpoints.md` back
- [x] Update links

---------

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
2023-11-21 08:06:27 +00:00
Yuri Astrakhan
c6a7ef67c9
Rename dst-type to mbtiles-type (#1014) 2023-11-20 17:38:28 -05:00
Yuri Astrakhan
999179029b Prepare for release 2023-11-20 01:51:08 -05:00
Yuri Astrakhan
f88fd10aa8
Add martin-cp tool to bulk-copy tiles from any Martin-supported sources (#1011)
This adds a new utility called `martin-cp` that allows copying any
number of tiles from a single source (or a composite source) to an
mbtiles file.

`martin-cp` is a tool for generating tiles in bulk, and save retrieved
tiles into a new or an existing MBTiles file. It can be used to generate
tiles for a large area or multiple areas. If multiple areas overlap, it
will generate tiles only once. `martin-cp` supports the same
configuration file and CLI arguments as Martin server, so it can support
all sources and even combining sources.
2023-11-20 06:27:51 +00:00
Yuri Astrakhan
140ed25679
mbtiles improvements, minor changes (#1013)
# MBTiles
* New `--agg-hash (update|verify|off)` flag replaces
`--update-agg-tiles-hash` (still supported, but not shown in the help
screen). This allows bypassing aggregate hash validation entirely,
without either updating or validating it.
* Simplify MBTiles SQL generation
* MBTiles now uses faster `1 << zoom` everywhere, and a dedicated TMS
inversion fn
* split up metadata insert and delete into separate fn
* consolidated schema initialization
* ensure db settings (like pragma) are always reset on new files

# Other
* Always sort JSON-serialized keys for consistency
  * this affects `/catalog` key ordering, but content is the same
* Minor code cleanup
2023-11-19 10:06:37 +00:00