diff --git a/CHANGELOG.md b/CHANGELOG.md index a3127866..1aff50eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.9.14 + +* Clean up polygons after coalescing, if necessary + ## 1.9.13 * Don't trust the OS so much about how many files can be open diff --git a/README.md b/README.md index 1a1d7954..60a4e122 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,9 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_. ### Doing more - * -ac or --coalesce: Coalesce adjacent line and polygon features that have the same properties + * -ac or --coalesce: Coalesce adjacent line and polygon features that have the same properties. + Note that when overlapping polygons are coalesced, the overlapping region is treated as a hole, + which may not be what you want. * -ar or --reverse: Try reversing the directions of lines to make them coalesce and compress better * -ao or --reorder: Reorder features to put ones with the same properties in sequence, to try to get them to coalesce * -al or --drop-lines: Let "dot" dropping at lower zooms apply to lines too diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index 793e4900..8f54e9da 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -134,7 +134,9 @@ compensate for the larger marker, or \-rf\fInumber\fP to allow at most \fInumber .SS Doing more .RS .IP \(bu 2 -\-ac or \-\-coalesce: Coalesce adjacent line and polygon features that have the same properties +\-ac or \-\-coalesce: Coalesce adjacent line and polygon features that have the same properties. +Note that when overlapping polygons are coalesced, the overlapping region is treated as a hole, +which may not be what you want. .IP \(bu 2 \-ar or \-\-reverse: Try reversing the directions of lines to make them coalesce and compress better .IP \(bu 2 diff --git a/tests/overlap/in.json b/tests/overlap/in.json new file mode 100644 index 00000000..087e54c1 --- /dev/null +++ b/tests/overlap/in.json @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-81,63],[-113,53],[-135,29],[-118,-9],[-75,-31],[-17,-22],[-5,8],[-10,50],[-28,59],[-81,63]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-93,75],[-113,69],[-117,60],[-103,39],[-71,29],[-37,34],[-3,61],[-33,79],[-74,79],[-93,75]]]}}]} diff --git a/tests/overlap/out/-z0.json b/tests/overlap/out/-z0.json new file mode 100644 index 00000000..7e26c86b --- /dev/null +++ b/tests/overlap/out/-z0.json @@ -0,0 +1,20 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "-135.000000,-31.000000,-3.000000,79.000000", +"center": "-3.000000,0.000000,0", +"description": "tests/overlap/out/-z0.json.check.mbtiles", +"format": "pbf", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {} } ] }", +"maxzoom": "0", +"minzoom": "0", +"name": "tests/overlap/out/-z0.json.check.mbtiles", +"type": "overlay", +"version": "2" +}, "features": [ +{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ +{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -3.076172, 61.015725 ], [ -37.001953, 34.016242 ], [ -71.015625, 29.075375 ], [ -103.007812, 39.027719 ], [ -117.070312, 60.020952 ], [ -113.027344, 69.005675 ], [ -93.076172, 75.004940 ], [ -74.003906, 79.004962 ], [ -33.046875, 79.004962 ], [ -3.076172, 61.015725 ] ] ] } } +, +{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -28.037109, 59.040555 ], [ -10.019531, 50.007739 ], [ -5.009766, 8.059230 ], [ -17.050781, -21.943046 ], [ -75.058594, -30.977609 ], [ -118.037109, -8.928487 ], [ -135.000000, 29.075375 ], [ -113.027344, 53.014783 ], [ -81.035156, 63.035039 ], [ -28.037109, 59.040555 ] ] ] } } +] } +] } +] } diff --git a/tests/overlap/out/-z0_--coalesce.json b/tests/overlap/out/-z0_--coalesce.json new file mode 100644 index 00000000..7705b202 --- /dev/null +++ b/tests/overlap/out/-z0_--coalesce.json @@ -0,0 +1,18 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "-135.000000,-31.000000,-3.000000,79.000000", +"center": "-3.000000,0.000000,0", +"description": "tests/overlap/out/-z0_--coalesce.json.check.mbtiles", +"format": "pbf", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {} } ] }", +"maxzoom": "0", +"minzoom": "0", +"name": "tests/overlap/out/-z0_--coalesce.json.check.mbtiles", +"type": "overlay", +"version": "2" +}, "features": [ +{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ +{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -3.076172, 61.015725 ], [ -15.380859, 52.908902 ], [ -10.019531, 50.007739 ], [ -5.009766, 8.059230 ], [ -17.050781, -21.943046 ], [ -75.058594, -30.977609 ], [ -118.037109, -8.928487 ], [ -135.000000, 29.075375 ], [ -113.027344, 53.014783 ], [ -111.884766, 53.383328 ], [ -117.070312, 60.020952 ], [ -113.027344, 69.005675 ], [ -93.076172, 75.004940 ], [ -74.003906, 79.004962 ], [ -33.046875, 79.004962 ], [ -3.076172, 61.015725 ] ], [ [ -111.884766, 53.383328 ], [ -103.007812, 39.027719 ], [ -71.015625, 29.075375 ], [ -37.001953, 34.016242 ], [ -15.380859, 52.908902 ], [ -28.037109, 59.040555 ], [ -81.035156, 63.035039 ], [ -111.884766, 53.383328 ] ] ] } } +] } +] } +] } diff --git a/tile.cc b/tile.cc index 2db32019..c0bb0315 100644 --- a/tile.cc +++ b/tile.cc @@ -538,7 +538,6 @@ void *partial_feature_worker(void *v) { // Give Clipper a chance to try to fix it. for (size_t i = 0; i < geoms.size(); i++) { geoms[i] = clean_or_clip_poly(geoms[i], 0, 0, 0, false); - geoms[i] = close_poly(geoms[i]); } } @@ -950,6 +949,14 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s features[j][x].geom = simplify_lines(features[j][x].geom, 32, 0); } + if (features[j][x].type == VT_POLYGON) { + if (features[j][x].coalesced) { + features[j][x].geom = clean_or_clip_poly(features[j][x].geom, 0, 0, 0, false); + } + + features[j][x].geom = close_poly(features[j][x].geom); + } + if (features[j][x].geom.size() > 0) { out.push_back(features[j][x]); } diff --git a/version.h b/version.h index 06899da3..665a2632 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "tippecanoe v1.9.13\n" +#define VERSION "tippecanoe v1.9.14\n"