mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Split complex polygons into multiple features
This commit is contained in:
@@ -114,6 +114,7 @@ Options
|
|||||||
* -pk: Don't limit tiles to 500K bytes
|
* -pk: Don't limit tiles to 500K bytes
|
||||||
* -pd: 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.
|
* -pd: 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: 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).
|
* -pi: 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: Don't split complex polygons (over 700 vertices after simplification) into multiple features.
|
||||||
* -q: Work quietly instead of reporting progress
|
* -q: Work quietly instead of reporting progress
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@@ -202,6 +203,9 @@ have their probability diffused, so that some of them will be drawn as a square
|
|||||||
this minimum size and others will not be drawn at all, preserving the total area that
|
this minimum size and others will not be drawn at all, preserving the total area that
|
||||||
all of them should have had together.
|
all of them should have had together.
|
||||||
|
|
||||||
|
Any polygons that have over 700 vertices after line simplification will be split into
|
||||||
|
multiple features so they can be rendered efficiently, unless you use -pp to prevent this.
|
||||||
|
|
||||||
Features in the same tile that share the same type and attributes are coalesced
|
Features in the same tile that share the same type and attributes are coalesced
|
||||||
together into a single geometry. You are strongly encouraged to use -x to exclude
|
together into a single geometry. You are strongly encouraged to use -x to exclude
|
||||||
any unnecessary properties to reduce wasted file size.
|
any unnecessary properties to reduce wasted file size.
|
||||||
|
|||||||
+20
-5
@@ -436,7 +436,9 @@ static drawvec clip_poly1(drawvec &geom, long long minx, long long miny, long lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out.size() < 3) {
|
if (out.size() < 3) {
|
||||||
fprintf(stderr, "Polygon degenerated to a line segment\n");
|
// fprintf(stderr, "Polygon degenerated to a line segment\n");
|
||||||
|
out.clear();
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
out[0].op = VT_MOVETO;
|
out[0].op = VT_MOVETO;
|
||||||
@@ -943,16 +945,12 @@ drawvec fix_polygon(drawvec &geom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms) {
|
std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms) {
|
||||||
return geoms;
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bool again = false;
|
bool again = false;
|
||||||
std::vector<drawvec> out;
|
std::vector<drawvec> out;
|
||||||
|
|
||||||
for (unsigned i = 0; i < geoms.size(); i++) {
|
for (unsigned i = 0; i < geoms.size(); i++) {
|
||||||
if (geoms[i].size() > 700) {
|
if (geoms[i].size() > 700) {
|
||||||
again = true;
|
|
||||||
|
|
||||||
long long midx = 0, midy = 0, count = 0;
|
long long midx = 0, midy = 0, count = 0;
|
||||||
long long maxx = LONG_LONG_MIN, maxy = LONG_LONG_MIN, minx = LONG_LONG_MAX, miny = LONG_LONG_MAX;
|
long long maxx = LONG_LONG_MIN, maxy = LONG_LONG_MIN, minx = LONG_LONG_MAX, miny = LONG_LONG_MAX;
|
||||||
|
|
||||||
@@ -976,6 +974,23 @@ std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
midx /= count;
|
||||||
|
midy /= count;
|
||||||
|
|
||||||
|
if (maxy - miny > maxx - minx) {
|
||||||
|
// printf("clipping y to %lld %lld %lld %lld\n", minx, miny, maxx, midy);
|
||||||
|
out.push_back(simple_clip_poly(geoms[i], minx, miny, maxx, midy));
|
||||||
|
// printf(" and %lld %lld %lld %lld\n", minx, midy, maxx, maxy);
|
||||||
|
out.push_back(simple_clip_poly(geoms[i], minx, midy, maxx, maxy));
|
||||||
|
} else {
|
||||||
|
// printf("clipping x to %lld %lld %lld %lld\n", minx, miny, midx, maxy);
|
||||||
|
out.push_back(simple_clip_poly(geoms[i], minx, miny, midx, maxy));
|
||||||
|
// printf(" and %lld %lld %lld %lld\n", midx, midy, maxx, maxy);
|
||||||
|
out.push_back(simple_clip_poly(geoms[i], midx, miny, maxx, maxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
again = true;
|
||||||
} else {
|
} else {
|
||||||
out.push_back(geoms[i]);
|
out.push_back(geoms[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,3 +29,4 @@ int quick_check(long long *bbox, int z, int detail, long long buffer);
|
|||||||
drawvec simplify_lines(drawvec &geom, int z, int detail);
|
drawvec simplify_lines(drawvec &geom, int z, int detail);
|
||||||
drawvec reorder_lines(drawvec &geom);
|
drawvec reorder_lines(drawvec &geom);
|
||||||
drawvec fix_polygon(drawvec &geom);
|
drawvec fix_polygon(drawvec &geom);
|
||||||
|
std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ features. This is a tool for making maps from huge datasets
|
|||||||
.PP
|
.PP
|
||||||
[Build Status](https://travis\-ci.org/mapbox/tippecanoe.svg)
|
[Build Status](https://travis\-ci.org/mapbox/tippecanoe.svg)
|
||||||
\[la]https://travis-ci.org/mapbox/tippecanoe\[ra]
|
\[la]https://travis-ci.org/mapbox/tippecanoe\[ra]
|
||||||
|
[Coverage Status](https://coveralls.io/repos/mapbox/tippecanoe/badge.svg?branch=master&service=github)
|
||||||
|
\[la]https://coveralls.io/github/mapbox/tippecanoe?branch=master\[ra]
|
||||||
.SH Intent
|
.SH Intent
|
||||||
.PP
|
.PP
|
||||||
The goal of Tippecanoe is to enable making a scale\-independent view of your data,
|
The goal of Tippecanoe is to enable making a scale\-independent view of your data,
|
||||||
@@ -143,6 +145,8 @@ If you use \-rg, it will guess a drop rate that will keep at most 50,000 feature
|
|||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-pi: 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).
|
\-pi: 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).
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
|
\-pp: Don't split complex polygons (over 700 vertices after simplification) into multiple features.
|
||||||
|
.IP \(bu 2
|
||||||
\-q: Work quietly instead of reporting progress
|
\-q: Work quietly instead of reporting progress
|
||||||
.RE
|
.RE
|
||||||
.SH Example
|
.SH Example
|
||||||
@@ -232,6 +236,9 @@ have their probability diffused, so that some of them will be drawn as a square
|
|||||||
this minimum size and others will not be drawn at all, preserving the total area that
|
this minimum size and others will not be drawn at all, preserving the total area that
|
||||||
all of them should have had together.
|
all of them should have had together.
|
||||||
.PP
|
.PP
|
||||||
|
Any polygons that have over 700 vertices after line simplification will be split into
|
||||||
|
multiple features so they can be rendered efficiently, unless you use \-pp to prevent this.
|
||||||
|
.PP
|
||||||
Features in the same tile that share the same type and attributes are coalesced
|
Features in the same tile that share the same type and attributes are coalesced
|
||||||
together into a single geometry. You are strongly encouraged to use \-x to exclude
|
together into a single geometry. You are strongly encouraged to use \-x to exclude
|
||||||
any unnecessary properties to reduce wasted file size.
|
any unnecessary properties to reduce wasted file size.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -529,11 +529,9 @@ void *partial_feature_worker(void *v) {
|
|||||||
std::vector<drawvec> geoms;
|
std::vector<drawvec> geoms;
|
||||||
geoms.push_back(geom);
|
geoms.push_back(geom);
|
||||||
|
|
||||||
#if 0
|
if (t == VT_POLYGON && !prevent[P_POLYGON_SPLIT]) {
|
||||||
if (t == VT_POLYGON) {
|
geoms = chop_polygon(geoms);
|
||||||
geoms = chop_geometry(geoms); // XXX
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (t == VT_POLYGON) {
|
if (t == VT_POLYGON) {
|
||||||
// Scaling may have made the polygon degenerate.
|
// Scaling may have made the polygon degenerate.
|
||||||
|
|||||||
Reference in New Issue
Block a user