From b7a411769a81664cda541a923b734bdbf227a792 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 16 Dec 2015 12:33:07 -0800 Subject: [PATCH] Don't allow <0 gamma (randomized) if basezoom or droprate not known --- geojson.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/geojson.c b/geojson.c index 0750fcf..2138a6e 100644 --- a/geojson.c +++ b/geojson.c @@ -1122,7 +1122,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max if (droprate < 0) { droprate = 1; - for (z = 0; z <= basezoom; z++) { + for (z = basezoom; z >= 0; z--) { double interval = exp(log(droprate) * (basezoom - z)); if (max[z].count / interval >= MAX_FEATURES) { @@ -1468,6 +1468,13 @@ int main(int argc, char **argv) { geometry_scale = 32 - (full_detail + maxzoom); + if ((basezoom < 0 || droprate < 0) && (gamma < 0)) { + // Can't use randomized (as opposed to evenly distributed) dot dropping + // if rate and base aren't known during feature reading. + gamma = 0; + fprintf(stderr, "Forcing -g0 since -B or -r is not known\n"); + } + if (outdir == NULL) { fprintf(stderr, "%s: must specify -o out.mbtiles\n", argv[0]); exit(EXIT_FAILURE);