Add multiplier stripping from tippecanoe-overzoom to tile-join

This commit is contained in:
Erica Fischer
2024-02-16 10:06:01 -08:00
parent 3708b89bd3
commit 9942b8db55
3 changed files with 34 additions and 0 deletions
+3
View File
@@ -810,6 +810,9 @@ The options are:
* `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-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.
* `-pe` or `--empty-csv-columns-are-null`: Treat empty CSV columns as nulls rather than as empty strings.
* `-m`: If a tile was created with the `--retain-points-multiplier` option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless `-j` is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
* `--preserve-input-order`: Restore a set of filtered features to its original input order
* `--accumulate-attribute`: Behaves as in `tippecanoe` to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with `-j` are *not* accumulated onto the output feature.
### Setting or disabling tile size limits
+6
View File
@@ -1033,6 +1033,12 @@ The options are:
\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.
.IP \(bu 2
\fB\fC\-pe\fR or \fB\fC\-\-empty\-csv\-columns\-are\-null\fR: Treat empty CSV columns as nulls rather than as empty strings.
.IP \(bu 2
\fB\fC\-m\fR: If a tile was created with the \fB\fC\-\-retain\-points\-multiplier\fR option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless \fB\fC\-j\fR is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
.IP \(bu 2
\fB\fC\-\-preserve\-input\-order\fR: Restore a set of filtered features to its original input order
.IP \(bu 2
\fB\fC\-\-accumulate\-attribute\fR: Behaves as in \fB\fCtippecanoe\fR to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with \fB\fC\-j\fR are \fInot\fP accumulated onto the output feature.
.RE
.SS Setting or disabling tile size limits
.RS
+25
View File
@@ -55,6 +55,9 @@ int minzoom = 0;
std::map<std::string, std::string> renames;
bool exclude_all = false;
std::vector<std::string> unidecode_data;
bool preserve_input_order = false;
bool demultiply = false;
std::unordered_map<std::string, attribute_op> attribute_accum;
bool want_overzoom = false;
int buffer = 5;
@@ -73,6 +76,12 @@ struct stats {
};
void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &include, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile, json_object *filter) {
if (attribute_accum.size() > 0 || demultiply) {
message = overzoom(message, z, x, y, z, x, y,
-1 /* detail */, 128 /* buffer */, include, false /* compress */, NULL /* child tiles */,
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data);
}
mvt_tile tile;
int features_added = 0;
bool was_compressed;
@@ -735,6 +744,7 @@ struct arg {
std::set<std::string> *remove_layers = NULL;
int ifmatched = 0;
json_object *filter = NULL;
struct tileset_reader *readers = NULL;
};
@@ -1235,6 +1245,9 @@ int main(int argc, char **argv) {
{"tile-stats-attributes-limit", required_argument, 0, '~'},
{"tile-stats-sample-values-limit", required_argument, 0, '~'},
{"tile-stats-values-limit", required_argument, 0, '~'},
{"filter-points-multiplier", no_argument, 0, 'm'},
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"accumulate-attribute", required_argument, 0, 'E'},
{"unidecode-data", required_argument, 0, '~'},
{0, 0, 0, 0},
@@ -1402,6 +1415,18 @@ int main(int argc, char **argv) {
quiet = true;
break;
case 'm':
demultiply = true;
break;
case 'o' & 0x1F:
preserve_input_order = true;
break;
case 'E':
set_attribute_accum(attribute_accum, optarg, argv);
break;
case '~': {
const char *opt = long_options[option_index].name;
if (strcmp(opt, "tile-stats-attributes-limit") == 0) {