Skip to content

Commit

Permalink
Round the drop rate a little for cross-platform test consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Nov 5, 2024
1 parent cd34f41 commit 048110c
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 159 deletions.
10 changes: 7 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,10 @@ int vertexcmp(const void *void1, const void *void2) {
return 0;
}

double round_droprate(double r) {
return std::round(r * 100000.0) / 100000.0;
}

std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, long long *file_bbox1, long long *file_bbox2, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, bool guess_cluster_maxzoom, std::unordered_map<std::string, int> const *attribute_types, const char *pgm, std::unordered_map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
int ret = EXIT_SUCCESS;

Expand Down Expand Up @@ -2406,7 +2410,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
// features is small, the drop rate should be large because the features are evenly
// spaced, and if the standard deviation is large, the drop rate can be small because
// the features are in clumps.
droprate = exp(-0.7681 * log(stddev) + 1.582);
droprate = round_droprate(exp(-0.7681 * log(stddev) + 1.582));

if (droprate < 0) {
droprate = 0;
Expand Down Expand Up @@ -2608,7 +2612,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
if (maxzoom == 0) {
droprate = 2.5;
} else {
droprate = exp(log((double) max[0].count / max[maxzoom].count) / (maxzoom));
droprate = round_droprate(exp(log((double) max[0].count / max[maxzoom].count) / (maxzoom)));
if (!quiet) {
fprintf(stderr, "Choosing a drop rate of -r%f to get from %lld to %lld in %d zooms\n", droprate, max[maxzoom].count, max[0].count, maxzoom);
}
Expand All @@ -2634,7 +2638,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i

if (max[z].count / interval >= max_features) {
interval = (double) max[z].count / max_features;
droprate = exp(log(interval) / (basezoom - z));
droprate = round_droprate(exp(log(interval) / (basezoom - z)));
interval = exp(log(droprate) * (basezoom - z));

if (!quiet) {
Expand Down
Loading

0 comments on commit 048110c

Please sign in to comment.