From 40f2f61d98bdd7093dc71044fe797395f2370c43 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 8 Jul 2016 15:49:59 -0700 Subject: [PATCH] Fix double-counted progress in the progress indicator --- CHANGELOG.md | 4 ++++ tile.cpp | 14 +++++++++++--- version.hpp | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8656d71e..e10745cc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.12.3 + +* Fix double-counted progress in the progress indicator + ## 1.12.2 * Add ability to specify a projection to tippecanoe-decode diff --git a/tile.cpp b/tile.cpp index b49de99bf..9e8da6ea3 100644 --- a/tile.cpp +++ b/tile.cpp @@ -559,7 +559,7 @@ int manage_gap(unsigned long long index, unsigned long long *previndex, double s return 0; } -long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, std::vector *layernames, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int minzoom, int maxzoom, double todo, volatile long long *along, double gamma, int nlayers, int child_shards, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, volatile int *running) { +long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, std::vector *layernames, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int minzoom, int maxzoom, double todo, volatile long long *along, long long alongminus, double gamma, int nlayers, int child_shards, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, volatile int *running) { int line_detail; double fraction = 1; @@ -686,7 +686,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s signed char feature_minzoom; deserialize_byte_io(geoms, &feature_minzoom, geompos_in); - double progress = floor((((*geompos_in + *along) / (double) todo) + z) / (maxzoom + 1) * 1000) / 10; + double progress = floor((((*geompos_in + *along - alongminus) / (double) todo) + z) / (maxzoom + 1) * 1000) / 10; if (progress >= oprogress + 0.1) { if (!quiet) { fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty); @@ -1049,6 +1049,14 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s totalsize += features[j].size(); } + double progress = floor((((*geompos_in + *along - alongminus) / (double) todo) + z) / (maxzoom + 1) * 1000) / 10; + if (progress >= oprogress + 0.1) { + if (!quiet) { + fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty); + } + oprogress = progress; + } + if (totalsize > 0) { if (totalsize > 200000 && !prevent[P_FEATURE_LIMIT]) { fprintf(stderr, "tile %d/%u/%u has %lld features, >200000 \n", z, tx, ty, totalsize); @@ -1174,7 +1182,7 @@ void *run_thread(void *vargs) { // fprintf(stderr, "%d/%u/%u\n", z, x, y); - long long len = write_tile(geom, &geompos, arg->metabase, arg->stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->basezoom, arg->layernames, arg->outdb, arg->droprate, arg->buffer, arg->fname, arg->geomfile, arg->minzoom, arg->maxzoom, arg->todo, arg->along, arg->gamma, arg->nlayers, arg->child_shards, arg->meta_off, arg->pool_off, arg->initial_x, arg->initial_y, arg->running); + long long len = write_tile(geom, &geompos, arg->metabase, arg->stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->basezoom, arg->layernames, arg->outdb, arg->droprate, arg->buffer, arg->fname, arg->geomfile, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->nlayers, arg->child_shards, arg->meta_off, arg->pool_off, arg->initial_x, arg->initial_y, arg->running); if (len < 0) { int *err = &arg->err; diff --git a/version.hpp b/version.hpp index e9ceef829..ca8a33ba2 100644 --- a/version.hpp +++ b/version.hpp @@ -1 +1 @@ -#define VERSION "tippecanoe v1.12.2\n" +#define VERSION "tippecanoe v1.12.3\n"