Introducing a new way to review your PRs.

Read the announcement

maplibre / maplibre-tile-spec

Next generation map vector tiles format

View on GitHub

20 documents · Updated Nov 23, 2026

docs / rust-conversion-cli

Rust conversion CLI

The Rust mlt command-line package converts tile data and geospatial source data into MapLibre Tile (MLT) output. It also gives engineers several ways to inspect, validate, and view that output from a terminal. See the Rust tile workspace for the package's place in the wider Rust system, and the Rust core codecs page for the shared tile model and codec behavior.

Command surface

The CLI groups conversion, inspection, statistics, and interactive viewing around the same tile reader and writer. The command router in rust/…/main.rs sends each subcommand to the matching workflow.

CommandPurpose
convertRe-encode MVT or MLT tiles and archives, or create tiled MLT output from GeoJSON or city models.
dumpShow raw parsed layer data without decoding it.
decodeDecode a tile and show its data as text or GeoJSON.
hexdumpShow the byte and bit layout of an MLT tile.
lsList tile files with size, layer, feature, geometry, and encoding statistics.
uiOpen an interactive terminal view of tile files, directories, or MBTiles maps.

The CLI uses MLT version 1 for ordinary re-encoding unless the caller selects version 2. GeoJSON and city-model tiling always targets the version 2 mesh and elevation model, so those workflows require --mlt-version 2.

References: rust/…/main.rs• L12-57 rust/…/mod.rs• L138-156 rust/…/mod.rs• L585-753

Conversion workflows

The convert command first identifies the input family and output container. It then either re-encodes existing tiles or turns source features into tiles before applying the shared MLT encoder settings.

flowchart LR
    A[Tile files] --> D[Convert]
    B[MBTiles or PMTiles] --> D
    C[GeoJSON FeatureCollection] --> G[Project and tile]
    E[CityGML or CityJSON] --> H[Read and build meshes]
    D --> I[MLT or MVT output]
    G --> J[z/x/y.mlt directory]
    H --> J
    I --> K[Inspect or render]
    J --> K

Existing tile and archive conversion

Existing .mlt, .mvt, and .pbf files are converted in place as a file tree. A directory walk keeps the input layout while changing the tile extension when needed. MBTiles and PMTiles inputs preserve their archive form in the supported archive outputs, and an optional bounding box limits archive conversion to tiles that overlap the requested region.

The conversion path can change MVT to MLT or MLT to MVT for file-based input. It preserves archive metadata where possible and updates the output metadata to describe MLT and its outer compression. Conversion refuses to append to an existing output, which keeps a partial result from looking like a complete one.

References: rust/…/from_files.rs• L74-170 rust/…/from_mbtiles.rs• L42-62 rust/…/from_pmtiles.rs• L24-40 rust/…/mod.rs• L691-753

GeoJSON tiling

The GeoJSON workflow accepts a WGS84 FeatureCollection and treats the whole file as one MLT layer. It projects features to the world Web Mercator square, clips them into the requested XYZ tiles, and writes only the zooms from --min-zoom through --max-zoom under z/x/y.mlt. The layer name comes from --layer or the input file name.

The workflow infers one property schema for all output tiles. It keeps feature ids and properties while using a shared coordinate grid. Lines and polygons cross tile edges with a small buffer so adjacent tiles do not show gaps. Positions with altitude need --z-step; the optional --height-mode says whether those values are absolute heights or heights above terrain.

References: rust/…/mod.rs• L1-11 rust/…/mod.rs• L72-163 rust/…/tiled.rs• L11-41 rust/…/README.md• L45-63

City-model tiling

The city-model workflow accepts CityGML 2.0 or 3.0 files with .gml or .xml names, CityJSON files with a .city.json name, or a directory containing those files. It reads buildings, bridges, and tunnels, reprojects their declared coordinate reference systems to WGS84, and writes one Meshes layer into the same z/x/y.mlt directory shape used by GeoJSON.

Each source object becomes a mesh feature at the zooms where it has enough visible detail. Surface meaning is kept as triangle part values such as wall, roof, ground, window, and door. Heights are stored above the building ground with a default 1 cm grid. The ground comes from a named CityJSON attribute when requested, then from terrain or surfaces. CityGML and CityJSON outputs are directory-only and cannot be written as MBTiles or PMTiles yet.

References: rust/…/mod.rs• L1-12 rust/…/mod.rs• L226-307 rust/…/model.rs• L17-25 rust/…/model.rs• L285-349 rust/…/tiler.rs• L493-540

Zoom detail

City-model output changes its representation as the zoom becomes coarser. This keeps small buildings readable without sending full high-detail meshes at every zoom.

Zoom relationOutput goal
Highest requested zoomHighest available detail for each building part.
One zoom belowLOD2 detail when the building is large enough. LOD means level of detail.
Two zooms belowA full LOD2 mesh for prominent buildings or a block for smaller buildings.
Three or more zooms belowNearby small buildings can merge into one block. Tall landmarks keep separate 3D meshes.

The --lod option selects one source level of detail. Lower zooms still derive their coarser representation from that selected source. A building stays whole in the tile that contains the center of its Web Mercator bounding box rather than being split between tiles.

References: rust/…/lods.rs• L9-16 rust/…/tiler.rs• L161-279 rust/…/README.md• L92-111

Output and verification

Tiled conversion and re-encoding share a verification boundary: the produced bytes must be readable by the normal decoder, and optional verification can compare the decoded content with the input. This makes the CLI useful both for production conversion and for checking codec changes.

Output contracts

The main output contracts are:

  • Tiled GeoJSON and city-model input requires --max-zoom; --min-zoom defaults to zero.
  • Tiled input writes a new directory of z/x/y.mlt files and refuses an output path that already exists.
  • Archive input requires an archive output. --bbox is supported for MBTiles and PMTiles input.
  • --to mvt is for file-based conversion, not GeoJSON or city-model tiling.
  • MLT version 2 options and typed field parsing require --mlt-version 2.

The tile writer decodes each written tile with the default decoder budget when --verify is not active. A tile that exceeds that budget is not a valid normal client result: GeoJSON conversion reports the first heavy tile and suggests a higher minimum zoom, while city-model conversion skips the tile with a warning.

References: rust/…/mod.rs• L365-437 rust/…/mod.rs• L585-705 rust/…/tiled.rs• L11-61 rust/…/mod.rs• L132-145

Round-trip verification

--verify decodes each encoded layer and compares its layer name, extent, elevation axis, features, geometry, properties, nested values, mesh vertices, triangles, and m-values with the source. The comparison allows only changes that the selected encoder setting permits, such as a changed integer width or vertex order when vertex sorting is enabled. When --fields converts string properties into typed columns, verification also checks that those columns format back to their source strings before encoding.

The separate ls --validate-to-json workflow compares a tile's decoded GeoJSON with a .json file beside it. It is useful for checking a set of produced files and returns a failing status when a file is invalid, missing its expected JSON, or does not match.

References: rust/…/mod.rs• L281-315 rust/…/verify.rs• L15-72 rust/…/ls.rs• L562-601 rust/…/ls.rs• L788-904

Inspection workflows

The inspection commands expose different levels of the same tile. Use decoded output to understand data values, statistics to compare files at scale, and a hexdump when the wire layout itself matters.

Text and GeoJSON inspection

dump parses a tile and prints raw layer structures. decode passes the layers through the decoder and prints decoded structures or a GeoJSON FeatureCollection. MVT and PBF files can be read for text or GeoJSON output, while GeoJSON output from raw dump data is rejected because it requires decoded values.

References: rust/…/dump.rs• L12-36 rust/…/dump.rs• L39-83 rust/…/lib.rs• L9-19

File statistics

ls accepts files, recursive directories, and glob paths. Its table or JSON result reports file size, encoded and decoded sizes, metadata size, layer and feature counts, geometry types, stream counts, and optional gzip and algorithm data. Extension and glob filters make it suitable for large output trees. With validation enabled, matching rows are hidden and mismatches remain visible.

References: rust/…/ls.rs• L35-104 rust/…/ls.rs• L562-601 rust/…/ls.rs• L788-929 rust/…/ls.rs• L1049-1129

Wire-level inspection

hexdump is limited to MLT files. It renders metadata and stream payloads as annotated bytes and optional bit fields, and can focus on one layer or hide payload detail. This view is for diagnosing how a tile is laid out rather than for reading its feature data.

References: rust/…/hexdump.rs• L11-50 rust/…/hexdump.rs• L71-111

Terminal presentation

The ui command turns inspection into an interactive terminal session. It supports a single tile, a directory of tile files, and an MBTiles archive with a map view.

flowchart LR
    A[Path argument] --> B{Input kind}
    B -->|Tile file| C[Layer overview]
    B -->|Directory| D[Background file scan]
    B -->|MBTiles| E[World map]
    D --> F[File list and filters]
    F --> C
    C --> G[Feature tree and geometry map]
    G --> H[Properties and geometry details]

Directory mode scans and analyzes files in the background. The file list can sort by file, size, encoded percentage, layers, or features. Filters can narrow the list by extension, geometry type, or encoding algorithm. Selecting a tile opens a preview; selecting a layer, feature, or part updates the tree, property view, and map together.

The layer view uses color and selection state to connect geometry on the map with its tree entry. It shows polygon winding, stored tessellation edges, feature properties, and geometry counts. MBTiles mode adds a world map with tile loading, hover details, pan, zoom, and an optional --center-tile z/x/y starting position.

References: rust/…/mod.rs• L84-128 rust/…/state.rs• L23-54 rust/…/files.rs• L19-124 rust/…/layers.rs• L23-140

The CLI is one delivery target for the Rust tile system. Its conversion and inspection paths use the shared core codec, while other packages expose related capabilities to native and web callers.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the accepted input suffixes and output-container rules aligned between ConvertArgs, input classification, and the command help.
  • Keep the GeoJSON and city-model requirements for MLT version 2, zoom range, and directory output aligned with their tilers.
  • Keep mesh field names and scopes such as gml_id, buildings, and triangle part aligned with decoder, GeoJSON export, and inspection views.
  • Keep verification rules aligned with any encoder option that can change feature or vertex order.
  • Keep ls statistics and UI filters aligned when a new tile geometry, stream, or algorithm becomes visible.

Important failure modes

TriggerConsequenceGuard
GeoJSON has altitude positions without --z-step, or has flat positions with --z-stepConversion stops before writing tiles.Match the z-grid option to the input coordinate dimensions.
Tiled input omits --max-zoom or selects MLT version 1Conversion is rejected because tiled output needs the version 2 elevation and mesh model.Set --max-zoom and --mlt-version 2.
City-model files name an unknown CRS or contain coordinates that cannot be reprojectedThe source file cannot become a common WGS84 mesh.Use a supported CRS declaration and inspect --fix-mislabelled-crs warnings for mixed directories.
A produced tile exceeds the default decoder memory budgetThe tile is skipped or the conversion fails, depending on the tiler.Raise --min-zoom, raise --max-zoom when needed, or reduce source detail.
--verify is combined with MVT output or --triangles-onlyThe command rejects the incompatible contract.Verify MLT output with outlines present.
ls --validate-to-json finds no adjacent JSON or a content mismatchThe row is marked invalid and the command exits unsuccessfully.Place the expected JSON beside each tile and compare decoded output.

Key files

FileWhy to read it
rust/…/main.rsShows the public command set and command dispatch.
rust/…/mod.rsDefines conversion input classification, shared options, output contracts, and encoder setup.
rust/…/mod.rsShows the GeoJSON-to-XYZ tiling flow and elevation contract.
rust/…/mod.rsShows city-model discovery, CRS handling, source reading, and conversion flow.
rust/…/tiler.rsShows how city-model meshes become zoom-dependent tile features.
rust/…/verify.rsDefines what round-trip verification considers equal.
rust/…/ls.rsDefines file analysis, validation, statistics, and JSON/table presentation.
rust/…/mod.rsDefines terminal modes, input handling, and the interactive event loop.
rust/…/README.mdGives user-facing examples for conversion, city-model tiling, and the visualizer.