Add an option to adjust the -rp drop rate

This commit is contained in:
Erica Fischer
2022-12-14 12:45:38 -08:00
parent 7f93cd2e40
commit bd1f6a0939
4 changed files with 21 additions and 3 deletions
+1
View File
@@ -2,6 +2,7 @@
* Make as-needed dropping and coalescing much faster: Don't keep scanning through the whole layer looking for another small feature.
* Don't guess an excessively large maxzoom when there is only one feature
* Add an option to adjust the -rp drop rate
## 2.15.2
+2 -1
View File
@@ -448,7 +448,8 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
You can also specify a marker-width with `-rg`*width* to allow fewer features in the densest tile to
compensate for the larger marker, or `-rf`*number* to allow at most *number* features in the densest tile.
If you use `-rp` with `-zg` or `--smallest-maximum-zoom-guess` it will choose a drop rate from the same
distance-between-features metrics as are used to choose the maxzoom.
distance-between-features metrics as are used to choose the maxzoom. If you use `-rp`*multiplier* it will keep
*multiplier* times as many points in zoom level 0 as it would normally choose.
* `-B` _zoom_ or `--base-zoom=`_zoom_: Base zoom, the level at and above which all points are included in the tiles (default maxzoom).
If you use `-Bg`, it will guess a zoom level that will keep at most 50,000 features in the densest tile.
You can also specify a marker-width with `-Bg`*width* to allow fewer features in the densest tile to
+16 -1
View File
@@ -86,6 +86,7 @@ std::string attribute_for_id = "";
size_t limit_tile_feature_count = 0;
size_t limit_tile_feature_count_at_maxzoom = 0;
unsigned int drop_denser = 0;
double drop_rate_multiplier = 1;
std::vector<order_field> order_by;
bool order_reverse;
@@ -2165,6 +2166,12 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
if (!quiet) {
fprintf(stderr, "Choosing a drop rate of %f\n", droprate);
}
droprate /= exp(log(drop_rate_multiplier) / maxzoom);
if (drop_rate_multiplier != 1 && !quiet) {
fprintf(stderr, "Adjusting drop rate to %f with multiplier\n", droprate);
}
}
}
@@ -3185,8 +3192,16 @@ int main(int argc, char **argv) {
case 'r':
if (strcmp(optarg, "g") == 0) {
droprate = -2;
} else if (strcmp(optarg, "p") == 0) {
} else if (optarg[0] == 'p') {
droprate = -3;
if (optarg[1] != '\0') {
drop_rate_multiplier = atof_require(optarg + 1, "Drop rate multiplier");
if (drop_rate_multiplier <= 0) {
fprintf(stderr, "%s: Must specify positive multiplier >0 with -r%c\n", argv[0], optarg[0]);
exit(EXIT_ARGS);
}
}
} else if (optarg[0] == 'g' || optarg[0] == 'f') {
droprate = -2;
if (optarg[0] == 'g') {
+2 -1
View File
@@ -560,7 +560,8 @@ If you use \fB\fC\-rg\fR, it will guess a drop rate that will keep at most 50,00
You can also specify a marker\-width with \fB\fC\-rg\fR\fIwidth\fP to allow fewer features in the densest tile to
compensate for the larger marker, or \fB\fC\-rf\fR\fInumber\fP to allow at most \fInumber\fP features in the densest tile.
If you use \fB\fC\-rp\fR with \fB\fC\-zg\fR or \fB\fC\-\-smallest\-maximum\-zoom\-guess\fR it will choose a drop rate from the same
distance\-between\-features metrics as are used to choose the maxzoom.
distance\-between\-features metrics as are used to choose the maxzoom. If you use \fB\fC\-rp\fR\fImultiplier\fP it will keep
\fImultiplier\fP times as many points in zoom level 0 as it would normally choose.
.IP \(bu 2
\fB\fC\-B\fR \fIzoom\fP or \fB\fC\-\-base\-zoom=\fR\fIzoom\fP: Base zoom, the level at and above which all points are included in the tiles (default maxzoom).
If you use \fB\fC\-Bg\fR, it will guess a zoom level that will keep at most 50,000 features in the densest tile.