diff --git a/decode.cpp b/decode.cpp index 5a69573..8a9f22d 100644 --- a/decode.cpp +++ b/decode.cpp @@ -63,7 +63,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { within = 0; } - layer_to_geojson(stdout, layer, z, x, y); + layer_to_geojson(stdout, layer, z, x, y, true); if (describe) { printf("] }\n"); diff --git a/plugin.cpp b/plugin.cpp index ff77391..eccbfab 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -41,7 +41,7 @@ void *run_writer(void *a) { exit(EXIT_FAILURE); } - layer_to_geojson(fp, *(wa->layer), wa->z, wa->x, wa->y); + layer_to_geojson(fp, *(wa->layer), wa->z, wa->x, wa->y, false); if (fclose(fp) != 0) { perror("fclose output to filter"); diff --git a/write_json.cpp b/write_json.cpp index 1a1d50d..3097135 100644 --- a/write_json.cpp +++ b/write_json.cpp @@ -24,11 +24,11 @@ struct lonlat { } }; -void layer_to_geojson(FILE *fp, mvt_layer &layer, unsigned z, unsigned x, unsigned y) { +void layer_to_geojson(FILE *fp, mvt_layer &layer, unsigned z, unsigned x, unsigned y, bool comma) { for (size_t f = 0; f < layer.features.size(); f++) { mvt_feature &feat = layer.features[f]; - if (f != 0) { + if (comma && f != 0) { fprintf(fp, ",\n"); } diff --git a/write_json.hpp b/write_json.hpp index 1308006..3799fce 100644 --- a/write_json.hpp +++ b/write_json.hpp @@ -1,2 +1,2 @@ -void layer_to_geojson(FILE *fp, mvt_layer &layer, unsigned z, unsigned x, unsigned y); +void layer_to_geojson(FILE *fp, mvt_layer &layer, unsigned z, unsigned x, unsigned y, bool comma); void fprintq(FILE *f, const char *s);