From: Kaj-Michael Lang Date: Mon, 28 Apr 2008 22:36:44 +0000 (+0300) Subject: Small changes in importer, add comments and use more transactions X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07ceca3f6da1dea714f6bceece54bc9613f0e7eb;p=mapper Small changes in importer, add comments and use more transactions --- diff --git a/src/osm-db-import.c b/src/osm-db-import.c index a274d63..cec035b 100644 --- a/src/osm-db-import.c +++ b/src/osm-db-import.c @@ -321,14 +321,21 @@ static node *cnode=NULL; static way *cway=NULL; struct sql_stmt { + /* POIs */ sqlite3_stmt *insert_poi; sqlite3_stmt *delete_osm_poi; + /* Places */ + sqlite3_stmt *insert_place; + sqlite3_stmt *delete_places; + + /* Nodes */ sqlite3_stmt *insert_node; sqlite3_stmt *delete_nodes; sqlite3_stmt *select_node; sqlite3_stmt *update_node; + /* Ways */ sqlite3_stmt *insert_way_data; sqlite3_stmt *insert_way_ref; sqlite3_stmt *insert_way_pc; @@ -341,9 +348,6 @@ struct sql_stmt { sqlite3_stmt *delete_way_names_nls; sqlite3_stmt *delete_way_ref; sqlite3_stmt *delete_way_pc; - - sqlite3_stmt *insert_place; - sqlite3_stmt *delete_place; }; static struct sql_stmt sql; @@ -373,7 +377,7 @@ sqlite3_finalize(sql.delete_nodes); sqlite3_finalize(sql.update_node); sqlite3_finalize(sql.insert_place); -sqlite3_finalize(sql.delete_place); +sqlite3_finalize(sql.delete_places); sqlite3_finalize(sql.delete_way); sqlite3_finalize(sql.insert_way_data); @@ -402,7 +406,7 @@ sqlite3_prepare_v2(db, "update nodes set l=l+1 where nid=?", -1, &sql.update_nod /* Places */ sqlite3_prepare_v2(db, "insert or replace into places (nid,type,name,isin_c,isin_p) values (?, ?, ?, ?, ?)", -1, &sql.insert_place, NULL); -sqlite3_prepare_v2(db, "delete from places", -1, &sql.delete_place, NULL); +sqlite3_prepare_v2(db, "delete from places", -1, &sql.delete_places, NULL); /* POI nodes */ if (sqlite3_prepare_v2(db, "insert or replace into poi (osm_id, lat, lon, label, cat_id, public, source, priority, isin_c, isin_p, desc, url, postal_code) " @@ -1151,7 +1155,7 @@ osm_planet_poi_clear_nodes(void) g_print("Removing old OSM POIs...\n"); db_transaction_begin(db); sqlite3_step(sql.delete_osm_poi); -sqlite3_step(sql.delete_place); +sqlite3_step(sql.delete_places); return db_transaction_commit(db); } @@ -1167,17 +1171,19 @@ return db_transaction_commit(db); /*********************************************************************/ -static void +static gboolean osm_planet_clear_nodes(void) { -g_print("Clearing old nodes\n"); +g_print("Clearing old nodes...\n"); +db_transaction_begin(db); sqlite3_step(sql.delete_nodes); +return db_transaction_commit(db); } static gboolean osm_planet_save_nodes(void) { -g_print("Storing nodes...\n"); +g_print("Storing new nodes...\n"); db_transaction_begin(db); g_hash_table_foreach(osm_nodes, osm_node_save_node, NULL); return db_transaction_commit(db); @@ -1203,11 +1209,13 @@ if (dbway_cnt % 15000==0 && dbway_cnt>0) { static void osm_planet_clear_ways(void) { -g_print("Clearing old data\n"); +g_print("Clearing old way data...\n"); +db_transaction_begin(db); sqlite3_step(sql.delete_way); sqlite3_step(sql.delete_way_name); sqlite3_step(sql.delete_way_ref); sqlite3_step(sql.delete_way_n2n); +db_transaction_commit(db); } static gboolean