PMTiles (for Rust)
This crate implements the PMTiles v3 spec, originally created by Brandon Liu for Protomaps.
Features
- Opening and validating
PMTilearchives - Querying tiles
- Backends supported:
- Async
mmap(Tokio) for local files - Async
httpandhttps(Reqwuest + Tokio) for URLs - Async
s3(Rust-S3 + Tokio) for S3-compatible buckets
- Async
Plans & TODOs
- Documentation and example code
- Support writing and conversion to and from
MBTiles+x/y/z - Support additional backends (sync
mmapandhttpat least) - Support additional async styles (e.g.,
async-std)
PRs welcome!
Usage examples
Reading from a local PMTiles file
use Bytes;
use AsyncPmTilesReader;
async
Reading from a URL with a simple directory cache
This example uses a simple hashmap-based cache to optimize reads from a PMTiles source. The same caching is available for all other methods. Note that HashMapCache is a rudimentary cache without eviction. You may want to build a more sophisticated cache for production use by implementing the DirectoryCache trait.
use Bytes;
use AsyncPmTilesReader;
use HashMapCache;
use Client; // Re-exported Reqwest crate
async
Reading from an S3 bucket with a directory cache
AWS client configuration is fairly none-trivial to document here. See AWS SDK documentation for more details.
use Bytes;
use AsyncPmTilesReader;
use Client; // Re-exported AWS SDK S3 client
use HashMapCache;
async
Development
- This project is easier to develop with just, a modern alternative to
make. Install it withcargo install just. - To get a list of available commands, run
just. - To run tests, use
just test.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Test Data License
Some PMTile fixtures copied from official PMTiles repository.