mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 18:35:41 +02:00
Plumbing for exclude and exclude-prefix
This commit is contained in:
@@ -1076,7 +1076,11 @@ bool pnpoly_mp(std::vector<mvt_geometry> const &geom, long long x, long long y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer,
|
||||||
|
std::set<std::string> const &keep,
|
||||||
|
std::set<std::string> const &exclude,
|
||||||
|
std::vector<std::string> const &exclude_prefix,
|
||||||
|
bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order,
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
@@ -1108,7 +1112,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, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
return overzoom(decoded, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
||||||
}
|
}
|
||||||
|
|
||||||
// like a minimal serial_feature, but with mvt_feature-style attributes
|
// like a minimal serial_feature, but with mvt_feature-style attributes
|
||||||
@@ -1237,6 +1241,8 @@ static void preserve_numeric(const std::string &key, const mvt_value &val, /
|
|||||||
|
|
||||||
static void feature_out(std::vector<tile_feature> const &features, mvt_layer &outlayer,
|
static void feature_out(std::vector<tile_feature> const &features, mvt_layer &outlayer,
|
||||||
std::set<std::string> const &keep,
|
std::set<std::string> const &keep,
|
||||||
|
std::set<std::string> const &exclude,
|
||||||
|
std::vector<std::string> const &exclude_prefix,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
std::shared_ptr<std::string> const &tile_stringpool,
|
std::shared_ptr<std::string> const &tile_stringpool,
|
||||||
std::string const &accumulate_numeric) {
|
std::string const &accumulate_numeric) {
|
||||||
@@ -1452,7 +1458,10 @@ static bool bbox_intersects(long long x1min, long long y1min, long long x1max, l
|
|||||||
|
|
||||||
mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &bins, int z, int x, int y, int detail,
|
mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &bins, int z, int x, int y, int detail,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
std::string const &accumulate_numeric) {
|
std::string const &accumulate_numeric,
|
||||||
|
std::set<std::string> keep,
|
||||||
|
std::set<std::string> exclude,
|
||||||
|
std::vector<std::string> exclude_prefix) {
|
||||||
std::vector<index_event> events;
|
std::vector<index_event> events;
|
||||||
|
|
||||||
// Index bins
|
// Index bins
|
||||||
@@ -1548,7 +1557,7 @@ mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &
|
|||||||
if (found != active.end()) {
|
if (found != active.end()) {
|
||||||
if (outfeatures[found->outfeature].size() > 1) {
|
if (outfeatures[found->outfeature].size() > 1) {
|
||||||
feature_out(outfeatures[found->outfeature], outlayer,
|
feature_out(outfeatures[found->outfeature], outlayer,
|
||||||
std::set<std::string>(), attribute_accum,
|
keep, exclude, exclude_prefix, attribute_accum,
|
||||||
tile_stringpool, accumulate_numeric);
|
tile_stringpool, accumulate_numeric);
|
||||||
mvt_feature &nfeature = outlayer.features.back();
|
mvt_feature &nfeature = outlayer.features.back();
|
||||||
mvt_value val;
|
mvt_value val;
|
||||||
@@ -1578,7 +1587,11 @@ mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer,
|
||||||
|
std::set<std::string> const &keep,
|
||||||
|
std::set<std::string> const &exclude,
|
||||||
|
std::vector<std::string> const &exclude_prefix,
|
||||||
|
bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order,
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
@@ -1710,7 +1723,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
|
|
||||||
if (flush_multiplier_cluster) {
|
if (flush_multiplier_cluster) {
|
||||||
if (pending_tile_features.size() > 0) {
|
if (pending_tile_features.size() > 0) {
|
||||||
feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool, accumulate_numeric);
|
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, tile_stringpool, accumulate_numeric);
|
||||||
pending_tile_features.clear();
|
pending_tile_features.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1767,7 +1780,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pending_tile_features.size() > 0) {
|
if (pending_tile_features.size() > 0) {
|
||||||
feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool, accumulate_numeric);
|
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, tile_stringpool, accumulate_numeric);
|
||||||
pending_tile_features.clear();
|
pending_tile_features.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1799,7 +1812,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
|
|
||||||
std::string child = overzoom(sts,
|
std::string child = overzoom(sts,
|
||||||
nz + 1, nx * 2 + x, ny * 2 + y,
|
nz + 1, nx * 2 + x, ny * 2 + y,
|
||||||
detail, buffer, keep, false, NULL,
|
detail, buffer, keep, exclude, exclude_prefix, false, NULL,
|
||||||
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
||||||
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);
|
||||||
@@ -1810,7 +1823,8 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bins.size() > 0) {
|
if (bins.size() > 0) {
|
||||||
outtile = assign_to_bins(outtile, bins, nz, nx, ny, detail, attribute_accum, accumulate_numeric);
|
outtile = assign_to_bins(outtile, bins, nz, nx, ny, detail, attribute_accum, accumulate_numeric,
|
||||||
|
keep, exclude, exclude_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ssize_t i = outtile.layers.size() - 1; i >= 0; i--) {
|
for (ssize_t i = outtile.layers.size() - 1; i >= 0; i--) {
|
||||||
|
|||||||
+10
-2
@@ -116,7 +116,11 @@ struct source_tile {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer,
|
||||||
|
std::set<std::string> const &keep,
|
||||||
|
std::set<std::string> const &exclude,
|
||||||
|
std::vector<std::string> const &exclude_prefix,
|
||||||
|
bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order,
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
@@ -125,7 +129,11 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
std::string const &accumulate_numeric);
|
std::string const &accumulate_numeric);
|
||||||
|
|
||||||
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, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer,
|
||||||
|
std::set<std::string> const &keep,
|
||||||
|
std::set<std::string> const &exclude,
|
||||||
|
std::vector<std::string> const &exclude_prefix,
|
||||||
|
bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order,
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||||
|
|||||||
+13
-1
@@ -25,6 +25,8 @@ std::vector<mvt_layer> bins;
|
|||||||
std::string accumulate_numeric;
|
std::string accumulate_numeric;
|
||||||
|
|
||||||
std::set<std::string> keep;
|
std::set<std::string> keep;
|
||||||
|
std::set<std::string> exclude;
|
||||||
|
std::vector<std::string> exclude_prefix;
|
||||||
|
|
||||||
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]);
|
||||||
@@ -46,6 +48,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{"include", required_argument, 0, 'y'},
|
{"include", required_argument, 0, 'y'},
|
||||||
|
{"exclude", required_argument, 0, 'x'},
|
||||||
|
{"exclude-prefix", required_argument, 0, 'x' & 0x1F},
|
||||||
{"full-detail", required_argument, 0, 'd'},
|
{"full-detail", required_argument, 0, 'd'},
|
||||||
{"buffer", required_argument, 0, 'b'},
|
{"buffer", required_argument, 0, 'b'},
|
||||||
{"output", required_argument, 0, 'o'},
|
{"output", required_argument, 0, 'o'},
|
||||||
@@ -81,6 +85,14 @@ int main(int argc, char **argv) {
|
|||||||
keep.insert(optarg);
|
keep.insert(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
exclude.insert(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'x' & 0x1F:
|
||||||
|
exclude_prefix.push_back(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
outfile = optarg;
|
outfile = optarg;
|
||||||
break;
|
break;
|
||||||
@@ -233,7 +245,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, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, accumulate_numeric);
|
||||||
|
|
||||||
FILE *f = fopen(outfile, "wb");
|
FILE *f = fopen(outfile, "wb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
|||||||
+3
-1
@@ -712,7 +712,9 @@ struct tileset_reader {
|
|||||||
t.y = parent_tile.y;
|
t.y = parent_tile.y;
|
||||||
tv.push_back(std::move(t));
|
tv.push_back(std::move(t));
|
||||||
|
|
||||||
std::string ret = overzoom(tv, tile.z, tile.x, tile.y, -1, buffer, std::set<std::string>(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map<std::string, attribute_op>(), unidecode_data, 0, 0, std::vector<mvt_layer>(), "");
|
std::string ret = overzoom(tv, tile.z, tile.x, tile.y, -1, buffer,
|
||||||
|
std::set<std::string>(), std::set<std::string>(), std::vector<std::string>(),
|
||||||
|
false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map<std::string, attribute_op>(), unidecode_data, 0, 0, std::vector<mvt_layer>(), "");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user