mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-23 04:15:15 +00:00
Add an option not to clip features if they appear in the tile at all
This commit is contained in:
parent
694fa8ee97
commit
24f401da52
@ -1,3 +1,7 @@
|
||||
## 1.9.15
|
||||
|
||||
* Add option not to clip features
|
||||
|
||||
## 1.9.14
|
||||
|
||||
* Clean up polygons after coalescing, if necessary
|
||||
|
@ -128,6 +128,7 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_.
|
||||
* -pd or --force-feature-limit: Dynamically drop some fraction of features from large tiles to keep them under the 500K size limit. It will probably look ugly at the tile boundaries.
|
||||
* -pi or --preserve-input-order: Preserve the original input order of features as the drawing order instead of ordering geographically. (This is implemented as a restoration of the original order at the end, so that dot-dropping is still geographic, which means it also undoes -ao).
|
||||
* -pp or --no-polygon-splitting: Don't split complex polygons (over 700 vertices after simplification) into multiple features.
|
||||
* -pc or --no-clipping: Don't clip features to the size of the tile. If a feature overlaps the tile's bounds or buffer at all, it is included completely. Be careful: this can produce very large tilesets, especially with large polygons.
|
||||
* -q or --quiet: Work quietly instead of reporting progress
|
||||
|
||||
Example
|
||||
|
29
geojson.c
29
geojson.c
@ -2512,6 +2512,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"output", required_argument, 0, 'o'},
|
||||
|
||||
{"name", required_argument, 0, 'n'},
|
||||
{"layer", required_argument, 0, 'l'},
|
||||
{"attribution", required_argument, 0, 'A'},
|
||||
@ -2522,7 +2524,6 @@ int main(int argc, char **argv) {
|
||||
{"full-detail", required_argument, 0, 'd'},
|
||||
{"low-detail", required_argument, 0, 'D'},
|
||||
{"minimum-detail", required_argument, 0, 'm'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"exclude", required_argument, 0, 'x'},
|
||||
{"include", required_argument, 0, 'y'},
|
||||
{"drop-rate", required_argument, 0, 'r'},
|
||||
@ -2553,6 +2554,7 @@ int main(int argc, char **argv) {
|
||||
{"force-feature-limit", no_argument, &prevent[P_DYNAMIC_DROP], 1},
|
||||
{"preseve-input-order", no_argument, &prevent[P_INPUT_ORDER], 1},
|
||||
{"no-polygon-splitting", no_argument, &prevent[P_POLYGON_SPLIT], 1},
|
||||
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
|
||||
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
@ -2736,8 +2738,29 @@ int main(int argc, char **argv) {
|
||||
read_parallel = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l source] [-z maxzoom] [-Z minzoom] [-B basezoom] [-d detail] [-D lower-detail] [-m min-detail] [-x excluded-field ...] [-y included-field ...] [-X] [-r droprate] [-b buffer] [-t tmpdir] [-a rco] [-p sfkld] [-q] [-P] [file.json ...]\n", argv[0]);
|
||||
default: {
|
||||
int width = 7 + strlen(argv[0]);
|
||||
fprintf(stderr, "Usage: %s", argv[0]);
|
||||
int i;
|
||||
for (i = 0; long_options[i].name != NULL; i++) {
|
||||
if (width + strlen(long_options[i].name) + 9 >= 80) {
|
||||
fprintf(stderr, "\n ");
|
||||
width = 8;
|
||||
}
|
||||
width += strlen(long_options[i].name) + 9;
|
||||
if (strcmp(long_options[i].name, "output") == 0) {
|
||||
fprintf(stderr, " --%s=output.mbtiles", long_options[i].name);
|
||||
width += 9;
|
||||
} else if (long_options[i].has_arg) {
|
||||
fprintf(stderr, " [--%s=...]", long_options[i].name);
|
||||
} else {
|
||||
fprintf(stderr, " [--%s]", long_options[i].name);
|
||||
}
|
||||
}
|
||||
if (width + 16 >= 80) {
|
||||
fprintf(stderr, " [file.json ...]");
|
||||
}
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +163,8 @@ which may not be what you want.
|
||||
.IP \(bu 2
|
||||
\-pp or \-\-no\-polygon\-splitting: Don't split complex polygons (over 700 vertices after simplification) into multiple features.
|
||||
.IP \(bu 2
|
||||
\-pc or \-\-no\-clipping: Don't clip features to the size of the tile. If a feature overlaps the tile's bounds or buffer at all, it is included completely. Be careful: this can produce very large tilesets, especially with large polygons.
|
||||
.IP \(bu 2
|
||||
\-q or \-\-quiet: Work quietly instead of reporting progress
|
||||
.RE
|
||||
.SH Example
|
||||
|
1
tests/curve/in.json
Normal file
1
tests/curve/in.json
Normal file
@ -0,0 +1 @@
|
||||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-99,83],[-117,71],[-118,26],[-97,-38],[-75,-66],[-33,-77],[93,-79],[145,-77],[145,-74],[90,-74],[-28,-73],[-63,-63],[-82,-33],[-103,32],[-106,70],[-82,82],[-99,83]]]}}]}
|
36
tests/curve/out/-z1.json
Normal file
36
tests/curve/out/-z1.json
Normal file
@ -0,0 +1,36 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-118.000000,-79.000000,145.000000,83.000000",
|
||||
"center": "-90.000000,-42.525564,1",
|
||||
"description": "tests/curve/out/-z1.json.check.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 1, \"fields\": {} } ] }",
|
||||
"maxzoom": "1",
|
||||
"minzoom": "0",
|
||||
"name": "tests/curve/out/-z1.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": [ [ [ -82.001953, 82.009169 ], [ -106.083984, 70.020587 ], [ -103.007812, 32.026706 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 90.000000, -73.995328 ], [ 144.931641, -73.995328 ], [ 144.931641, -76.999935 ], [ 92.988281, -78.988187 ], [ -33.046875, -76.999935 ], [ -75.058594, -65.982270 ], [ -97.031250, -37.996163 ], [ -118.037109, 26.037042 ], [ -117.070312, 71.016960 ], [ -99.052734, 83.004844 ], [ -82.001953, 82.009169 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 1 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -92.680664, 0.000000 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 0.000000, -73.239377 ], [ 3.515625, -73.264704 ], [ 3.515625, -77.608282 ], [ 0.000000, -77.551572 ], [ -33.002930, -76.999935 ], [ -75.014648, -65.982270 ], [ -97.031250, -37.996163 ], [ -109.731445, 0.000000 ], [ -110.830078, 3.513421 ], [ -93.779297, 3.513421 ], [ -92.680664, 0.000000 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -82.001953, 82.003058 ], [ -106.040039, 70.005567 ], [ -103.007812, 32.026706 ], [ -92.680664, 0.000000 ], [ -91.625977, -3.513421 ], [ -108.632812, -3.513421 ], [ -109.731445, 0.000000 ], [ -118.037109, 26.037042 ], [ -117.026367, 71.002660 ], [ -99.008789, 83.004844 ], [ -82.001953, 82.003058 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 1 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, -73.239377 ], [ 90.000000, -73.995328 ], [ 144.975586, -73.995328 ], [ 144.975586, -76.999935 ], [ 92.988281, -78.996578 ], [ 0.000000, -77.551572 ], [ -3.515625, -77.494607 ], [ -3.515625, -73.201317 ], [ 0.000000, -73.239377 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
] }
|
36
tests/curve/out/-z1_--no-clipping.json
Normal file
36
tests/curve/out/-z1_--no-clipping.json
Normal file
@ -0,0 +1,36 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-118.000000,-79.000000,145.000000,83.000000",
|
||||
"center": "-90.000000,-42.525564,1",
|
||||
"description": "tests/curve/out/-z1_--no-clipping.json.check.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 1, \"fields\": {} } ] }",
|
||||
"maxzoom": "1",
|
||||
"minzoom": "0",
|
||||
"name": "tests/curve/out/-z1_--no-clipping.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": [ [ [ -82.001953, 82.009169 ], [ -106.083984, 70.020587 ], [ -103.007812, 32.026706 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 90.000000, -73.995328 ], [ 144.931641, -73.995328 ], [ 144.931641, -76.999935 ], [ 92.988281, -78.988187 ], [ -33.046875, -76.999935 ], [ -75.058594, -65.982270 ], [ -97.031250, -37.996163 ], [ -118.037109, 26.037042 ], [ -117.070312, 71.016960 ], [ -99.052734, 83.004844 ], [ -82.001953, 82.009169 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 1 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -82.001953, 82.003058 ], [ -106.040039, 70.005567 ], [ -103.007812, 32.026706 ], [ -92.680664, 0.000000 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 0.000000, -73.239377 ], [ 90.000000, -73.995328 ], [ 144.975586, -73.995328 ], [ 144.975586, -76.999935 ], [ 92.988281, -78.996578 ], [ 0.000000, -77.551572 ], [ -33.002930, -76.999935 ], [ -75.014648, -65.982270 ], [ -97.031250, -37.996163 ], [ -109.731445, 0.000000 ], [ -118.037109, 26.037042 ], [ -117.026367, 71.002660 ], [ -99.008789, 83.004844 ], [ -82.001953, 82.003058 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -82.001953, 82.003058 ], [ -106.040039, 70.005567 ], [ -103.007812, 32.026706 ], [ -92.680664, 0.000000 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 90.000000, -73.995328 ], [ 144.975586, -73.995328 ], [ 144.975586, -76.999935 ], [ 92.988281, -78.996578 ], [ -33.002930, -76.999935 ], [ -75.014648, -65.982270 ], [ -97.031250, -37.996163 ], [ -109.731445, 0.000000 ], [ -118.037109, 26.037042 ], [ -117.026367, 71.002660 ], [ -99.008789, 83.004844 ], [ -82.001953, 82.003058 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 1 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -82.001953, 82.003058 ], [ -106.040039, 70.005567 ], [ -103.007812, 32.026706 ], [ -82.001953, -32.990236 ], [ -63.017578, -62.995158 ], [ -28.037109, -72.996909 ], [ 0.000000, -73.239377 ], [ 90.000000, -73.995328 ], [ 144.975586, -73.995328 ], [ 144.975586, -76.999935 ], [ 92.988281, -78.996578 ], [ 0.000000, -77.551572 ], [ -33.002930, -76.999935 ], [ -75.014648, -65.982270 ], [ -97.031250, -37.996163 ], [ -118.037109, 26.037042 ], [ -117.026367, 71.002660 ], [ -99.008789, 83.004844 ], [ -82.001953, 82.003058 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
] }
|
4102
tests/ne_110m_admin_0_countries/out/-z4_-yname_-pc.json
Normal file
4102
tests/ne_110m_admin_0_countries/out/-z4_-yname_-pc.json
Normal file
File diff suppressed because one or more lines are too long
27
tile.cc
27
tile.cc
@ -758,17 +758,36 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
}
|
||||
|
||||
if (quick != 1) {
|
||||
drawvec clipped;
|
||||
|
||||
// Do the clipping, even if we are going to include the whole feature,
|
||||
// so that we can know whether the feature itself, or only the feature's
|
||||
// bounding box, touches the tile.
|
||||
|
||||
if (t == VT_LINE) {
|
||||
geom = clip_lines(geom, z, line_detail, buffer);
|
||||
clipped = clip_lines(geom, z, line_detail, buffer);
|
||||
}
|
||||
if (t == VT_POLYGON) {
|
||||
geom = simple_clip_poly(geom, z, line_detail, buffer);
|
||||
clipped = simple_clip_poly(geom, z, line_detail, buffer);
|
||||
}
|
||||
if (t == VT_POINT) {
|
||||
geom = clip_point(geom, z, line_detail, buffer);
|
||||
clipped = clip_point(geom, z, line_detail, buffer);
|
||||
}
|
||||
|
||||
geom = remove_noop(geom, t, 0);
|
||||
clipped = remove_noop(clipped, t, 0);
|
||||
|
||||
// Must clip at z0 even if we don't want clipping, to handle features
|
||||
// that are duplicated across the date line
|
||||
|
||||
if (prevent[P_CLIPPING] && z != 0) {
|
||||
if (clipped.size() == 0) {
|
||||
geom.clear();
|
||||
} else {
|
||||
// geom is unchanged
|
||||
}
|
||||
} else {
|
||||
geom = clipped;
|
||||
}
|
||||
}
|
||||
|
||||
if (geom.size() > 0) {
|
||||
|
2
tile.h
2
tile.h
@ -71,4 +71,6 @@ static int prevent_options[] = {
|
||||
P_INPUT_ORDER,
|
||||
#define P_POLYGON_SPLIT ((int) 'p')
|
||||
P_POLYGON_SPLIT,
|
||||
#define P_CLIPPING ((int) 'c')
|
||||
P_CLIPPING,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user