From: Kaj-Michael Lang Date: Sat, 2 Feb 2008 09:59:16 +0000 (+0200) Subject: Add asserts. Remove too verbose messages. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa3c25da88239f017ac57f4ce4075c76b755ffd9;p=mapper Add asserts. Remove too verbose messages. --- diff --git a/src/osm.c b/src/osm.c index d1c4bc4..5ecb546 100644 --- a/src/osm.c +++ b/src/osm.c @@ -665,7 +665,6 @@ if (!w->data->name) way_names++; - sqlite3_bind_int(sql.insert_way_name, 1, w->id); sqlite3_bind_text(sql.insert_way_name, 2, w->data->name, -1, SQLITE_TRANSIENT); @@ -916,8 +915,10 @@ return (nlat > bbox.lat_min && nlat < bbox.lat_max && nlon > bbox.lon_min && nlo static void osm_new_node_data(node *n) { -if (n==NULL) return; -if (n->data!=NULL) return; +if (n==NULL) + return; +if (n->data!=NULL) + return; n->data=g_slice_new(node_data); n->data->name=NULL; n->data->url=NULL; @@ -981,8 +982,10 @@ return n; static void osm_new_way_data(way *w) { -if (w==NULL) return; -if (w->data!=NULL) return; +if (w==NULL) + return; +if (w->data!=NULL) + return; w->data=g_slice_new(way_data); w->data->name=NULL; @@ -997,6 +1000,7 @@ w->data->speed=0; void osm_free_way_data(way *w) { +g_assert(w); if (!w->data) return; if (w->data->name) @@ -1015,6 +1019,7 @@ osm_new_way(gint id) way *w; w=g_slice_new(way); +g_assert(w); w->id=id; w->nodes=NULL; w->type=WAY_UNWAYED; @@ -1029,6 +1034,7 @@ return w; static void osm_way_add_to_list(way *w) { +g_assert(w); osm_ways=g_slist_prepend(osm_ways, w); } @@ -1037,6 +1043,7 @@ osm_way_new_node(way *w, gint nid) { node *n; +g_assert(w); n=osm_find_node(nid); w->nodes=g_slist_prepend(w->nodes, n); w->ncnt++; @@ -1156,7 +1163,7 @@ node *n=(node *)value; dbnode_cnt++; db_insert_node(n); if (dbnode_cnt % 26214==0) - g_printf("Nodes: %f%%\n",((float)dbnode_cnt/(float)node_cnt)*100); + g_printf("\rNodes: %f%%\n",((float)dbnode_cnt/(float)node_cnt)*100); } /** @@ -1243,8 +1250,8 @@ osm_way_save(way *value, gpointer user_data) { dbway_cnt++; db_insert_way(value); -if (dbway_cnt % 8192==0 && dbway_cnt>0) { - g_printf("Ways: %f%%\n",(((float)dbway_cnt/(float)way_cnt)*100)); +if (dbway_cnt % 16384==0 && dbway_cnt>0) { + g_printf("\rWays: %f%%\n",(((float)dbway_cnt/(float)way_cnt)*100)); print_way(value); } } @@ -1482,12 +1489,10 @@ switch (t) { if (cnode->data->name) { switch (cnode->type) { case NODE_PLACE_COUNTRY: - g_printf("Country: [%s] (%d)\n", cnode->data->name, cnode->id); g_hash_table_insert(osm_place_country, cnode->data->name, cnode); break; case NODE_PLACE_CITY: case NODE_PLACE_TOWN: - g_printf("City: [%s] (%d)\n", cnode->data->name, cnode->id); g_hash_table_insert(osm_place_city, cnode->data->name, cnode); break; case NODE_PLACE_SUBURB: @@ -1510,7 +1515,7 @@ switch (t) { break; case IN_WAY_TAG: if (way_cnt % 1024==0) { - g_printf("Ways: %d\n", way_cnt); + g_printf("\rWays: %d\n", way_cnt); } cway->nodes=g_slist_reverse(cway->nodes); @@ -1616,7 +1621,7 @@ switch (t) { /* */ break; case IN_OSM_TAG: - g_printf("Planet loaded.\n"); + g_printf("\nPlanet loaded.\n"); break; default:; } @@ -1733,10 +1738,10 @@ static void print_memory_usage(void) { g_print("Memory usage per item:\n"); -g_printf("Node size: %d\n", (int)sizeof(node)); -g_printf("NodeD size: %d\n", (int)sizeof(node_data)); -g_printf("Way size: %d\n", (int)sizeof(way)); -g_printf("WayD size: %d\n", (int)sizeof(way_data)); +g_printf("Node size: %d\n", (gint)sizeof(node)); +g_printf("NodeD size: %d\n", (gint)sizeof(node_data)); +g_printf("Way size: %d\n", (gint)sizeof(way)); +g_printf("WayD size: %d\n", (gint)sizeof(way_data)); } /************************************************************************/