The MvtService is the core component for serving Mapbox Vector Tiles (MVT). It manages datasources, tilesets, and a tile cache. Developers can use it to retrieve tiles directly or seed a tile cache for high-performance serving.
Key lifecycle steps for using MvtService:
- Initialize: Create the service from an
ApplicationCfg using from_config. - Connect: Call
.connect() to establish connections to all configured datasources (required for PostGIS). - Prepare: Call
.prepare_feature_queries() to prepare datasource queries before requesting tiles. - Serve: Use
.tile_cached() to fetch tiles with cache support or .tile() for raw tile generation.
// Example conceptual workflow
let mut service = MvtService::from_config(&app_cfg).map_err(|e| e)?;
service.connect();
service.prepare_feature_queries();
// Fetch a cached tile
let tile_data = service.tile_cached("my_tileset", x, y, zoom, true, None);