mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
Let tile-join and tippecanoe-overzoom write MLT tiles too
Both tools could read MapLibre Tiles but only ever wrote Mapbox Vector Tiles, so there was no way to convert a tileset into MLT, or to keep a tileset in MLT once it had been through either of them. Give them the same --output-format, --pretessellate, and --no-mlt-feature-sort options that tippecanoe has. tile-join writes the chosen format to mbtiles files, PMTiles archives, and tile directories, naming directory tiles and the tileset metadata format accordingly, and tippecanoe-overzoom writes it to its output tile. Either tool will read whichever format its sources are in regardless of what it is writing. The output format selection and the MLT encoder options now live in mlt.cpp, shared by all three tools rather than defined in main.cpp for tippecanoe alone, along with encode_tile() for encoding a tile in the selected format. overzoom() takes the format as a parameter, since tile-join uses it internally to rescale tiles that will be re-encoded afterward, and those intermediate tiles should stay MVT. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LxhELiLtpUFwrPSWwTYdHG
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#include "mlt.hpp"
|
||||
#include "errors.hpp"
|
||||
|
||||
#include <mlt/encoder.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -11,6 +14,37 @@
|
||||
|
||||
using Vertex = mlt::Encoder::Vertex;
|
||||
|
||||
int output_format = OUTPUT_MVT;
|
||||
bool mlt_sort_features = true;
|
||||
bool mlt_pretessellate = false;
|
||||
|
||||
void set_output_format(char **argv, const char *format) {
|
||||
if (strcmp(format, "mvt") == 0 || strcmp(format, "pbf") == 0) {
|
||||
output_format = OUTPUT_MVT;
|
||||
} else if (strcmp(format, "mlt") == 0) {
|
||||
output_format = OUTPUT_MLT;
|
||||
} else {
|
||||
fprintf(stderr, "%s: --output-format must be 'mvt' or 'mlt'\n", argv[0]);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
const char *tile_format_name(int format) {
|
||||
return (format == OUTPUT_MLT) ? "mlt" : "pbf";
|
||||
}
|
||||
|
||||
const char *tile_format_extension(int format) {
|
||||
return (format == OUTPUT_MLT) ? ".mlt" : ".pbf";
|
||||
}
|
||||
|
||||
std::string encode_tile(mvt_tile &tile, int format) {
|
||||
if (format == OUTPUT_MLT) {
|
||||
return encode_as_mlt(tile, mlt_sort_features, mlt_pretessellate);
|
||||
} else {
|
||||
return tile.encode();
|
||||
}
|
||||
}
|
||||
|
||||
// An MLT property column has a single type for the whole layer, while MVT
|
||||
// values each carry their own type, so a type that can hold every value of
|
||||
// an attribute has to be chosen before the layer can be converted.
|
||||
|
||||
Reference in New Issue
Block a user