Merge pull request #213 from mapbox/polygon-coalesce

Clean up polygon geometry again after coalescing
This commit is contained in:
Eric Fischer 2016-04-18 16:15:13 -07:00
commit 694fa8ee97
8 changed files with 58 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

1
tests/overlap/in.json Normal file
View File

@ -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]]]}}]}

View File

@ -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 ] ] ] } }
] }
] }
] }

View File

@ -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 ] ] ] } }
] }
] }
] }

View File

@ -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]);
}

View File

@ -1 +1 @@
#define VERSION "tippecanoe v1.9.13\n"
#define VERSION "tippecanoe v1.9.14\n"