diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcaf19b..16b4b718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.27.8 + +* Add --accumulate-attribute to keep attributes of dropped, coalesced, + or clustered features +* Make sure numeric command line arguments are actually numbers +* Don't coalesce features whose non-string-pool attributes don't match + ## 1.27.7 * Add an option to produce only a single tile diff --git a/README.md b/README.md index 21cdd908..2a961878 100644 --- a/README.md +++ b/README.md @@ -180,11 +180,21 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_. * `-x` _name_ or `--exclude=`_name_: Exclude the named properties from all features * `-y` _name_ or `--include=`_name_: Include the named properties in all features, excluding all those not explicitly named * `-X` or `--exclude-all`: Exclude all properties and encode only geometries + +### Modifying feature attributes + * `-T`_attribute_`:`_type_ or `--attribute-type=`_attribute_`:`_type_: Coerce the named feature _attribute_ to be of the specified _type_. The _type_ may be `string`, `float`, `int`, or `bool`. If the type is `bool`, then original attributes of `0` (or, if numeric, `0.0`, etc.), `false`, `null`, or the empty string become `false`, and otherwise become `true`. If the type is `float` or `int` and the original attribute was non-numeric, it becomes `0`. If the type is `int` and the original attribute was floating-point, it is rounded to the nearest integer. + * `-E`_attribute_`:`_operation_ or `--accumulate-attribute=`_attribute_`:`_operation_: Preserve the named _attribute_ from features + that are dropped, coalesced-as-needed, or clustered. The _operation_ may be + `sum`, `product`, `mean`, `max`, `min`, `concat`, or `comma` + to specify how the named _attribute_ is accumulated onto the attribute of the same name in a feature that does survive. + +### Filtering features by attributes + * `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://www.mapbox.com/mapbox-gl-js/style-spec/#types-filter)) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer `"*"` apply to all layers. * `-J` *filter-file* or `--feature-filter-file`=*filter-file*: Like `-j`, but read the filter from a file. diff --git a/main.cpp b/main.cpp index e8665441..aeb2d90b 100644 --- a/main.cpp +++ b/main.cpp @@ -2271,12 +2271,16 @@ void set_attribute_accum(std::map &attribute_accum, c t = op_product; } else if (type == "mean") { t = op_mean; + } else if (type == "max") { + t = op_max; + } else if (type == "min") { + t = op_min; } else if (type == "concat") { t = op_concat; } else if (type == "comma") { t = op_comma; } else { - fprintf(stderr, "Attribute method (%s) must be sum, product, mean, concat, or comma\n", type.c_str()); + fprintf(stderr, "Attribute method (%s) must be sum, product, mean, max, min, concat, or comma\n", type.c_str()); exit(EXIT_FAILURE); } @@ -2367,8 +2371,12 @@ int main(int argc, char **argv) { {"exclude", required_argument, 0, 'x'}, {"include", required_argument, 0, 'y'}, {"exclude-all", no_argument, 0, 'X'}, + + {"Modifying feature attributes", 0, 0, 0}, {"attribute-type", required_argument, 0, 'T'}, {"accumulate-attribute", required_argument, 0, 'E'}, + + {"Filtering features by attributes", 0, 0, 0}, {"feature-filter-file", required_argument, 0, 'J'}, {"feature-filter", required_argument, 0, 'j'}, diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index 1b6a8907..dd0ac2da 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -201,6 +201,9 @@ resolution is obtained than by using a smaller \fImaxzoom\fP or \fIdetail\fP\&. \fB\fC\-y\fR \fIname\fP or \fB\fC\-\-include=\fR\fIname\fP: Include the named properties in all features, excluding all those not explicitly named .IP \(bu 2 \fB\fC\-X\fR or \fB\fC\-\-exclude\-all\fR: Exclude all properties and encode only geometries +.RE +.SS Modifying feature attributes +.RS .IP \(bu 2 \fB\fC\-T\fR\fIattribute\fP\fB\fC:\fR\fItype\fP or \fB\fC\-\-attribute\-type=\fR\fIattribute\fP\fB\fC:\fR\fItype\fP: Coerce the named feature \fIattribute\fP to be of the specified \fItype\fP\&. The \fItype\fP may be \fB\fCstring\fR, \fB\fCfloat\fR, \fB\fCint\fR, or \fB\fCbool\fR\&. @@ -208,6 +211,13 @@ If the type is \fB\fCbool\fR, then original attributes of \fB\fC0\fR (or, if num If the type is \fB\fCfloat\fR or \fB\fCint\fR and the original attribute was non\-numeric, it becomes \fB\fC0\fR\&. If the type is \fB\fCint\fR and the original attribute was floating\-point, it is rounded to the nearest integer. .IP \(bu 2 +\fB\fC\-E\fR\fIattribute\fP\fB\fC:\fR\fIoperation\fP or \fB\fC\-\-accumulate\-attribute=\fR\fIattribute\fP\fB\fC:\fR\fIoperation\fP: Preserve the named \fIattribute\fP from features +that are dropped, coalesced\-as\-needed, or clustered. The \fIoperation\fP may be \fB\fCsum\fR, \fB\fCproduct\fR, \fB\fCmean\fR, \fB\fCconcat\fR, or \fB\fCcomma\fR +to specify how the named \fIattribute\fP is accumulated onto the attribute of the same name in a feature that does survive. +.RE +.SS Filtering features by attributes +.RS +.IP \(bu 2 \fB\fC\-j\fR \fIfilter\fP or \fB\fC\-\-feature\-filter\fR=\fIfilter\fP: Check features against a per\-layer filter (as defined in the Mapbox GL Style Specification \[la]https://www.mapbox.com/mapbox-gl-js/style-spec/#types-filter\[ra]) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer \fB\fC"*"\fR apply to all layers. .IP \(bu 2 \fB\fC\-J\fR \fIfilter\-file\fP or \fB\fC\-\-feature\-filter\-file\fR=\fIfilter\-file\fP: Like \fB\fC\-j\fR, but read the filter from a file. diff --git a/tile.hpp b/tile.hpp index ba8e4b6f..b30b5969 100644 --- a/tile.hpp +++ b/tile.hpp @@ -13,6 +13,8 @@ enum attribute_op { op_mean, op_concat, op_comma, + op_max, + op_min, }; long long write_tile(char **geom, char *metabase, char *stringpool, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int min_detail, int basezoom, sqlite3 *outdb, const char *outdir, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma, int nlayers); diff --git a/version.hpp b/version.hpp index e32afae9..0761b3aa 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "tippecanoe v1.27.7\n" +#define VERSION "tippecanoe v1.27.8\n" #endif