From 48b5db6ae53fed3851148a41946d506f92339b95 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 17 Dec 2014 16:01:33 -0800 Subject: [PATCH] Keep the progress indicator progressing while working through big tiles --- geojson.c | 5 +---- tile.cc | 8 +++++++- tile.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/geojson.c b/geojson.c index 11d1c33..eee23ac 100644 --- a/geojson.c +++ b/geojson.c @@ -255,10 +255,7 @@ void check(int geomfd[4], off_t geom_size[4], char *metabase, unsigned *file_bbo // fprintf(stderr, "%d/%u/%u\n", z, x, y); - fprintf(stderr, " %3.1f%% %d/%u/%u \r", - (((geom - geomstart + along) / (double) todo) + z) / (maxzoom + 1) * 100, z, x, y); - - long long len = write_tile(&geom, metabase, file_bbox, z, x, y, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb, droprate, buffer, fname, jp, sub, minzoom, maxzoom); + long long len = write_tile(&geom, metabase, file_bbox, z, x, y, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb, droprate, buffer, fname, jp, sub, minzoom, maxzoom, todo, geomstart, along); if (z == maxzoom && len > most) { *midx = x; diff --git a/tile.cc b/tile.cc index d8542ca..a7fcb97 100644 --- a/tile.cc +++ b/tile.cc @@ -342,9 +342,10 @@ void evaluate(std::vector &features, char *metabase, struct pool *file pool_free(&keys); } -long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom) { +long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along) { int line_detail; static bool evaluated = false; + double oprogress = 0; char *og = *geoms; @@ -384,6 +385,11 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u signed char feature_minzoom; deserialize_byte(geoms, &feature_minzoom); + double progress = floor((((*geoms - geomstart + along) / (double) todo) + z) / (file_maxzoom + 1) * 1000) / 10; + if (progress != oprogress) { + fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty); + } + int quick = quick_check(bbox, z, line_detail, buffer); if (quick == 0) { continue; diff --git a/tile.h b/tile.h index 9ac106e..6807f08 100644 --- a/tile.h +++ b/tile.h @@ -26,4 +26,4 @@ void deserialize_uint(char **f, unsigned *n); void deserialize_byte(char **f, signed char *n); struct pool_val *deserialize_string(char **f, struct pool *p, int type); -long long write_tile(char **geom, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom); +long long write_tile(char **geom, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along);