Add MLT (MapLibre Tile) output format

Integrate the C++ MLT encoder from maplibre-tile-spec as a submodule.
Tiles are encoded by converting the existing mvt_tile to
mlt::Encoder::Layer and calling the encoder library directly.

New CLI flags:
  --output-format=mlt     Encode tiles as MLT instead of MVT
  --pretessellate         Pre-triangulate polygons (MLT only)
  --no-mlt-feature-sort   Disable within-tile Hilbert sorting (MLT only)

MLT tiles use .mlt extension in directory output and format=mlt in
mbtiles metadata. Compression and all existing flags work unchanged.
This commit is contained in:
Danila Poyarkov
2026-07-02 17:29:24 +03:00
parent 7fc82a1796
commit 53b98d76c4
15 changed files with 309 additions and 16 deletions
+9 -2
View File
@@ -39,6 +39,7 @@
#include "serial.hpp"
#include "options.hpp"
#include "main.hpp"
#include "mlt.hpp"
#include "write_json.hpp"
#include "milo/dtoa_milo.h"
#include "evaluator.hpp"
@@ -2847,7 +2848,12 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
std::string compressed;
std::string pbf = tile.encode();
std::string pbf;
if (output_format == OUTPUT_MLT) {
pbf = encode_as_mlt(tile, mlt_sort_features, mlt_pretessellate);
} else {
pbf = tile.encode();
}
tile.layers.clear();
@@ -3022,7 +3028,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (outdb != NULL) {
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
} else if (outdir != NULL) {
dir_write_tile(outdir, z, tx, ty, compressed);
const char *tile_ext = (output_format == OUTPUT_MLT) ? ".mlt" : ".pbf";
dir_write_tile(outdir, z, tx, ty, compressed, tile_ext);
}
if (pthread_mutex_unlock(&db_lock) != 0) {