Skip to main content

Crate mbtiles

Crate mbtiles 

Source
Expand description

§mbtiles

Book docs.rs docs GitHub crates.io version CI build

A library to help tile servers like Martin work with MBTiles files. When using as a lib, you may want to disable default features (i.e. the unused “cli” feature).

This crate also has a small utility that allows users to interact with the *.mbtiles files from the command line. See tools documentation for more information.

§Development

Any changes to SQL commands require running of just prepare-sqlite. This will install cargo sqlx command if it is not already installed, and update the ./sqlx-data.json file.

§License

Licensed under either of

§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.

Re-exports§

pub use sqlx;

Structs§

CacheEntryMeta
Cache metadata attached to a tile when writing it with Mbtiles::set_cached.
CachedTile
A cached tile together with its cache metadata, as returned by Mbtiles::get_cached.
Mbtiles
A reference to an MBTiles file providing low-level database operations.
MbtilesCache
Connection pool for using an .mbtiles file as a writable tile cache.
MbtilesCopier
MbtilesPool
Connection pool for concurrent read access to an MBTiles file.
Metadata
Tileset metadata combining MBTiles and TileJSON specifications.
TileCoord
UnixSeconds
A point in time as whole seconds since the Unix epoch (1970-01-01 UTC).

Enums§

AggHashType
CopyDuplicateMode
CopyType
HashAlgorithm
tile-hashing algorithm recorded in the HASH_ALGORITHM metadata key.
IntegrityCheckType
MbtError
MbtType
MbtTypeCli
NormalizedSchema
Describes the naming convention used by a normalized MBTiles schema.
PackCompression
How pack compresses tiles before storing them in the MBTiles file.
PatchType
PatchTypeCli
TileScheme
Tile-coordinate scheme of an on-disk tile directory tree.
UpdateZoomType

Constants§

AGG_TILES_HASH
Metadata key for the aggregate tiles hash value
AGG_TILES_HASH_AFTER_APPLY
Metadata key for a diff file, describing the eventual AGG_TILES_HASH value of the resulting tileset once the diff is applied
AGG_TILES_HASH_BEFORE_APPLY
Metadata key for a diff file, describing the expected AGG_TILES_HASH value of the tileset to which the diff will be applied.
HASH_ALGORITHM
metadata key naming the algorithm used to hash tiles and compute AGG_TILES_HASH.

Functions§

action_with_rusqlite
anonymous_mbtiles
Create an in memory, temporary mbtile connection with the given script
apply_patch
calc_agg_tiles_hash
Compute the hash of the combined tiles in the mbtiles file tiles table/view. This should work on all mbtiles files perf MBTiles specification.
compute_min_max_zoom
Compute min and max zoom levels from the tiles table
create_cache_tables
Create the tile-cache table and the standard tiles view (if they don’t already exist).
create_flat_tables
create_flat_with_hash_tables
create_metadata_table
create_normalized_tables
create_tiles_with_hash_view
detach_db
Execute DETACH DATABASE command
get_patch_type
Check if MBTiles has a table or a view named bsdiffraw or bsdiffrawgz with needed fields, and return the corresponding patch type. If missing, return PatchType::Whole
has_tiles_with_hash
Check if MBTiles has a table or a view named tiles_with_hash with needed fields
init_mbtiles_schema
invert_y_value
MBTiles uses a TMS (Tile Map Service) scheme for its tile coordinates (inverted along the Y axis). This function converts Y value between TMS tile coordinate to an XYZ tile coordinate.
is_cache_tables_type
Check if the database uses the tile-cache schema: a tile_cache table with zoom_level, tile_column, tile_row, fetched, expires, etag, and tile_data columns.
is_dedup_id_normalized_tables_type
Check if MBTiles has an alternative normalized schema with tiles_shallow + tiles_data tables using integer tile_data_id instead of text tile_id.
is_empty_database
Returns true if the database is empty (no tables/indexes/…)
is_flat_tables_type
is_flat_with_hash_tables_type
is_normalized_tables_type
pack
Packs a {z}/{x}/{y}.{ext} directory tree at input_directory into a flat MBTiles file at output_file, interpreting the directory layout with scheme and compressing tiles per compression.
reset_db_settings
temp_named_mbtiles
Create a named, in memory, temporary mbtile connection with the given script
unpack
Unpacks the MBTiles file at input_file into a {z}/{x}/{y}.{ext} directory tree under output_directory, laying out the y coordinate according to scheme.

Type Aliases§

MbtResult
Tile