From 19b79d0d5c97970f744269b752ef6e608445c6db Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Tue, 26 Mar 2024 16:26:52 -0700 Subject: [PATCH] Scaffolding --- clip.cpp | 8 ++++---- geometry.hpp | 6 ++++-- overzoom.cpp | 8 +++++++- tile-join.cpp | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/clip.cpp b/clip.cpp index 4b11a3dd8..d4c1ab308 100644 --- a/clip.cpp +++ b/clip.cpp @@ -758,7 +758,7 @@ static std::vector> clip_poly1(std::vector const &keep, bool do_compress, std::vector> *next_overzoomed_tiles, - bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, std::vector const &unidecode_data) { + bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, std::vector const &unidecode_data, json_object *join_attributes_json) { mvt_tile tile; try { @@ -772,7 +772,7 @@ std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int n exit(EXIT_PROTOBUF); } - return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data); + return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json); } struct tile_feature { @@ -873,7 +873,7 @@ static struct preservecmp { std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int nx, int ny, int detail, int buffer, std::set const &keep, bool do_compress, std::vector> *next_overzoomed_tiles, - bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, std::vector const &unidecode_data) { + bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, std::vector const &unidecode_data, json_object *join_attributes_json) { mvt_tile outtile; std::shared_ptr tile_stringpool = std::make_shared(); @@ -1046,7 +1046,7 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n std::string child = overzoom(outtile, nz, nx, ny, nz + 1, nx * 2 + x, ny * 2 + y, detail, buffer, keep, false, NULL, - demultiply, filter, preserve_input_order, attribute_accum, unidecode_data); + demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json); if (child.size() > 0) { next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y); } diff --git a/geometry.hpp b/geometry.hpp index f847afd15..5d4ea1d7c 100644 --- a/geometry.hpp +++ b/geometry.hpp @@ -105,13 +105,15 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n std::vector> *next_overzoomed_tiles, bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, - std::vector const &unidecode_data); + std::vector const &unidecode_data, + json_object *join_attributes_json); std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int nx, int ny, int detail, int buffer, std::set const &keep, bool do_compress, std::vector> *next_overzoomed_tiles, bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map const &attribute_accum, - std::vector const &unidecode_data); + std::vector const &unidecode_data, + json_object *join_attributes_json); #endif diff --git a/overzoom.cpp b/overzoom.cpp index 67037f918..b8f553367 100644 --- a/overzoom.cpp +++ b/overzoom.cpp @@ -20,6 +20,7 @@ std::string filter; bool preserve_input_order = false; std::unordered_map attribute_accum; std::vector unidecode_data; +json_object *join_attributes_json = NULL; std::set keep; @@ -43,6 +44,7 @@ int main(int argc, char **argv) { {"preserve-input-order", no_argument, 0, 'o' & 0x1F}, {"accumulate-attribute", required_argument, 0, 'E'}, {"unidecode-data", required_argument, 0, 'u' & 0x1F}, + {"join-attributes-json", required_argument, 0, 'c' & 0x1F}, {0, 0, 0, 0}, }; @@ -97,6 +99,10 @@ int main(int argc, char **argv) { unidecode_data = read_unidecode(optarg); break; + case 'c' & 0x1F: + join_attributes_json = read_filter(optarg); + break; + default: fprintf(stderr, "Unrecognized flag -%c\n", i); usage(argv); @@ -151,7 +157,7 @@ int main(int argc, char **argv) { json_filter = parse_filter(filter.c_str()); } - std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data); + std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json); fwrite(out.c_str(), sizeof(char), out.size(), f); fclose(f); diff --git a/tile-join.cpp b/tile-join.cpp index be33a7e44..9dfbcd4e0 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -704,7 +704,7 @@ struct tileset_reader { } if (source.layers.size() != 0) { - std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map(), unidecode_data); + std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map(), unidecode_data, NULL /* XXX join_attributes_json */); return ret; }