mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Add option to remove geometry in tile-join (#382)
add option to remove geometry in `tile-join` Co-authored-by: indus <stefan.keim@posteo.de>
This commit is contained in:
@@ -407,7 +407,8 @@ std::string mvt_tile::encode() {
|
|||||||
std::string feature_string;
|
std::string feature_string;
|
||||||
protozero::pbf_writer feature_writer(feature_string);
|
protozero::pbf_writer feature_writer(feature_string);
|
||||||
|
|
||||||
feature_writer.add_enum(3, layers[i].features[f].type);
|
if (layers[i].features[f].type >= 0)
|
||||||
|
feature_writer.add_enum(3, layers[i].features[f].type);
|
||||||
|
|
||||||
std::vector<unsigned> sorted_tags = layers[i].features[f].tags;
|
std::vector<unsigned> sorted_tags = layers[i].features[f].tags;
|
||||||
for (size_t v = 1; v < sorted_tags.size(); v += 2) {
|
for (size_t v = 1; v < sorted_tags.size(); v += 2) {
|
||||||
|
|||||||
+41
-33
@@ -56,6 +56,7 @@ int minzoom = 0;
|
|||||||
std::map<std::string, std::string> renames;
|
std::map<std::string, std::string> renames;
|
||||||
bool exclude_all = false;
|
bool exclude_all = false;
|
||||||
bool exclude_all_tile_attributes = false;
|
bool exclude_all_tile_attributes = false;
|
||||||
|
bool exclude_all_tile_geometries = false;
|
||||||
std::vector<std::string> unidecode_data;
|
std::vector<std::string> unidecode_data;
|
||||||
|
|
||||||
bool want_overzoom = false;
|
bool want_overzoom = false;
|
||||||
@@ -323,42 +324,46 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outfeature.type = feat.type;
|
if (exclude_all_tile_geometries) {
|
||||||
outfeature.geometry = feat.geometry;
|
outfeature.type = -1;
|
||||||
|
} else {
|
||||||
|
outfeature.type = feat.type;
|
||||||
|
outfeature.geometry = feat.geometry;
|
||||||
|
|
||||||
if (layer.extent != outlayer.extent) {
|
if (layer.extent != outlayer.extent) {
|
||||||
for (size_t i = 0; i < outfeature.geometry.size(); i++) {
|
for (size_t i = 0; i < outfeature.geometry.size(); i++) {
|
||||||
outfeature.geometry[i].x = outfeature.geometry[i].x * outlayer.extent / layer.extent;
|
outfeature.geometry[i].x = outfeature.geometry[i].x * outlayer.extent / layer.extent;
|
||||||
outfeature.geometry[i].y = outfeature.geometry[i].y * outlayer.extent / layer.extent;
|
outfeature.geometry[i].y = outfeature.geometry[i].y * outlayer.extent / layer.extent;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const &g : outfeature.geometry) {
|
|
||||||
if (g.op == mvt_moveto || g.op == mvt_lineto) {
|
|
||||||
// pin to the tile extent, since we don't want bounds bigger than the earth
|
|
||||||
long long gx = std::min((long long) outlayer.extent, std::max(0LL, g.x));
|
|
||||||
long long gy = std::min((long long) outlayer.extent, std::max(0LL, g.y));
|
|
||||||
|
|
||||||
// to world scale
|
|
||||||
gx = gx * (1LL << (32 - z)) / outlayer.extent;
|
|
||||||
gy = gy * (1LL << (32 - z)) / outlayer.extent;
|
|
||||||
|
|
||||||
// to world offset
|
|
||||||
gx += (1LL << (32 - z)) * x;
|
|
||||||
gy += (1LL << (32 - z)) * y;
|
|
||||||
|
|
||||||
minx = std::min(minx, gx);
|
|
||||||
miny = std::min(miny, gy);
|
|
||||||
maxx = std::max(maxx, gx);
|
|
||||||
maxy = std::max(maxy, gy);
|
|
||||||
|
|
||||||
// if in the western hemisphere, try shifting to east
|
|
||||||
if (gx < (1LL << 31)) {
|
|
||||||
gx += 1LL << 32;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minx2 = std::min(minx2, gx);
|
for (auto const &g : outfeature.geometry) {
|
||||||
maxx2 = std::max(maxx2, gx);
|
if (g.op == mvt_moveto || g.op == mvt_lineto) {
|
||||||
|
// pin to the tile extent, since we don't want bounds bigger than the earth
|
||||||
|
long long gx = std::min((long long) outlayer.extent, std::max(0LL, g.x));
|
||||||
|
long long gy = std::min((long long) outlayer.extent, std::max(0LL, g.y));
|
||||||
|
|
||||||
|
// to world scale
|
||||||
|
gx = gx * (1LL << (32 - z)) / outlayer.extent;
|
||||||
|
gy = gy * (1LL << (32 - z)) / outlayer.extent;
|
||||||
|
|
||||||
|
// to world offset
|
||||||
|
gx += (1LL << (32 - z)) * x;
|
||||||
|
gy += (1LL << (32 - z)) * y;
|
||||||
|
|
||||||
|
minx = std::min(minx, gx);
|
||||||
|
miny = std::min(miny, gy);
|
||||||
|
maxx = std::max(maxx, gx);
|
||||||
|
maxy = std::max(maxy, gy);
|
||||||
|
|
||||||
|
// if in the western hemisphere, try shifting to east
|
||||||
|
if (gx < (1LL << 31)) {
|
||||||
|
gx += 1LL << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
minx2 = std::min(minx2, gx);
|
||||||
|
maxx2 = std::max(maxx2, gx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1309,6 +1314,7 @@ int main(int argc, char **argv) {
|
|||||||
{"exclude-all", no_argument, 0, 'X'},
|
{"exclude-all", no_argument, 0, 'X'},
|
||||||
{"include", required_argument, 0, 'y'},
|
{"include", required_argument, 0, 'y'},
|
||||||
{"exclude-all-tile-attributes", no_argument, 0, '~'},
|
{"exclude-all-tile-attributes", no_argument, 0, '~'},
|
||||||
|
{"exclude-all-tile-geometries", no_argument, 0, '~'},
|
||||||
{"layer", required_argument, 0, 'l'},
|
{"layer", required_argument, 0, 'l'},
|
||||||
{"exclude-layer", required_argument, 0, 'L'},
|
{"exclude-layer", required_argument, 0, 'L'},
|
||||||
{"quiet", no_argument, 0, 'q'},
|
{"quiet", no_argument, 0, 'q'},
|
||||||
@@ -1507,6 +1513,8 @@ int main(int argc, char **argv) {
|
|||||||
unidecode_data = read_unidecode(optarg);
|
unidecode_data = read_unidecode(optarg);
|
||||||
} else if (strcmp(opt, "exclude-all-tile-attributes") == 0) {
|
} else if (strcmp(opt, "exclude-all-tile-attributes") == 0) {
|
||||||
exclude_all_tile_attributes = true;
|
exclude_all_tile_attributes = true;
|
||||||
|
} else if (strcmp(opt, "exclude-all-tile-geometries") == 0) {
|
||||||
|
exclude_all_tile_geometries = true;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
||||||
exit(EXIT_ARGS);
|
exit(EXIT_ARGS);
|
||||||
|
|||||||
Reference in New Issue
Block a user