static gboolean is_update=FALSE;
static XML_Parser xp;
+/* POI or Place node extra data */
typedef struct _node_data node_data;
struct _node_data {
gchar *name;
- node_type_t type;
guint32 isin;
};
guint32 id;
gdouble lat;
gdouble lon;
+ node_type_t type;
node_data *data;
};
db_prepare(void)
{
/* Way nodes */
-sqlite3_prepare_v2(db, "insert or replace into nodes (nid,lat,lon,l,flags) values (?,?,?,0,?)", -1, &sql.insert_node, NULL);
+sqlite3_prepare_v2(db, "insert or replace into nodes (nid,lat,lon,l,f) values (?,?,?,0,?)", -1, &sql.insert_node, NULL);
sqlite3_prepare_v2(db, "select lat,lon,l from nodes where nid=?", -1, &sql.select_node, NULL);
sqlite3_prepare_v2(db, "delete from nodes", -1, &sql.delete_nodes, NULL);
sqlite3_prepare_v2(db, "update nodes set l=l+1 where nid=?", -1, &sql.update_node, NULL);
g_assert(n);
g_printf("Node #%d: T:%d [%s]\n",
n->id,
- n->data ? n->data->type : 0,
+ n->type,
n->data ? n->data->name : "");
#endif
}
db_insert_node(node *n)
{
gint32 lat, lon;
-guint32 flags=0;
sqlite3_bind_int(sql.insert_node, 1, n->id);
sqlite3_bind_double(sql.insert_node, 3, lon);
#endif
-sqlite3_bind_int(sql.insert_node, 4, flags);
+sqlite3_bind_int(sql.insert_node, 4, n->type);
sqlite3_step(sql.insert_node);
sqlite3_reset(sql.insert_node);
sqlite3_clear_bindings(sql.insert_node);
if (!n->data->name)
return FALSE;
sqlite3_bind_int(sql.insert_place, 1, n->id);
-sqlite3_bind_int(sql.insert_place, 2, n->data->type);
+sqlite3_bind_int(sql.insert_place, 2, n->type);
sqlite3_bind_text(sql.insert_place, 3, n->data->name, -1, SQLITE_TRANSIENT);
sqlite3_bind_int(sql.insert_place, 4, n->data->isin);
r=sqlite3_step(sql.insert_place);
sqlite3_bind_text(sql.insert_poi, 4, n->data->name, -1, SQLITE_TRANSIENT);
else
sqlite3_bind_text(sql.insert_poi, 4, "", -1, SQLITE_TRANSIENT);
-sqlite3_bind_int(sql.insert_poi, 5, n->data->type);
-sqlite3_bind_int(sql.insert_poi, 6, n->data->type/100);
+sqlite3_bind_int(sql.insert_poi, 5, n->type);
+sqlite3_bind_int(sql.insert_poi, 6, n->type/100);
sqlite3_bind_int(sql.insert_poi, 7, n->data->isin);
#if 0
g_printf("N: %d [%f:%f][%s](%d)\n",
n->id, n->lat, n->lon,
n->data->name ? n->data->name : "-",
- n->data->type);
+ n->type);
} else {
g_printf("N: %d [%f:%f]\n",
n->id, n->lat, n->lon);
if (n->data!=NULL) return;
n->data=g_slice_new(node_data);
n->data->name=NULL;
-n->data->type=NODE_PLAIN;
+n->type=NODE_PLAIN;
noded_cnt++;
}
gchar *ps;
ps=g_strstrip(*place);
#ifdef VERBOSE
- g_printf("Checking (%d) [%s] in [%s]\n",n->data->type, n->data->name, ps);
+ g_printf("Checking (%d) [%s] in [%s]\n",n->type, n->data->name, ps);
#endif
- switch (n->data->type) {
+ switch (n->type) {
case NODE_PLACE_CITY:
case NODE_PLACE_TOWN:
case NODE_PLACE_VILLAGE:
n->data->isin=osm_find_node_place(n);
-if (n->data->type>NODE_POI_START && n->data->type<NODE_POI_END) {
+if (n->type>NODE_POI_START && n->type<NODE_POI_END) {
print_node(n);
db_insert_poi(n);
-} else if (n->data->type>NODE_PLACE_START && n->data->type<NODE_PLACE_END) {
+} else if (n->type>NODE_PLACE_START && n->type<NODE_PLACE_END) {
print_node(n);
db_insert_place(n);
} else {
- g_printerr("Unhandled node type: %d\n", n->data->type);
osm_free_node_data(n);
return FALSE;
}
if (!v)
continue;
if (strcasecmp (v, nodeinfo[i].v)==0) {
- cnode->data->type=nodeinfo[i].type;
+ cnode->type=nodeinfo[i].type;
break;
}
}
- if (cnode->data->type!=NODE_PLAIN) {
+ if (cnode->type!=NODE_PLAIN) {
cnode->data->name=NULL;
v=g_hash_table_lookup(osm_node_tags, "name");
if (v)
g_hash_table_insert(osm_node_isin, GINT_TO_POINTER(cnode->id), isin);
}
- if (cnode->data->type==NODE_PLAIN) {
+ if (cnode->type==NODE_PLAIN) {
osm_free_node_data(cnode);
} else {
osm_poi=g_slist_prepend(osm_poi, cnode);
if (cnode->data->name) {
- switch (cnode->data->type) {
+ switch (cnode->type) {
case NODE_PLACE_COUNTRY:
g_hash_table_insert(osm_place_country, cnode->data->name, cnode);
break;