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;
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;
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);
/* 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) "
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);
}
/*********************************************************************/
-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);
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