Skip to content

Commit

Permalink
Merge pull request #206 from mapbox/chatty-polygon
Browse files Browse the repository at this point in the history
Add an option to drop a fraction of polygons by zoom.
  • Loading branch information
e-n-f committed Apr 6, 2016
2 parents d1456c0 + 574a2b7 commit 22ede9a
Show file tree
Hide file tree
Showing 9 changed files with 2,587 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.9.9

* Add --drop-polygons to drop a fraction of polygons by zoom level
* Only complain once about failing to clean polygons

## 1.9.8

* Use an on-disk radix sort for the index to control virtual memory thrashing
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_.
* -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
* -ap or --drop-polygons: Let "dot" dropping at lower zooms apply to polygons too

### Doing less

Expand Down
1 change: 1 addition & 0 deletions geojson.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,7 @@ int main(int argc, char **argv) {
{"reverse", no_argument, &additional[A_REVERSE], 1},
{"reorder", no_argument, &additional[A_REORDER], 1},
{"drop-lines", no_argument, &additional[A_LINE_DROP], 1},
{"drop-polygons", no_argument, &additional[A_POLYGON_DROP], 1},
{"prefer-radix-sort", no_argument, &additional[A_PREFER_RADIX_SORT], 1},

{"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1},
Expand Down
7 changes: 6 additions & 1 deletion geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl
}

if (!clipper.Execute(ClipperLib::ctUnion, clipped)) {
fprintf(stderr, "Polygon clean failed\n");
static bool complained = false;

if (!complained) {
fprintf(stderr, "Polygon clean failed\n");
complained = true;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions man/tippecanoe.1
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ compensate for the larger marker, or \-rf\fInumber\fP to allow at most \fInumber
\-ao or \-\-reorder: Reorder features to put ones with the same properties in sequence, to try to get them to coalesce
.IP \(bu 2
\-al or \-\-drop\-lines: Let "dot" dropping at lower zooms apply to lines too
.IP \(bu 2
\-ap or \-\-drop\-polygons: Let "dot" dropping at lower zooms apply to polygons too
.RE
.SS Doing less
.RS
Expand Down
2,566 changes: 2,566 additions & 0 deletions tests/ne_110m_admin_0_countries/out/-z4_-yname_--drop-polygons.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion tile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,9 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi
continue;
}

if (gamma >= 0 && (t == VT_POINT || (additional[A_LINE_DROP] && t == VT_LINE))) {
if (gamma >= 0 && (t == VT_POINT ||
(additional[A_LINE_DROP] && t == VT_LINE) ||
(additional[A_POLYGON_DROP] && t == VT_POLYGON))) {
seq++;
if (seq >= 0) {
seq -= interval;
Expand Down
2 changes: 2 additions & 0 deletions tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static int additional_options[] = {
A_REORDER,
#define A_LINE_DROP ((int) 'l')
A_LINE_DROP,
#define A_POLYGON_DROP ((int) 'p')
A_POLYGON_DROP,
#define A_PREFER_RADIX_SORT ((int) 'r')
A_PREFER_RADIX_SORT,
};
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION "tippecanoe v1.9.8\n"
#define VERSION "tippecanoe v1.9.9\n"

0 comments on commit 22ede9a

Please sign in to comment.