From: Kaj-Michael Lang Date: Sat, 21 Jul 2007 17:52:24 +0000 (+0300) Subject: Handle "noexit" tag X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a562ac4b09d89ef9a9ab2f8896a7eef430a7fc;p=mapper Handle "noexit" tag Small fixups here and there. --- diff --git a/src/osm.c b/src/osm.c index 4703187..3bbab09 100644 --- a/src/osm.c +++ b/src/osm.c @@ -845,6 +845,8 @@ switch (t) { cway->data->int_ref=g_strdup(v); else if (strcasecmp(k, "oneway")==0) cway->flags|=W_ONEWAY; + else if (strcasecmp(k, "noexit")==0) + cway->flags|=W_NOEXIT; else if (strcasecmp(k, "layer")==0) cway->data->layer=atoi(v); else if ((strcasecmp(k, "junction")==0) && (strcasecmp(v, "roundabout")==0)) { @@ -866,6 +868,10 @@ switch (t) { break; } } + } else { +#ifdef VERBOSE_UNHANDLED_WAY_TAGS + g_printf("Unhandled tag: [%s == %s]\n", k, v); +#endif } } @@ -914,10 +920,15 @@ switch (t) { g_printf("Segments: %d\n", seg_cnt); } break; + case IN_OSM_TAG: + g_printf("Planet loaded.\n"); + break; default:; } } +/************************************************************************/ + gint osm_planet_parse_file(gchar *pfile) { int f, r, res; @@ -948,7 +959,9 @@ close(f); return res; } -inline gint +/************************************************************************/ + +static gint print_fail(const gchar *msg, gint ret) { g_printf("ERROR: %s\n", msg); @@ -957,13 +970,33 @@ return ret; /************************************************************************/ -int main (int argc, char **argv) +static void +print_memory_usage(void) { - +g_print("Memory usage:\n"); g_printf("Node size: %d\n", sizeof(node)); g_printf("Seg size: %d\n", sizeof(segment)); g_printf("Way size: %d\n", sizeof(way)); +} + +static void +storage_init(void) +{ +osm_nodes=g_hash_table_new(g_direct_hash, g_direct_equal); +osm_segments=g_hash_table_new(g_direct_hash, g_direct_equal); +} + +static void +storage_free(void) +{ +g_hash_table_unref(osm_nodes); +g_hash_table_unref(osm_segments); +} + +/************************************************************************/ +int main (int argc, char **argv) +{ if (argc!=2) { return print_fail("No planet XML file given", 1); } else { @@ -974,8 +1007,9 @@ if (db_open()!=TRUE) return print_fail("Database open failed", 2); db_prepare(); -osm_nodes=g_hash_table_new(g_direct_hash, g_direct_equal); -osm_segments=g_hash_table_new(g_direct_hash, g_direct_equal); +print_memory_usage(); + +storage_init(); osm_planet_parse_file(argv[1]); @@ -984,8 +1018,7 @@ g_printf("Planet loaded.\nTotal nodes %d, POIs: %d, Segments %d and Ways %d.\n", osm_planet_save_to_db(); -g_hash_table_unref(osm_nodes); -g_hash_table_unref(osm_segments); +storage_free(); sqlite3_close(db); sync();