From 93d0767829c9da99cb1fbc7f97f4cb7ec793b7e5 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 8 Jan 2016 11:31:10 -0800 Subject: [PATCH] Add an option to do line simplification only at zooms below maxzoom --- README.md | 1 + man/tippecanoe.1 | 2 ++ tile.cc | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8620c32..62140e1 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Options ### Doing less * -ps: Don't simplify lines + * -pS: Don't simplify lines at maxzoom (but do simplify at lower zooms) * -pf: Don't limit tiles to 200,000 features * -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. diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index f8a3798..765a740 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -130,6 +130,8 @@ If you use \-rg, it will guess a drop rate that will keep at most 50,000 feature .IP \(bu 2 \-ps: Don't simplify lines .IP \(bu 2 +\-pS: Don't simplify lines at maxzoom (but do simplify at lower zooms) +.IP \(bu 2 \-pf: Don't limit tiles to 200,000 features .IP \(bu 2 \-pk: Don't limit tiles to 500K bytes diff --git a/tile.cc b/tile.cc index 670435a..7cc613d 100644 --- a/tile.cc +++ b/tile.cc @@ -479,6 +479,7 @@ struct partial { int line_detail; char *prevent; char *additional; + int maxzoom; }; struct partial_arg { @@ -499,8 +500,9 @@ void *partial_feature_worker(void *v) { int line_detail = (*partials)[i].line_detail; char *prevent = (*partials)[i].prevent; char *additional = (*partials)[i].additional; + int maxzoom = (*partials)[i].maxzoom; - if ((t == VT_LINE || t == VT_POLYGON) && !prevent['s' & 0xFF]) { + if ((t == VT_LINE || t == VT_POLYGON) && !(prevent['s' & 0xFF] || (z == maxzoom && prevent['S' & 0xFF]))) { if (1 /* !reduced */) { // XXX why did this not simplify if reduced? if (t == VT_LINE) { geom = remove_noop(geom, t, 32 - z - line_detail); @@ -806,6 +808,7 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi p.line_detail = line_detail; p.prevent = prevent; p.additional = additional; + p.maxzoom = maxzoom; partials.push_back(p); } }