static gint dbnoded_cnt=0;
static gint dbway_cnt=0;
+static gboolean is_update=FALSE;
static XML_Parser xp;
typedef struct _node_data node_data;
/*********************************************************************/
+void
+osm_planet_clear_nodes(void)
+{
+g_print("Clearing old nodes\n");
+sqlite3_step(sql.delete_nodes);
+}
+
void
osm_planet_save_nodes(void)
{
g_print("Storing nodes...\n");
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
-sqlite3_step(sql.delete_nodes);
g_hash_table_foreach(osm_nodes, osm_node_save_node, NULL);
sqlite3_exec(db, "commit;", NULL, NULL, NULL);
}
}
void
-osm_planet_save_ways(void)
+osm_planet_clear_ways(void)
{
-g_print("Storing ways...\n");
-
g_print("Clearing old data:\n");
sqlite3_step(sql.delete_way);
sqlite3_step(sql.delete_way_seg);
sqlite3_step(sql.delete_way_name);
sqlite3_step(sql.delete_way_ref);
+}
+void
+osm_planet_save_ways(void)
+{
g_print("Inserting new ways:\n");
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
g_slist_foreach(osm_ways, osm_node_save_way, NULL);
osm_planet_save_to_db(void)
{
g_printf("Saving planet to database:\n");
+
osm_planet_poi_clear_nodes();
osm_planet_poi_save_nodes();
+
+if (!is_update) {
+ osm_planet_clear_nodes();
+ osm_planet_clear_ways();
+}
+
osm_planet_save_nodes();
osm_planet_save_ways();
+
g_printf("Data saved.\n");
}
/************************************************************************/
-gboolean
+void
osm_planet_parse_init(void)
{
xp=XML_ParserCreate(NULL);
sqlite3_close(db);
sync();
+return 0;
}