Skip to content

Commit

Permalink
Add an option to prevent tiny polygon reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Nov 21, 2016
1 parent dc9e68b commit e9aa8c1
Show file tree
Hide file tree
Showing 6 changed files with 4,040 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_.
* -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.
* -pD or --no-duplication: As with --no-clipping, each feature is included intact instead of cut to tile boundaries. In addition, it is included only in a single tile per zoom level rather than potentially in multiple copies. Clients of the tileset must check adjacent tiles (possibly some distance away) to ensure they have all features.
* -pt or --no-tiny-polygon-reduction: Don't combine the area of very small polygons into small squares that represent their combined area.
* -q or --quiet: Work quietly instead of reporting progress

Example
Expand Down Expand Up @@ -242,7 +243,8 @@ For line features, it drops any features that are too small to draw at all.
This still leaves the lower zooms too dark (and too dense for the 500K tile limit,
in some places), so I need to figure out an equitable way to throw features away.

Any polygons that are smaller than a minimum area (currently 4 square subpixels) will
Unless you specify `--no-tiny-polygon-reduction`,
any polygons that are smaller than a minimum area (currently 4 square subpixels) will
have their probability diffused, so that some of them will be drawn as a square of
this minimum size and others will not be drawn at all, preserving the total area that
all of them should have had together.
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,7 @@ int main(int argc, char **argv) {
{"no-polygon-splitting", no_argument, &prevent[P_POLYGON_SPLIT], 1},
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
{"no-duplication", no_argument, &prevent[P_DUPLICATION], 1},
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},

{0, 0, 0, 0},
};
Expand Down
5 changes: 4 additions & 1 deletion man/tippecanoe.1
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ which may not be what you want.
.IP \(bu 2
\-pD or \-\-no\-duplication: As with \-\-no\-clipping, each feature is included intact instead of cut to tile boundaries. In addition, it is included only in a single tile per zoom level rather than potentially in multiple copies. Clients of the tileset must check adjacent tiles (possibly some distance away) to ensure they have all features.
.IP \(bu 2
\-pt or \-\-no\-tiny\-polygon\-reduction: Don't combine the area of very small polygons into small squares that represent their combined area.
.IP \(bu 2
\-q or \-\-quiet: Work quietly instead of reporting progress
.RE
.SH Example
Expand Down Expand Up @@ -287,7 +289,8 @@ For line features, it drops any features that are too small to draw at all.
This still leaves the lower zooms too dark (and too dense for the 500K tile limit,
in some places), so I need to figure out an equitable way to throw features away.
.PP
Any polygons that are smaller than a minimum area (currently 4 square subpixels) will
Unless you specify \fB\fC\-\-no\-tiny\-polygon\-reduction\fR,
any polygons that are smaller than a minimum area (currently 4 square subpixels) will
have their probability diffused, so that some of them will be drawn as a square of
this minimum size and others will not be drawn at all, preserving the total area that
all of them should have had together.
Expand Down
1 change: 1 addition & 0 deletions options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define P_POLYGON_SPLIT ((int) 'p')
#define P_CLIPPING ((int) 'c')
#define P_DUPLICATION ((int) 'D')
#define P_TINY_POLYGON_REDUCTION ((int) 't')

extern int prevent[256];
extern int additional[256];
4,028 changes: 4,028 additions & 0 deletions tests/ne_110m_admin_0_countries/out/-z4_-yname_--no-tiny-polygon-reduction.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,9 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s

bool reduced = false;
if (t == VT_POLYGON) {
geom = reduce_tiny_poly(geom, z, line_detail, &reduced, &accum_area);
if (!prevent[P_TINY_POLYGON_REDUCTION]) {
geom = reduce_tiny_poly(geom, z, line_detail, &reduced, &accum_area);
}
has_polygons = true;
}

Expand Down

0 comments on commit e9aa8c1

Please sign in to comment.