From 0e536bcec4f5aa1b3101ec0da6af9763633af708 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Thu, 2 Jul 2026 17:34:40 +0300 Subject: [PATCH] Update MLT encoder dependency --- .github/workflows/test.yml | 2 ++ .gitignore | 1 - .gitmodules | 4 ++-- Makefile | 18 +++++++++--------- README.md | 2 +- maplibre-tile-spec | 2 +- mlt.cpp | 15 ++++++++++++--- tile-join.cpp | 2 +- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb8ae19e..87c0187c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,8 @@ jobs: version: ['Release', 'Debug'] steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Install dependencies (Ubuntu) if: runner.os == 'Linux' run: sudo apt-get install libsqlite3-dev diff --git a/.gitignore b/.gitignore index dff9b97a..8f53e676 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,3 @@ mlt-build/ # Nodejs node_modules -tmp/ diff --git a/.gitmodules b/.gitmodules index 7c4755cd..cb7e0f58 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "maplibre-tile-spec"] path = maplibre-tile-spec - url = https://github.com/dannote/maplibre-tile-spec.git - branch = feature/cpp-encoder + url = https://github.com/maplibre/maplibre-tile-spec.git + branch = main diff --git a/Makefile b/Makefile index d4435776..f56d6b42 100644 --- a/Makefile +++ b/Makefile @@ -58,19 +58,24 @@ C = $(wildcard *.c) $(wildcard *.cpp) INCLUDES = -I/usr/local/include -I. -Iclipper2/include MLT_INCLUDES = -Imaplibre-tile-spec/cpp/include -isystem maplibre-tile-spec/cpp/vendor/fsst -MLT_LIBS = mlt-build/libmlt-cpp-encoder.a mlt-build/libfsst-lib.a +MLT_LIBS = mlt-build/libmlt-cpp-encoder.a mlt-build/libfsst-lib.a mlt-build/fastpfor/libFastPFOR.a +MLT_BUILD_STAMP = mlt-build/.built LIBS = -L/usr/local/lib -mlt-build/libmlt-cpp-encoder.a: maplibre-tile-spec/cpp/CMakeLists.txt +$(MLT_BUILD_STAMP): maplibre-tile-spec/cpp/CMakeLists.txt cmake -S maplibre-tile-spec/cpp -B mlt-build \ - -DCMAKE_BUILD_TYPE=Release \ - -DMLT_WITH_FASTPFOR=OFF \ + -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ + -DMLT_WITH_FASTPFOR=ON \ + -DMLT_WITH_FASTPFOR_SIMD=OFF \ -DMLT_WITH_JSON=OFF \ -DMLT_WITH_TESTS=OFF \ -DMLT_WITH_TOOLS=OFF \ -DCMAKE_CXX_STANDARD=20 \ $(if $(VERBOSE),,--log-level=WARNING) > /dev/null cmake --build mlt-build --target mlt-cpp-encoder $(if $(VERBOSE),,-- -s) > /dev/null + touch $@ + +$(MLT_LIBS): $(MLT_BUILD_STAMP) tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o mlt.o serial.o main.o platform.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o attribute.o thread.o shared_borders.o clipper2/src/clipper.engine.o $(MLT_LIBS) $(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread @@ -605,23 +610,18 @@ mlt-test: tippecanoe ./tippecanoe -q --output-format=mlt -z5 -f -o tests/mlt/points.mbtiles tests/mlt/points.geojson ./tippecanoe -q -z5 -f -o tests/mlt/points-mvt.mbtiles tests/mlt/points.geojson @test $$(sqlite3 tests/mlt/points.mbtiles "SELECT COUNT(*) FROM tiles") -eq $$(sqlite3 tests/mlt/points-mvt.mbtiles "SELECT COUNT(*) FROM tiles") || (echo "FAIL: MLT and MVT tile counts differ" && exit 1) - @echo "PASS: MLT tile count matches MVT" # Verify format metadata @test "$$(sqlite3 tests/mlt/points.mbtiles "SELECT value FROM metadata WHERE name='format'")" = "mlt" || (echo "FAIL: format metadata is not 'mlt'" && exit 1) - @echo "PASS: MLT format metadata correct" # Verify tiles are gzip compressed @sqlite3 tests/mlt/points.mbtiles "SELECT hex(substr(tile_data, 1, 2)) FROM tiles LIMIT 1" | grep -q "1F8B" || (echo "FAIL: MLT tiles not gzip compressed" && exit 1) - @echo "PASS: MLT tiles are gzip compressed" # Directory output with .mlt extension rm -rf tests/mlt/dir-out ./tippecanoe -q --output-format=mlt -z2 -f -e tests/mlt/dir-out tests/mlt/points.geojson @test $$(find tests/mlt/dir-out -name '*.mlt' | wc -l) -gt 0 || (echo "FAIL: No .mlt files in directory output" && exit 1) @test $$(find tests/mlt/dir-out -name '*.pbf' | wc -l) -eq 0 || (echo "FAIL: .pbf files in MLT directory output" && exit 1) - @echo "PASS: Directory output uses .mlt extension" # Pretessellate flag ./tippecanoe -q --output-format=mlt --pretessellate -z5 -f -o tests/mlt/points-tess.mbtiles tests/mlt/points.geojson @test $$(sqlite3 tests/mlt/points-tess.mbtiles "SELECT COUNT(*) FROM tiles") -gt 0 || (echo "FAIL: No tiles with pretessellate" && exit 1) - @echo "PASS: --pretessellate produces tiles" rm -f tests/mlt/points.mbtiles tests/mlt/points-mvt.mbtiles tests/mlt/points-tess.mbtiles rm -rf tests/mlt/dir-out diff --git a/README.md b/README.md index 32ea8fce..24e229b4 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ $ brew install tippecanoe On Ubuntu it will usually be easiest to build from the source repository: ```sh -$ git clone https://github.com/felt/tippecanoe.git +$ git clone --recurse-submodules https://github.com/felt/tippecanoe.git $ cd tippecanoe $ make -j $ make install diff --git a/maplibre-tile-spec b/maplibre-tile-spec index d596473e..ec6808da 160000 --- a/maplibre-tile-spec +++ b/maplibre-tile-spec @@ -1 +1 @@ -Subproject commit d596473e2861b873da913f53c3b70663bff2c4af +Subproject commit ec6808dab4ce9bd5ecb0394a6bd5f50c02d69944 diff --git a/mlt.cpp b/mlt.cpp index adaa2da4..69bf9b91 100644 --- a/mlt.cpp +++ b/mlt.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -29,7 +30,9 @@ static bool try_parse_json_object(const std::string &s, mlt::Encoder::StructValu json_object *key = obj->value.object.keys[i]; json_object *val = obj->value.object.values[i]; - if (key->type != JSON_STRING) continue; + if (key->type != JSON_STRING) { + continue; + } std::string child_key = key->value.string.string; std::string child_val; @@ -211,7 +214,11 @@ static mlt::Encoder::Layer convert_layer(const mvt_layer &layer) { for (const auto &feature : layer.features) { mlt::Encoder::Feature f; - f.id = feature.id; + if (feature.has_id) { + f.id = feature.id; + } else { + f.id = std::nullopt; + } f.geometry = convert_geometry(feature); for (size_t t = 0; t + 1 < feature.tags.size(); t += 2) { @@ -245,7 +252,9 @@ std::string encode_as_mlt(const mvt_tile &tile, bool sort_features, bool pretess break; } } - if (any_has_id) break; + if (any_has_id) { + break; + } } config.includeIds = any_has_id; diff --git a/tile-join.cpp b/tile-join.cpp index 1b057577..347f7a10 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -1636,7 +1636,7 @@ int main(int argc, char **argv) { st.maxlon2 = st.maxlon; } - metadata m = make_metadata(name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.minlat2, st.minlon2, st.maxlat2, st.maxlon2, st.midlat, st.midlon, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str(), !pg, attribute_descriptions, "tile-join", generator_options, strategies, st.maxzoom, 2.5, 1); + metadata m = make_metadata(name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.minlat2, st.minlon2, st.maxlat2, st.maxlon2, st.midlat, st.midlon, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, "pbf", description.c_str(), !pg, attribute_descriptions, "tile-join", generator_options, strategies, st.maxzoom, 2.5, 1); if (outdb != NULL) { mbtiles_write_metadata(outdb, m, true);