From: Kaj-Michael Lang Date: Thu, 25 Oct 2007 10:43:21 +0000 (+0300) Subject: Store node type in flags for now. Fix field flags -> f. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89a22a088d71012cdae3eb96ab26f552aff92cfa;p=mapper Store node type in flags for now. Fix field flags -> f. --- diff --git a/src/osm.c b/src/osm.c index 99de5df..dd1b028 100644 --- a/src/osm.c +++ b/src/osm.c @@ -65,10 +65,10 @@ static guint dbway_cnt=0; 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; }; @@ -78,6 +78,7 @@ struct _node { guint32 id; gdouble lat; gdouble lon; + node_type_t type; node_data *data; }; @@ -352,7 +353,7 @@ void 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); @@ -409,7 +410,7 @@ print_node(node *n) 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 } @@ -420,7 +421,6 @@ gboolean db_insert_node(node *n) { gint32 lat, lon; -guint32 flags=0; sqlite3_bind_int(sql.insert_node, 1, n->id); @@ -434,7 +434,7 @@ sqlite3_bind_double(sql.insert_node, 2, lat); 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); @@ -452,7 +452,7 @@ if (!n->data) 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); @@ -474,8 +474,8 @@ if (n->data->name) 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 @@ -680,7 +680,7 @@ if (n->data) { 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); @@ -717,7 +717,7 @@ if (n==NULL) return; 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++; } @@ -846,9 +846,9 @@ while (*place!=NULL) { 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: @@ -937,14 +937,13 @@ if (!n->data) { n->data->isin=osm_find_node_place(n); -if (n->data->type>NODE_POI_START && n->data->typetype>NODE_POI_START && n->typedata->type>NODE_PLACE_START && n->data->typetype>NODE_PLACE_START && n->typedata->type); osm_free_node_data(n); return FALSE; } @@ -1224,12 +1223,12 @@ switch (t) { 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) @@ -1244,12 +1243,12 @@ switch (t) { 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;