diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f97475..c5f9a593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.57.0 + +* Add multi-tile input to tippecanoe-overzoom + # 2.56.0 * Rework --coalesce-densest-as-needed and --drop-densest-as-needed to look better diff --git a/Makefile b/Makefile index a39ac049..8b7bcb08 100644 --- a/Makefile +++ b/Makefile @@ -284,6 +284,16 @@ overzoom-test: tippecanoe-overzoom ./tippecanoe-decode tests/pbf/11-327-791-out.pbf 11 327 791 > tests/pbf/11-327-791-out.json cmp tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json rm tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json tests/pbf/11-327-791-out.pbf + # Basic operation, multiple input form + ./tippecanoe-overzoom -o tests/pbf/13-1310-3166.pbf -t 13/1310/3166 tests/pbf/11-327-791.pbf 11/327/791 + ./tippecanoe-decode tests/pbf/13-1310-3166.pbf 13 1310 3166 > tests/pbf/13-1310-3166.pbf.json.check + cmp tests/pbf/13-1310-3166.pbf.json.check tests/pbf/13-1310-3166.pbf.json + rm tests/pbf/13-1310-3166.pbf tests/pbf/13-1310-3166.pbf.json.check + # Multiple inputs + ./tippecanoe-overzoom -o tests/pbf/13-1310-3166-ne.pbf -t 13/1310/3166 tests/pbf/11-327-791.pbf 11/327/791 tests/pbf/0-0-0.pbf 0/0/0 + ./tippecanoe-decode tests/pbf/13-1310-3166-ne.pbf 13 1310 3166 > tests/pbf/13-1310-3166-ne.pbf.json.check + cmp tests/pbf/13-1310-3166-ne.pbf.json.check tests/pbf/13-1310-3166-ne.pbf.json + rm tests/pbf/13-1310-3166-ne.pbf tests/pbf/13-1310-3166-ne.pbf.json.check # Different detail and buffer, and attribute stripping ./tippecanoe-overzoom -d8 -b30 -y NAME -y name -y scalerank -o tests/pbf/13-1310-3166-8-30.pbf tests/pbf/11-327-791.pbf 11/327/791 13/1310/3166 ./tippecanoe-decode tests/pbf/13-1310-3166-8-30.pbf 13 1310 3166 > tests/pbf/13-1310-3166-8-30.pbf.json.check diff --git a/README.md b/README.md index 038783f8..1461d8da 100644 --- a/README.md +++ b/README.md @@ -991,10 +991,15 @@ to turn those into moderate detail tiles at high zoom levels, for the benefit of renderers that cannot internally overzoom high-resolution tiles without losing some of the precision. Running: - tippecanoe-overzoom -o out.mvt.gz inz/inx/iny outz/outx/outy in.mvt.gz + tippecanoe-overzoom -o out.mvt.gz in.mvt.gz inz/inx/iny outz/outx/outy reads tile `inz/inx/iny` of `in.mvt.gz` and produces tile `outz/outx/outy` of `out.mvt.gz`. + tippecanoe-overzoom -o out.mvt.gz -t outz/outx/outy in.mvt.gz inz/inx/iny in2.mvt.gz in2z/in2x/in2y in3.mvt.gz in3z/in3x/in3y + +reads tile `inz/inx/iny` of `in.mvt.gz`, tile `in2z/in2x/in2y` of `in2.mvt.gz`, and tile `in3z/in3x/in3y` of `in3.mvt.gz`, +and produces tile `outz/outx/outy` of `out.mvt.gz` from them. + ### Options * `-b` *buffer*: Set the tile buffer in the output tile (default 5) diff --git a/clip.cpp b/clip.cpp index 4b11a3dd..ee6e2bc2 100644 --- a/clip.cpp +++ b/clip.cpp @@ -755,24 +755,36 @@ static std::vector> clip_poly1(std::vector const &tiles, 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) { - mvt_tile tile; + std::vector decoded; - try { - bool was_compressed; - if (!tile.decode(s, was_compressed)) { - fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", oz, ox, oy); - exit(EXIT_MVT); + for (auto const &t : tiles) { + mvt_tile tile; + + try { + bool was_compressed; + if (!tile.decode(t.tile, was_compressed)) { + fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", t.z, t.x, t.y); + exit(EXIT_MVT); + } + } catch (std::exception const &e) { + fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", t.z, t.x, t.y); + exit(EXIT_PROTOBUF); } - } catch (std::exception const &e) { - fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", oz, ox, oy); - exit(EXIT_PROTOBUF); + + source_tile out; + out.tile = tile; + out.z = t.z; + out.x = t.x; + out.y = t.y; + + decoded.push_back(out); } - 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(decoded, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data); } struct tile_feature { @@ -870,165 +882,175 @@ static struct preservecmp { } } preservecmp; -std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int nx, int ny, +std::string overzoom(std::vector const &tiles, 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) { mvt_tile outtile; std::shared_ptr tile_stringpool = std::make_shared(); - for (auto const &layer : tile.layers) { - mvt_layer outlayer = mvt_layer(); + for (auto const &tile : tiles) { + for (auto const &layer : tile.tile.layers) { + mvt_layer *outlayer = NULL; - int det = detail; - if (det <= 0) { - det = std::round(log(layer.extent) / log(2)); - } + int det = detail; + if (det <= 0) { + det = std::round(log(layer.extent) / log(2)); + } - outlayer.name = layer.name; - outlayer.version = layer.version; - outlayer.extent = 1LL << det; + for (size_t i = 0; i < outtile.layers.size(); i++) { + if (outtile.layers[i].name == layer.name) { + outlayer = &outtile.layers[i]; + } + } - std::vector pending_tile_features; + if (outlayer == NULL) { + mvt_layer newlayer = mvt_layer(); - static const std::string retain_points_multiplier_first = "tippecanoe:retain_points_multiplier_first"; - static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence"; + newlayer.name = layer.name; + newlayer.version = layer.version; + newlayer.extent = 1LL << det; - for (auto feature : layer.features) { - bool flush_multiplier_cluster = false; - if (demultiply) { - for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) { - if (layer.keys[feature.tags[i]] == retain_points_multiplier_first) { - mvt_value v = layer.values[feature.tags[i + 1]]; - if (v.type == mvt_bool && v.numeric_value.bool_value) { - flush_multiplier_cluster = true; + outtile.layers.push_back(newlayer); + outlayer = &outtile.layers.back(); + } + + std::vector pending_tile_features; + + static const std::string retain_points_multiplier_first = "tippecanoe:retain_points_multiplier_first"; + static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence"; + + for (auto feature : layer.features) { + bool flush_multiplier_cluster = false; + if (demultiply) { + for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) { + if (layer.keys[feature.tags[i]] == retain_points_multiplier_first) { + mvt_value v = layer.values[feature.tags[i + 1]]; + if (v.type == mvt_bool && v.numeric_value.bool_value) { + flush_multiplier_cluster = true; + feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2); + } + } else if (i < (ssize_t) feature.tags.size() && layer.keys[feature.tags[i]] == retain_points_multiplier_sequence) { + mvt_value v = layer.values[feature.tags[i + 1]]; + feature.seq = mvt_value_to_long_long(v); feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2); } - } else if (i < (ssize_t) feature.tags.size() && layer.keys[feature.tags[i]] == retain_points_multiplier_sequence) { - mvt_value v = layer.values[feature.tags[i + 1]]; - feature.seq = mvt_value_to_long_long(v); - feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2); } - } - } else { - flush_multiplier_cluster = true; - } - - if (flush_multiplier_cluster) { - if (pending_tile_features.size() > 0) { - feature_out(pending_tile_features, outlayer, keep, attribute_accum, tile_stringpool); - pending_tile_features.clear(); - } - } - - std::set exclude_attributes; - if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) { - continue; - } - - drawvec geom; - int t = feature.type; - - // Convert feature geometry to world coordinates - - long long tilesize = 1LL << (32 - oz); // source tile size in world coordinates - draw ring_closure(0, 0, 0); - bool sametile = (nz == oz && nx == ox && ny == oy && outlayer.extent >= layer.extent); - - for (auto const &g : feature.geometry) { - if (g.op == mvt_closepath) { - geom.push_back(ring_closure); } else { - geom.emplace_back(g.op, - g.x * tilesize / layer.extent + ox * tilesize, - g.y * tilesize / layer.extent + oy * tilesize); + flush_multiplier_cluster = true; + } - if (g.op == mvt_moveto) { - ring_closure = geom.back(); - ring_closure.op = mvt_lineto; + if (flush_multiplier_cluster) { + if (pending_tile_features.size() > 0) { + feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool); + pending_tile_features.clear(); } } - } - // Now offset from world coordinates to output tile coordinates, - // but retain world scale, because that is what tippecanoe clipping expects - - long long outtilesize = 1LL << (32 - nz); // destination tile size in world coordinates - for (auto &g : geom) { - g.x -= nx * outtilesize; - g.y -= ny * outtilesize; - } - - if (!sametile) { - // Clip to output tile - - long long xmin = LLONG_MAX; - long long ymin = LLONG_MAX; - long long xmax = LLONG_MIN; - long long ymax = LLONG_MIN; - - for (auto const &g : geom) { - xmin = std::min(xmin, g.x); - ymin = std::min(ymin, g.y); - xmax = std::max(xmax, g.x); - ymax = std::max(ymax, g.y); - } - - long long b = outtilesize * buffer / 256; - if (xmax < -b || ymax < -b || xmin > outtilesize + b || ymin > outtilesize + b) { + std::set exclude_attributes; + if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) { continue; } - if (t == VT_LINE) { - geom = clip_lines(geom, nz, buffer); - } else if (t == VT_POLYGON) { - drawvec dv; - geom = simple_clip_poly(geom, nz, buffer, dv, false); - } else if (t == VT_POINT) { - geom = clip_point(geom, nz, buffer); + drawvec geom; + int t = feature.type; + + // Convert feature geometry to world coordinates + + long long tilesize = 1LL << (32 - tile.z); // source tile size in world coordinates + draw ring_closure(0, 0, 0); + bool sametile = (nz == tile.z && nx == tile.x && ny == tile.y && outlayer->extent >= layer.extent); + + for (auto const &g : feature.geometry) { + if (g.op == mvt_closepath) { + geom.push_back(ring_closure); + } else { + geom.emplace_back(g.op, + g.x * tilesize / layer.extent + tile.x * tilesize, + g.y * tilesize / layer.extent + tile.y * tilesize); + if (g.op == mvt_moveto) { + ring_closure = geom.back(); + ring_closure.op = mvt_lineto; + } + } } - } - // Scale to output tile extent + // Now offset from world coordinates to output tile coordinates, + // but retain world scale, because that is what tippecanoe clipping expects - to_tile_scale(geom, nz, det); + long long outtilesize = 1LL << (32 - nz); // destination tile size in world coordinates + for (auto &g : geom) { + g.x -= nx * outtilesize; + g.y -= ny * outtilesize; + } - if (!sametile) { - // Clean geometries + if (!sametile) { + // Clip to output tile + + long long xmin = LLONG_MAX; + long long ymin = LLONG_MAX; + long long xmax = LLONG_MIN; + long long ymax = LLONG_MIN; + + for (auto const &g : geom) { + xmin = std::min(xmin, g.x); + ymin = std::min(ymin, g.y); + xmax = std::max(xmax, g.x); + ymax = std::max(ymax, g.y); + } + + long long b = outtilesize * buffer / 256; + if (xmax < -b || ymax < -b || xmin > outtilesize + b || ymin > outtilesize + b) { + continue; + } + + if (t == VT_LINE) { + geom = clip_lines(geom, nz, buffer); + } else if (t == VT_POLYGON) { + drawvec dv; + geom = simple_clip_poly(geom, nz, buffer, dv, false); + } else if (t == VT_POINT) { + geom = clip_point(geom, nz, buffer); + } + } + + // Scale to output tile extent + + to_tile_scale(geom, nz, det); + + if (!sametile) { + // Clean geometries + + geom = remove_noop(geom, t, 0); + if (t == VT_POLYGON) { + geom = clean_or_clip_poly(geom, 0, 0, false, false); + } + } - geom = remove_noop(geom, t, 0); if (t == VT_POLYGON) { - geom = clean_or_clip_poly(geom, 0, 0, false, false); + geom = close_poly(geom); } + + tile_feature tf; + tf.geom = std::move(geom); + tf.t = t; + tf.has_id = feature.has_id; + tf.id = feature.id; + tf.tags = std::move(feature.tags); + tf.layer = &layer; + tf.seq = feature.seq; + + pending_tile_features.push_back(tf); } - if (t == VT_POLYGON) { - geom = close_poly(geom); + if (pending_tile_features.size() > 0) { + feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool); + pending_tile_features.clear(); } - tile_feature tf; - tf.geom = std::move(geom); - tf.t = t; - tf.has_id = feature.has_id; - tf.id = feature.id; - tf.tags = std::move(feature.tags); - tf.layer = &layer; - tf.seq = feature.seq; - - pending_tile_features.push_back(tf); - } - - if (pending_tile_features.size() > 0) { - feature_out(pending_tile_features, outlayer, keep, attribute_accum, tile_stringpool); - pending_tile_features.clear(); - } - - if (preserve_input_order) { - std::stable_sort(outlayer.features.begin(), outlayer.features.end(), preservecmp); - } - - if (outlayer.features.size() > 0) { - outtile.layers.push_back(std::move(outlayer)); + if (preserve_input_order) { + std::stable_sort(outlayer->features.begin(), outlayer->features.end(), preservecmp); + } } } @@ -1043,7 +1065,16 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n if (outtile.layers.size() > 0) { for (size_t x = 0; x < 2; x++) { for (size_t y = 0; y < 2; y++) { - std::string child = overzoom(outtile, nz, nx, ny, + source_tile st; + st.tile = outtile; + st.z = nz; + st.x = nx; + st.y = ny; + + std::vector sts; + sts.push_back(st); + + std::string child = overzoom(sts, nz + 1, nx * 2 + x, ny * 2 + y, detail, buffer, keep, false, NULL, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data); @@ -1055,6 +1086,12 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n } } + for (ssize_t i = outtile.layers.size() - 1; i >= 0; i--) { + if (outtile.layers[i].features.size() == 0) { + outtile.layers.erase(outtile.layers.begin() + i); + } + } + if (outtile.layers.size() > 0) { std::string pbf = outtile.encode(); diff --git a/geometry.hpp b/geometry.hpp index 3e9e6d70..4be046a8 100644 --- a/geometry.hpp +++ b/geometry.hpp @@ -100,14 +100,28 @@ void visvalingam(drawvec &ls, size_t start, size_t end, double threshold, size_t int pnpoly(const drawvec &vert, size_t start, size_t nvert, long long testx, long long testy); double distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y); -std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int nx, int ny, +struct input_tile { + std::string tile; + int z; + int x; + int y; +}; + +struct source_tile { + mvt_tile tile; + int z; + int x; + int y; +}; + +std::string overzoom(std::vector const &tiles, 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::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int nx, int ny, +std::string overzoom(std::vector const &tiles, 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, diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index fc0b6cfa..d57bd352 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -1257,11 +1257,20 @@ some of the precision. Running: .PP .RS .nf -tippecanoe\-overzoom \-o out.mvt.gz inz/inx/iny outz/outx/outy in.mvt.gz +tippecanoe\-overzoom \-o out.mvt.gz in.mvt.gz inz/inx/iny outz/outx/outy .fi .RE .PP reads tile \fB\fCinz/inx/iny\fR of \fB\fCin.mvt.gz\fR and produces tile \fB\fCoutz/outx/outy\fR of \fB\fCout.mvt.gz\fR\&. +.PP +.RS +.nf +tippecanoe\-overzoom \-o out.mvt.gz \-t outz/outx/outy in.mvt.gz inz/inx/iny in2.mvt.gz in2z/in2x/in2y in3.mvt.gz in3z/in3x/in3y +.fi +.RE +.PP +reads tile \fB\fCinz/inx/iny\fR of \fB\fCin.mvt.gz\fR, tile \fB\fCin2z/in2x/in2y\fR of \fB\fCin2.mvt.gz\fR, and tile \fB\fCin3z/in3x/in3y\fR of \fB\fCin3.mvt.gz\fR, +and produces tile \fB\fCoutz/outx/outy\fR of \fB\fCout.mvt.gz\fR from them. .SS Options .RS .IP \(bu 2 diff --git a/overzoom.cpp b/overzoom.cpp index 67037f91..a3e29b51 100644 --- a/overzoom.cpp +++ b/overzoom.cpp @@ -26,13 +26,18 @@ std::set keep; void usage(char **argv) { fprintf(stderr, "Usage: %s -o newtile.pbf.gz tile.pbf.gz oz/ox/oy nz/nx/ny\n", argv[0]); fprintf(stderr, "to create tile nz/nx/ny from tile oz/ox/oy\n"); + fprintf(stderr, "Usage: %s -o newtile.pbf.gz -t nz/nx/ny tile.pbf.gz oz/ox/oy tile2.pbf.gz oz2/ox2/oy2\n", argv[0]); + fprintf(stderr, "to create tile nz/nx/ny from tiles oz/ox/oy and oz2/ox2/oy2\n"); exit(EXIT_FAILURE); } int main(int argc, char **argv) { int i; + const char *outtile = NULL; const char *outfile = NULL; + std::vector sources; + struct option long_options[] = { {"include", required_argument, 0, 'y'}, {"full-detail", required_argument, 0, 'd'}, @@ -43,6 +48,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}, + {"source-tile", required_argument, 0, 't'}, {0, 0, 0, 0}, }; @@ -97,53 +103,71 @@ int main(int argc, char **argv) { unidecode_data = read_unidecode(optarg); break; + case 't': + outtile = optarg; + break; + default: fprintf(stderr, "Unrecognized flag -%c\n", i); usage(argv); } } - if (argc - optind != 3) { - usage(argv); - } - - if (outfile == NULL) { - usage(argv); - } - - const char *infile = argv[optind + 0]; - - int oz, ox, oy; - if (sscanf(argv[optind + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) { - fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 1]); - usage(argv); - } - + std::vector its; int nz, nx, ny; - if (sscanf(argv[optind + 2], "%d/%d/%d", &nz, &nx, &ny) != 3) { - fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 2]); - usage(argv); - } - std::string tile; - char buf[1000]; - int len; + if (outtile == NULL) { // single input + if (argc - optind != 3) { + fprintf(stderr, "Wrong number of arguments\n"); + usage(argv); + } - FILE *f = fopen(infile, "rb"); - if (f == NULL) { - perror(infile); - exit(EXIT_FAILURE); - } + const char *infile = argv[optind + 0]; - while ((len = fread(buf, sizeof(char), 1000, f)) > 0) { - tile.append(std::string(buf, len)); - } - fclose(f); + int oz, ox, oy; + if (sscanf(argv[optind + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) { + fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 1]); + usage(argv); + } - f = fopen(outfile, "wb"); - if (f == NULL) { - perror(outfile); - exit(EXIT_FAILURE); + if (sscanf(argv[optind + 2], "%d/%d/%d", &nz, &nx, &ny) != 3) { + fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 2]); + usage(argv); + } + + input_tile s; + s.tile = infile; + s.z = oz; + s.x = ox; + s.y = oy; + + sources.push_back(s); + } else { // multiple inputs + if ((argc - optind) % 2 != 0) { + fprintf(stderr, "Unpaired arguments\n"); + usage(argv); + } + + if (sscanf(outtile, "%d/%d/%d", &nz, &nx, &ny) != 3) { + fprintf(stderr, "%s: not in z/x/y form\n", outtile); + usage(argv); + } + + for (i = optind; i + 1 < argc; i += 2) { + int oz, ox, oy; + if (sscanf(argv[i + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) { + fprintf(stderr, "%s: not in z/x/y form\n", argv[i + 1]); + usage(argv); + } + + input_tile s; + s.tile = argv[i]; + s.z = oz; + s.x = ox; + s.y = oy; + + sources.push_back(s); + } } json_object *json_filter = NULL; @@ -151,7 +175,35 @@ 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); + for (auto const &s : sources) { + std::string tile; + char buf[1000]; + int len; + + FILE *f = fopen(s.tile.c_str(), "rb"); + if (f == NULL) { + perror(s.tile.c_str()); + exit(EXIT_FAILURE); + } + + while ((len = fread(buf, sizeof(char), 1000, f)) > 0) { + tile.append(std::string(buf, len)); + } + fclose(f); + + input_tile t = s; + t.tile = std::move(tile); + its.push_back(std::move(t)); + } + + std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data); + + FILE *f = fopen(outfile, "wb"); + if (f == NULL) { + perror(outfile); + exit(EXIT_FAILURE); + } + fwrite(out.c_str(), sizeof(char), out.size(), f); fclose(f); diff --git a/tests/pbf/0-0-0.pbf b/tests/pbf/0-0-0.pbf new file mode 100644 index 00000000..cf7b426b Binary files /dev/null and b/tests/pbf/0-0-0.pbf differ diff --git a/tests/pbf/13-1310-3166-ne.pbf.json b/tests/pbf/13-1310-3166-ne.pbf.json new file mode 100644 index 00000000..852b0102 --- /dev/null +++ b/tests/pbf/13-1310-3166-ne.pbf.json @@ -0,0 +1,21 @@ +{ "type": "FeatureCollection", "properties": { "zoom": 13, "x": 1310, "y": 3166 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_land", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "featurecla": "Land", "scalerank": 0, "min_zoom": 0 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.387760, 37.788760 ], [ -122.387094, 37.778754 ], [ -122.386837, 37.778517 ], [ -122.386837, 37.752665 ], [ -122.432499, 37.752665 ], [ -122.432499, 37.788760 ], [ -122.387760, 37.788760 ] ] ] } } +] } +, +{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_populated_places", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "SCALERANK": 1, "NATSCALE": 300, "LABELRANK": 1, "FEATURECLA": "Populated place", "NAME": "San Francisco", "NAMEALT": "San Francisco-Oakland", "NAMEASCII": "San Francisco", "ADM0CAP": 0, "WORLDCITY": 1, "MEGACITY": 1, "SOV0NAME": "United States", "SOV_A3": "USA", "ADM0NAME": "United States of America", "ADM0_A3": "USA", "ADM1NAME": "California", "ISO_A2": "US", "LATITUDE": 37.769196, "LONGITUDE": -122.417169, "POP_MAX": 3450000, "POP_MIN": 732072, "POP_OTHER": 27400, "RANK_MAX": 12, "RANK_MIN": 11, "MEGANAME": "San Francisco-Oakland", "LS_NAME": "San Francisco1", "MAX_POP10": 988636, "MAX_POP20": 1130999, "MAX_POP50": 1371285, "MAX_POP300": 4561697, "MAX_POP310": 4561697, "MAX_NATSCA": 300, "MIN_AREAKM": 218, "MAX_AREAKM": 1748, "MIN_AREAMI": 84, "MAX_AREAMI": 675, "MIN_PERKM": 126, "MAX_PERKM": 755, "MIN_PERMI": 78, "MAX_PERMI": 469, "MIN_BBXMIN": -122.516667, "MAX_BBXMIN": -122.516667, "MIN_BBXMAX": -122.358333, "MAX_BBXMAX": -121.733333, "MIN_BBYMIN": 37.191667, "MAX_BBYMIN": 37.575, "MIN_BBYMAX": 37.816667, "MAX_BBYMAX": 38.041667, "MEAN_BBXC": -122.301354, "MEAN_BBYC": 37.622288, "TIMEZONE": "America/Los_Angeles", "UN_FID": 570, "POP1950": 1855, "POP1955": 2021, "POP1960": 2200, "POP1965": 2361, "POP1970": 2529, "POP1975": 2590, "POP1980": 2656, "POP1985": 2805, "POP1990": 2961, "POP1995": 3095, "POP2000": 3236, "POP2005": 3387, "POP2010": 3450, "POP2015": 3544, "POP2020": 3684, "POP2025": 3803, "POP2050": 3898, "MIN_ZOOM": 2.7, "WIKIDATAID": "Q62", "WOF_ID": 85922583, "CAPALT": 0, "NAME_EN": "San Francisco", "NAME_DE": "San Francisco", "NAME_ES": "San Francisco", "NAME_FR": "San Francisco", "NAME_PT": "São Francisco", "NAME_RU": "Сан-Франциско", "NAME_ZH": "旧金山", "NAME_AR": "سان فرانسيسكو", "NAME_BN": "সান ফ্রান্সিস্কো", "NAME_EL": "Σαν Φρανσίσκο", "NAME_HI": "सैन फ्रांसिस्को", "NAME_HU": "San Francisco", "NAME_ID": "San Francisco", "NAME_IT": "San Francisco", "NAME_JA": "サンフランシスコ", "NAME_KO": "샌프란시스코", "NAME_NL": "San Francisco", "NAME_PL": "San Francisco", "NAME_SV": "San Francisco", "NAME_TR": "San Francisco", "NAME_VI": "San Francisco", "NE_ID": 1159151479, "NAME_FA": "سان فرانسیسکو", "NAME_HE": "סן פרנסיסקו", "NAME_UK": "Сан-Франциско", "NAME_UR": "سان فرانسسکو", "NAME_ZHT": "舊金山", "GEONAMESID": 5391959 }, "geometry": { "type": "Point", "coordinates": [ -122.399583, 37.784249 ] } } +] } +, +{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_roads", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "scalerank": 4, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "101", "question": 0, "length_km": 11, "toll": 0, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 118705, "continent": "North America", "expressway": 1, "level": "Federal", "min_zoom": 4, "min_label": 7 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.407351, 37.767933 ], [ -122.412586, 37.781841 ], [ -122.419496, 37.788760 ] ] } } +, +{ "type": "Feature", "properties": { "scalerank": 3, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "80", "question": 0, "length_km": 14, "toll": 1, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 311505, "continent": "North America", "expressway": 1, "level": "Interstate", "min_zoom": 3, "min_label": 6 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.407351, 37.767933 ], [ -122.388253, 37.785300 ], [ -122.386837, 37.786453 ] ] } } +, +{ "type": "Feature", "properties": { "scalerank": 4, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "280", "question": 0, "length_km": 52, "toll": 0, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 124805, "continent": "North America", "expressway": 1, "level": "Interstate", "min_zoom": 4, "min_label": 7 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.405677, 37.752665 ], [ -122.407351, 37.767933 ] ] } } +] } +, +{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_admin_0_countries", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "featurecla": "Admin-0 country", "scalerank": 0, "LABELRANK": 2, "SOVEREIGNT": "United States of America", "SOV_A3": "US1", "ADM0_DIF": 1, "LEVEL": 2, "TYPE": "Country", "TLC": "1", "ADMIN": "United States of America", "ADM0_A3": "USA", "GEOU_DIF": 0, "GEOUNIT": "United States of America", "GU_A3": "USA", "SU_DIF": 0, "SUBUNIT": "United States", "SU_A3": "USA", "BRK_DIFF": 0, "NAME": "United States of America", "NAME_LONG": "United States", "BRK_A3": "USA", "BRK_NAME": "United States", "ABBREV": "U.S.A.", "POSTAL": "US", "FORMAL_EN": "United States of America", "NAME_CIAWF": "United States", "NAME_SORT": "United States of America", "MAPCOLOR7": 4, "MAPCOLOR8": 5, "MAPCOLOR9": 1, "MAPCOLOR13": 1, "POP_EST": 328239523, "POP_RANK": 17, "POP_YEAR": 2019, "GDP_MD": 21433226, "GDP_YEAR": 2019, "ECONOMY": "1. Developed region: G7", "INCOME_GRP": "1. High income: OECD", "FIPS_10": "US", "ISO_A2": "US", "ISO_A2_EH": "US", "ISO_A3": "USA", "ISO_A3_EH": "USA", "ISO_N3": "840", "ISO_N3_EH": "840", "UN_A3": "840", "WB_A2": "US", "WB_A3": "USA", "WOE_ID": 23424977, "WOE_ID_EH": 23424977, "WOE_NOTE": "Exact WOE match as country", "ADM0_ISO": "USA", "ADM0_TLC": "USA", "ADM0_A3_US": "USA", "ADM0_A3_FR": "USA", "ADM0_A3_RU": "USA", "ADM0_A3_ES": "USA", "ADM0_A3_CN": "USA", "ADM0_A3_TW": "USA", "ADM0_A3_IN": "USA", "ADM0_A3_NP": "USA", "ADM0_A3_PK": "USA", "ADM0_A3_DE": "USA", "ADM0_A3_GB": "USA", "ADM0_A3_BR": "USA", "ADM0_A3_IL": "USA", "ADM0_A3_PS": "USA", "ADM0_A3_SA": "USA", "ADM0_A3_EG": "USA", "ADM0_A3_MA": "USA", "ADM0_A3_PT": "USA", "ADM0_A3_AR": "USA", "ADM0_A3_JP": "USA", "ADM0_A3_KO": "USA", "ADM0_A3_VN": "USA", "ADM0_A3_TR": "USA", "ADM0_A3_ID": "USA", "ADM0_A3_PL": "USA", "ADM0_A3_GR": "USA", "ADM0_A3_IT": "USA", "ADM0_A3_NL": "USA", "ADM0_A3_SE": "USA", "ADM0_A3_BD": "USA", "ADM0_A3_UA": "USA", "ADM0_A3_UN": -99, "ADM0_A3_WB": -99, "CONTINENT": "North America", "REGION_UN": "Americas", "SUBREGION": "Northern America", "REGION_WB": "North America", "NAME_LEN": 24, "LONG_LEN": 13, "ABBREV_LEN": 6, "TINY": -99, "HOMEPART": 1, "MIN_ZOOM": 0, "MIN_LABEL": 1.7, "MAX_LABEL": 5.7, "LABEL_X": -97.482602, "LABEL_Y": 39.538479, "NE_ID": 1159321369, "WIKIDATAID": "Q30", "NAME_AR": "الولايات المتحدة", "NAME_BN": "মার্কিন যুক্তরাষ্ট্র", "NAME_DE": "Vereinigte Staaten", "NAME_EN": "United States of America", "NAME_ES": "Estados Unidos", "NAME_FA": "ایالات متحده آمریکا", "NAME_FR": "États-Unis", "NAME_EL": "Ηνωμένες Πολιτείες Αμερικής", "NAME_HE": "ארצות הברית", "NAME_HI": "संयुक्त राज्य अमेरिका", "NAME_HU": "Amerikai Egyesült Államok", "NAME_ID": "Amerika Serikat", "NAME_IT": "Stati Uniti d'America", "NAME_JA": "アメリカ合衆国", "NAME_KO": "미국", "NAME_NL": "Verenigde Staten van Amerika", "NAME_PL": "Stany Zjednoczone", "NAME_PT": "Estados Unidos", "NAME_RU": "США", "NAME_SV": "USA", "NAME_TR": "Amerika Birleşik Devletleri", "NAME_UK": "Сполучені Штати Америки", "NAME_UR": "ریاستہائے متحدہ امریکا", "NAME_VI": "Hoa Kỳ", "NAME_ZH": "美国", "NAME_ZHT": "美國", "FCLASS_ISO": "Admin-0 country", "FCLASS_TLC": "Admin-0 country" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.432499, 37.788081 ], [ -122.386837, 37.788081 ], [ -122.386837, 37.752665 ], [ -122.432499, 37.752665 ], [ -122.432499, 37.788081 ] ] ] } } +] } +] } diff --git a/tile-join.cpp b/tile-join.cpp index 3abc70a5..aa860146 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -704,7 +704,15 @@ 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::vector tv; + source_tile t; + t.tile = std::move(source); + t.z = parent_tile.z; + t.x = parent_tile.x; + t.y = parent_tile.y; + tv.push_back(std::move(t)); + + std::string ret = overzoom(tv, tile.z, tile.x, tile.y, -1, buffer, std::set(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map(), unidecode_data); return ret; } diff --git a/version.hpp b/version.hpp index 44b97a9b..db792d63 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v2.56.0" +#define VERSION "v2.57.0" #endif