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
+3 -3
View File
@@ -25,7 +25,7 @@ std::string dir_read_tile(std::string base, struct zxy tile) {
return (contents.str());
}
void dir_write_tile(const char *outdir, int z, int tx, int ty, std::string const &pbf) {
void dir_write_tile(const char *outdir, int z, int tx, int ty, std::string const &pbf, const char *ext) {
// Don't check mkdir error returns, since most of these calls to
// mkdir will be creating directories that already exist.
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
@@ -39,7 +39,7 @@ void dir_write_tile(const char *outdir, int z, int tx, int ty, std::string const
newdir = newdir + "/" + std::to_string(tx);
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
newdir = newdir + "/" + std::to_string(ty) + ext;
struct stat st;
if (stat(newdir.c_str(), &st) == 0) {
@@ -81,7 +81,7 @@ static bool pbfname(const char *s) {
s++;
}
return strcmp(s, ".pbf") == 0 || strcmp(s, ".mvt") == 0;
return strcmp(s, ".pbf") == 0 || strcmp(s, ".mvt") == 0 || strcmp(s, ".mlt") == 0;
}
void check_dir(const char *dir, char **argv, bool force, bool forcetable) {