mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Fix clipping bug when the clip region doesn't intersect the tile (#312)
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# 2.73.0
|
||||||
|
|
||||||
|
* Correctly clip features down to nothing when the clip region doesn't intersect the tile at all
|
||||||
|
|
||||||
# 2.72.0
|
# 2.72.0
|
||||||
|
|
||||||
* Add --clip-polygon-file and --feature-filter-file options to tippecanoe-overzoom
|
* Add --clip-polygon-file and --feature-filter-file options to tippecanoe-overzoom
|
||||||
|
|||||||
@@ -439,6 +439,10 @@ overzoom-test: tippecanoe-overzoom
|
|||||||
./tippecanoe-decode tests/pbf/countries-8-135-86-bigclip.pbf 8 135 86 > tests/pbf/countries-8-135-86-bigclip.json.check
|
./tippecanoe-decode tests/pbf/countries-8-135-86-bigclip.pbf 8 135 86 > tests/pbf/countries-8-135-86-bigclip.json.check
|
||||||
cmp tests/pbf/countries-8-135-86-bigclip.json.check tests/pbf/countries-8-135-86-bigclip.json
|
cmp tests/pbf/countries-8-135-86-bigclip.json.check tests/pbf/countries-8-135-86-bigclip.json
|
||||||
rm tests/pbf/countries-8-135-86-bigclip.pbf tests/pbf/countries-8-135-86-bigclip.json.check
|
rm tests/pbf/countries-8-135-86-bigclip.pbf tests/pbf/countries-8-135-86-bigclip.json.check
|
||||||
|
# Clip region that does not intersect with the tile
|
||||||
|
./tippecanoe-overzoom -o tests/pbf/squirrels-13-2413-3077-clip.pbf --clip-polygon-file tests/pbf/squirrels-clip.json tests/pbf/squirrels-13-2413-3077.pbf 13/2413/3077 13/2413/3077
|
||||||
|
cmp tests/pbf/squirrels-13-2413-3077-clip.pbf /dev/null # clipped away
|
||||||
|
rm tests/pbf/squirrels-13-2413-3077-clip.pbf
|
||||||
|
|
||||||
join-test: tippecanoe tippecanoe-decode tile-join
|
join-test: tippecanoe tippecanoe-decode tile-join
|
||||||
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
|
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
|
||||||
|
|||||||
+31
-21
@@ -294,6 +294,7 @@ int main(int argc, char **argv) {
|
|||||||
// clip the clip polygons, if any, to the tile bounds,
|
// clip the clip polygons, if any, to the tile bounds,
|
||||||
// to reduce their complexity
|
// to reduce their complexity
|
||||||
|
|
||||||
|
bool clipped_to_nothing = false;
|
||||||
if (clipbboxes.size() > 0) {
|
if (clipbboxes.size() > 0) {
|
||||||
long long wx1 = (nx - buffer / 256.0) * (1LL << (32 - nz));
|
long long wx1 = (nx - buffer / 256.0) * (1LL << (32 - nz));
|
||||||
long long wy1 = (ny - buffer / 256.0) * (1LL << (32 - nz));
|
long long wy1 = (ny - buffer / 256.0) * (1LL << (32 - nz));
|
||||||
@@ -315,38 +316,47 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (c.dv.size() > 0) {
|
if (c.dv.size() > 0) {
|
||||||
c.dv = clip_poly_poly(c.dv, tile_bounds);
|
c.dv = clip_poly_poly(c.dv, tile_bounds);
|
||||||
|
|
||||||
|
if (c.dv.size() == 0) {
|
||||||
|
clipped_to_nothing = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_filter = NULL;
|
std::string out;
|
||||||
if (filter.size() > 0) {
|
|
||||||
json_filter = parse_filter(filter.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const &s : sources) {
|
if (!clipped_to_nothing) {
|
||||||
std::string tile;
|
json_object *json_filter = NULL;
|
||||||
char buf[1000];
|
if (filter.size() > 0) {
|
||||||
int len;
|
json_filter = parse_filter(filter.c_str());
|
||||||
|
|
||||||
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) {
|
for (auto const &s : sources) {
|
||||||
tile.append(std::string(buf, len));
|
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));
|
||||||
}
|
}
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
input_tile t = s;
|
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);
|
||||||
t.tile = std::move(tile);
|
|
||||||
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, clipbboxes);
|
|
||||||
|
|
||||||
FILE *f = fopen(outfile, "wb");
|
FILE *f = fopen(outfile, "wb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
|
|||||||
+4
-2
@@ -11,6 +11,8 @@ size_t calc_memsize();
|
|||||||
|
|
||||||
size_t get_max_open_files();
|
size_t get_max_open_files();
|
||||||
|
|
||||||
constexpr const char *get_null_device() { return "/dev/null"; }
|
constexpr const char *get_null_device() {
|
||||||
|
return "/dev/null";
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PLATFORM_HPP
|
#endif // PLATFORM_HPP
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
{"coordinates":[[[-73.9722549,40.7904659],[-73.9755817,40.7674848],[-73.938783,40.767022],[-73.9457082,40.7791562],[-73.9628855,40.7760201],[-73.9629534,40.7914425],[-73.9722549,40.7904659]]],"crs":{"properties":{"name":"EPSG:4326"},"type":"name"},"type":"Polygon"}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#ifndef VERSION_HPP
|
#ifndef VERSION_HPP
|
||||||
#define VERSION_HPP
|
#define VERSION_HPP
|
||||||
|
|
||||||
#define VERSION "v2.72.0"
|
#define VERSION "v2.73.0"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user