change progressmeter to output at node processing - osm-zipcodes - Extract (dutch) addresses from OpenStreetMap OSM XML
(HTM) git clone git://git.codemadness.org/osm-zipcodes
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 918d881b3982b6ceb90ee1eaaa3a1f7c11addb4c
(DIR) parent 9a7c2c6438bef350d21b2c26141cad89b8976c6a
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 11 Apr 2019 18:04:47 +0200
change progressmeter to output at node processing
Diffstat:
M main.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/main.c b/main.c
@@ -126,9 +126,15 @@ xmltagstart(XMLParser *x, const char *t, size_t tl)
void
xmltagend(XMLParser *x, const char *t, size_t tl, int isshort)
{
+ static size_t nodecount;
+
if (isnode && tl == 4 && t[0] == 'n' && t[1] == 'o' && t[2] == 'd' && t[3] == 'e') {
printaddress();
+ /* progress meter */
+ if ((nodecount++ % 100000) == 0)
+ fprintf(stderr, "\rProgress: %.2f%%", ((float)off / (float)len) * 100.0);
+
isnode = 0;
fieldtype = 0; /* reset fieldtype */
na.id[0] = '\0';
@@ -227,10 +233,6 @@ getnext(void)
{
if (off >= len)
return EOF;
- /* progress meter */
- if (off % (1048576*10) == 0)
- fprintf(stderr, "\rProgress: %.2f%%", ((float)off / (float)len) * 100.0);
-
return reg[off++];
}
@@ -262,6 +264,9 @@ main(int argc, char *argv[])
x.getnext = getnext;
xml_parse(&x);
+ /* progress meter */
+ fprintf(stderr, "\rProgress: %.2f%%\n", 100.0);
+
munmap(reg, len);
close(fd);