]> err.no Git - mapper/commitdiff
Small changes in importer, add comments and use more transactions
authorKaj-Michael Lang <milang@tal.org>
Mon, 28 Apr 2008 22:36:44 +0000 (01:36 +0300)
committerKaj-Michael Lang <milang@tal.org>
Mon, 28 Apr 2008 22:36:44 +0000 (01:36 +0300)
src/osm-db-import.c

index a274d63c4a0f5e7f389b786b540379af8f9c7fa5..cec035b655ed62954568461d6dee4c1b54f2efe8 100644 (file)
@@ -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