Skip to main content

Module mvt

Module mvt 

Source
Expand description

Mapbox Vector Tile (MVT / PBF) binary decoder.

This module decodes Mapbox Vector Tile v2 protocol-buffer payloads into the engine’s FeatureCollection geometry model.

§Wire format summary

An MVT tile is a protobuf message containing one or more layers, each of which contains:

  • a name (source layer id)
  • shared keys and values string tables
  • one or more features with:
    • an optional id
    • a geometry type (POINT, LINESTRING, POLYGON)
    • a command-encoded geometry stream
    • interleaved tags indexing into the key/value tables

Coordinates in MVT are integer tile-local pixel positions in a grid of extent units (typically 4096). This decoder converts them to WGS-84 [GeoCoord] using the tile’s geographic bounds.

§Usage

use rustial_engine::mvt::{decode_mvt, MvtDecodeOptions};
use rustial_math::TileId;

let tile_id = TileId::new(14, 8192, 5461);
let layers = decode_mvt(&pbf_bytes, &tile_id, &MvtDecodeOptions::default())?;
for (layer_name, features) in &layers {
    println!("{}: {} features", layer_name, features.len());
}

§Error handling

Decoding never panics. Malformed protobuf fields are skipped, and individual feature decode failures are logged and skipped rather than aborting the entire tile.

§No external protobuf dependency

This decoder hand-rolls the protobuf wire format reading rather than depending on prost or protobuf. The MVT spec uses a tiny subset of protobuf (varint, length-delimited, fixed32) and the hand-rolled approach avoids a heavy code-generation dependency for ~200 lines of wire decoding.

Structs§

MvtDecodeOptions
Options controlling MVT decoding behaviour.

Enums§

MvtError
Errors that can occur during MVT decoding.

Functions§

decode_mvt
Decode an MVT (PBF) binary payload into per-layer feature collections.

Type Aliases§

DecodedVectorTile
Decoded vector tile: a map from source-layer name to feature collection.