mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Plumb a clip bounding box around through overzoom
This commit is contained in:
@@ -1087,7 +1087,8 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
|||||||
std::vector<std::string> const &unidecode_data, double simplification,
|
std::vector<std::string> const &unidecode_data, double simplification,
|
||||||
double tiny_polygon_size,
|
double tiny_polygon_size,
|
||||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||||
std::string const &accumulate_numeric, size_t feature_limit) {
|
std::string const &accumulate_numeric, size_t feature_limit,
|
||||||
|
std::vector<clipbbox> const &clipbboxes) {
|
||||||
std::vector<source_tile> decoded;
|
std::vector<source_tile> decoded;
|
||||||
|
|
||||||
for (auto const &t : tiles) {
|
for (auto const &t : tiles) {
|
||||||
@@ -1113,7 +1114,7 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
|||||||
decoded.push_back(out);
|
decoded.push_back(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
return overzoom(decoded, nz, nx, ny, detail_or_unspecified, buffer, keep, exclude, exclude_prefix, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, feature_limit);
|
return overzoom(decoded, nz, nx, ny, detail_or_unspecified, buffer, keep, exclude, exclude_prefix, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, feature_limit, clipbboxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// like a minimal serial_feature, but with mvt_feature-style attributes
|
// like a minimal serial_feature, but with mvt_feature-style attributes
|
||||||
@@ -1776,7 +1777,8 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
std::vector<std::string> const &unidecode_data, double simplification,
|
std::vector<std::string> const &unidecode_data, double simplification,
|
||||||
double tiny_polygon_size,
|
double tiny_polygon_size,
|
||||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||||
std::string const &accumulate_numeric, size_t feature_limit) {
|
std::string const &accumulate_numeric, size_t feature_limit,
|
||||||
|
std::vector<clipbbox> const &clipbboxes) {
|
||||||
mvt_tile outtile;
|
mvt_tile outtile;
|
||||||
key_pool key_pool;
|
key_pool key_pool;
|
||||||
|
|
||||||
@@ -2003,7 +2005,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
detail_or_unspecified, buffer, keep, exclude, exclude_prefix, false, NULL,
|
detail_or_unspecified, buffer, keep, exclude, exclude_prefix, false, NULL,
|
||||||
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data,
|
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data,
|
||||||
simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric,
|
simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric,
|
||||||
1);
|
1, clipbboxes);
|
||||||
if (child.size() > 0) {
|
if (child.size() > 0) {
|
||||||
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
|
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -115,6 +115,18 @@ struct source_tile {
|
|||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct clipbbox {
|
||||||
|
double lon1;
|
||||||
|
double lat1;
|
||||||
|
double lon2;
|
||||||
|
double lat2;
|
||||||
|
|
||||||
|
long long minx;
|
||||||
|
long long miny;
|
||||||
|
long long maxx;
|
||||||
|
long long maxy;
|
||||||
|
};
|
||||||
|
|
||||||
std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int ny,
|
std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int ny,
|
||||||
int detail, int buffer,
|
int detail, int buffer,
|
||||||
std::set<std::string> const &keep,
|
std::set<std::string> const &keep,
|
||||||
@@ -127,7 +139,8 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
std::vector<std::string> const &unidecode_data, double simplification,
|
std::vector<std::string> const &unidecode_data, double simplification,
|
||||||
double tiny_polygon_size,
|
double tiny_polygon_size,
|
||||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||||
std::string const &accumulate_numeric, size_t feature_limit);
|
std::string const &accumulate_numeric, size_t feature_limit,
|
||||||
|
std::vector<clipbbox> const &clipbboxes);
|
||||||
|
|
||||||
std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int ny,
|
std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int ny,
|
||||||
int detail, int buffer,
|
int detail, int buffer,
|
||||||
@@ -141,7 +154,8 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
|||||||
std::vector<std::string> const &unidecode_data, double simplification,
|
std::vector<std::string> const &unidecode_data, double simplification,
|
||||||
double tiny_polygon_size,
|
double tiny_polygon_size,
|
||||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||||
std::string const &accumulate_numeric, size_t feature_limit);
|
std::string const &accumulate_numeric, size_t feature_limit,
|
||||||
|
std::vector<clipbbox> const &clipbboxes);
|
||||||
|
|
||||||
draw center_of_mass_mp(const drawvec &dv);
|
draw center_of_mass_mp(const drawvec &dv);
|
||||||
|
|
||||||
|
|||||||
@@ -24,18 +24,6 @@ struct index {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clipbbox {
|
|
||||||
double lon1;
|
|
||||||
double lat1;
|
|
||||||
double lon2;
|
|
||||||
double lat2;
|
|
||||||
|
|
||||||
long long minx;
|
|
||||||
long long miny;
|
|
||||||
long long maxx;
|
|
||||||
long long maxy;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern std::vector<clipbbox> clipbboxes;
|
extern std::vector<clipbbox> clipbboxes;
|
||||||
|
|
||||||
void checkdisk(std::vector<struct reader> *r);
|
void checkdisk(std::vector<struct reader> *r);
|
||||||
|
|||||||
+17
-1
@@ -10,6 +10,7 @@
|
|||||||
#include "attribute.hpp"
|
#include "attribute.hpp"
|
||||||
#include "text.hpp"
|
#include "text.hpp"
|
||||||
#include "read_json.hpp"
|
#include "read_json.hpp"
|
||||||
|
#include "projection.hpp"
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
@@ -29,6 +30,7 @@ std::string accumulate_numeric;
|
|||||||
std::set<std::string> keep;
|
std::set<std::string> keep;
|
||||||
std::set<std::string> exclude;
|
std::set<std::string> exclude;
|
||||||
std::vector<std::string> exclude_prefix;
|
std::vector<std::string> exclude_prefix;
|
||||||
|
std::vector<clipbbox> clipbboxes;
|
||||||
|
|
||||||
void usage(char **argv) {
|
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, "Usage: %s -o newtile.pbf.gz tile.pbf.gz oz/ox/oy nz/nx/ny\n", argv[0]);
|
||||||
@@ -67,7 +69,9 @@ int main(int argc, char **argv) {
|
|||||||
{"assign-to-bins", required_argument, 0, 'b' & 0x1F},
|
{"assign-to-bins", required_argument, 0, 'b' & 0x1F},
|
||||||
{"bin-by-id-list", required_argument, 0, 'c' & 0x1F},
|
{"bin-by-id-list", required_argument, 0, 'c' & 0x1F},
|
||||||
{"accumulate-numeric-attributes", required_argument, 0, 'a' & 0x1F},
|
{"accumulate-numeric-attributes", required_argument, 0, 'a' & 0x1F},
|
||||||
|
{"numeric-attributes", required_argument, 0, 'a' & 0x1F},
|
||||||
{"no-tile-compression", no_argument, 0, 'd' & 0x1F},
|
{"no-tile-compression", no_argument, 0, 'd' & 0x1F},
|
||||||
|
{"clip-bounding-box", required_argument, 0, 'k' & 0x1F},
|
||||||
|
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
@@ -158,6 +162,18 @@ int main(int argc, char **argv) {
|
|||||||
do_compress = false;
|
do_compress = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'k' & 0x1F:
|
||||||
|
clipbbox clip;
|
||||||
|
if (sscanf(optarg, "%lf,%lf,%lf,%lf", &clip.lon1, &clip.lat1, &clip.lon2, &clip.lat2) == 4) {
|
||||||
|
projection->project(clip.lon1, clip.lat1, 32, &clip.minx, &clip.maxy);
|
||||||
|
projection->project(clip.lon2, clip.lat2, 32, &clip.maxx, &clip.miny);
|
||||||
|
clipbboxes.push_back(clip);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s: Can't parse bounding box --clip-bounding-box=%s\n", argv[0], optarg);
|
||||||
|
exit(EXIT_ARGS);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
||||||
usage(argv);
|
usage(argv);
|
||||||
@@ -262,7 +278,7 @@ int main(int argc, char **argv) {
|
|||||||
its.push_back(std::move(t));
|
its.push_back(std::move(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, SIZE_MAX);
|
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, SIZE_MAX, clipbboxes);
|
||||||
|
|
||||||
FILE *f = fopen(outfile, "wb");
|
FILE *f = fopen(outfile, "wb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
|||||||
+2
-1
@@ -716,7 +716,8 @@ struct tileset_reader {
|
|||||||
std::set<std::string>(), std::set<std::string>(), std::vector<std::string>(),
|
std::set<std::string>(), std::set<std::string>(), std::vector<std::string>(),
|
||||||
false, &next_overzoomed_tiles, false, NULL, false,
|
false, &next_overzoomed_tiles, false, NULL, false,
|
||||||
std::unordered_map<std::string, attribute_op>(), unidecode_data, 0, 0,
|
std::unordered_map<std::string, attribute_op>(), unidecode_data, 0, 0,
|
||||||
std::vector<mvt_layer>(), "", "", SIZE_MAX);
|
std::vector<mvt_layer>(), "", "", SIZE_MAX,
|
||||||
|
std::vector<clipbbox>());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user