tile_sorcerer/lib.rs
1//! # Tile Sorcerer
2//!
3//! Tools for modeling and querying vector tile sources.
4//!
5//! ## Current status
6//!
7//! This crate should be regarded as stable in terms of code reliability/correctness, but not
8//! yet stable in terms of trait and method signatures. While there are a number of
9//! known limitations, this code is being deployed at scale already. We are
10//! releasing this code in Rust tradition as 0.x until we feel the interface
11//! and feature set have stabilized, but welcome usage and contributions from
12//! the Rust GIS community.
13//!
14//! ## Current features
15//!
16//! Given a PostGIS database and a TileMill source (such as OpenMapTiles data),
17//! this crate will help you leverage PostGIS to render Mapbox Vector Tiles.
18//!
19//! ## Known Limitations
20//!
21//! The current focus is on high-performance rendering from a single PostGIS database.
22//! Other formats are not presently supported, but can be added in the future.
23//! As such, the database connection info present in layers is presently ignored, and
24//! it is up to the calling application to set up a connection pool pointed at the right
25//! database. Projection info is also currently ignored, and your database is assumed to be
26//! in EPSG:3857 web mercator already.
27//!
28//! The trait-based design allows for further extensibility, so additional operations,
29//! tile source formats, etc. will likely be added in the future.
30
31#![deny(warnings)]
32
33use sqlx::PgConnection;
34
35/// This is the main trait exported by this crate. It is presently rather barebones,
36/// but is open for future expansion if other formats become relevant.
37pub trait TileSource: Sized {
38    /// Renders the Mapbox vector tile for a slippy map tile in XYZ format.
39    fn render_mvt(
40        &self,
41        conn: &mut PgConnection,
42        zoom: u8,
43        x: i32,
44        y: i32,
45    ) -> impl std::future::Future<Output = Result<Vec<u8>, sqlx::Error>> + Send;
46}
47
48pub mod tm2;
49mod error;
50
51pub use error::Error;