Add option for newline-delimited output format to tippecanoe-decode

This commit is contained in:
Eric Fischer
2017-03-28 16:25:40 -07:00
parent eaff7b93c5
commit 834ba19277
9 changed files with 4962 additions and 69 deletions
+11 -2
View File
@@ -24,7 +24,7 @@ struct lonlat {
}
};
void layer_to_geojson(FILE *fp, mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, unsigned long long index, long long sequence, long long extent) {
void layer_to_geojson(FILE *fp, mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, unsigned long long index, long long sequence, long long extent) {
for (size_t f = 0; f < layer.features.size(); f++) {
mvt_feature const &feat = layer.features[f];
@@ -38,7 +38,7 @@ void layer_to_geojson(FILE *fp, mvt_layer const &layer, unsigned z, unsigned x,
fprintf(fp, ", \"id\": %llu", feat.id);
}
if (name || index != 0 || sequence != 0 || extent != 0) {
if (name || zoom || index != 0 || sequence != 0 || extent != 0) {
bool need_comma = false;
fprintf(fp, ", \"tippecanoe\": { ");
@@ -52,6 +52,15 @@ void layer_to_geojson(FILE *fp, mvt_layer const &layer, unsigned z, unsigned x,
need_comma = true;
}
if (zoom) {
if (need_comma) {
fprintf(fp, ", ");
}
fprintf(fp, "\"minzoom\": %u, ", z);
fprintf(fp, "\"maxzoom\": %u", z);
need_comma = true;
}
if (index != 0) {
if (need_comma) {
fprintf(fp, ", ");