From: Kaj-Michael Lang Date: Tue, 6 Nov 2007 07:35:27 +0000 (+0200) Subject: Add two SQL statements for getting next/prev node X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2b23bf14869b2cf82879606bf0a832d4c3895f3;p=mapper Add two SQL statements for getting next/prev node --- diff --git a/src/osm-db.c b/src/osm-db.c index 6455e6a..2004bf4 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -62,6 +62,9 @@ struct sql_select_stmt { sqlite3_stmt *select_way_ref; sqlite3_stmt *select_place; sqlite3_stmt *select_near_place; + + sqlite3_stmt *select_node_next; + sqlite3_stmt *select_node_prev; }; static struct sql_select_stmt sql; static GTimer *dbt; @@ -197,13 +200,22 @@ if (sqlite3_prepare_v2(db, "select wn.f,ilat,ilon from way_n2n as wn,nodes where return FALSE; /* Way name */ -if (sqlite3_prepare_v2(db, "select name from way_names where wid=?", - -1, &sql.select_way_name, NULL)!=SQLITE_OK) +if (sqlite3_prepare_v2(db, "select name from way_names where wid=?", -1, &sql.select_way_name, NULL)!=SQLITE_OK) return FALSE; /* Way ref and int_ref */ -if (sqlite3_prepare_v2(db, "select ref,int_ref from way_ref where rid=?", - -1, &sql.select_way_ref, NULL)!=SQLITE_OK) +if (sqlite3_prepare_v2(db, "select ref,int_ref from way_ref where rid=?", -1, &sql.select_way_ref, NULL)!=SQLITE_OK) + return FALSE; + +/* Get next, prev node + way information. For routing. */ +if (sqlite3_prepare_v2(db, "select w.wid,w.type,w.flags,w.speed,n.nid,n.rlat,n.rlon,nn.f,nn.t,n.f,n.l " + "from way as w, nodes as n, way_n2n as nn where w.wid=nn.wid and nn.f=n.nid and nn.f=?", + -1, &sql.select_node_next, NULL)!=SQLITE_OK) + return FALSE; + +if (sqlite3_prepare_v2(db, "select w.wid,w.type,w.flags,w.speed,n.nid,n.rlat,n.rlon,nn.f,nn.t,n.f,n.l " + "from way as w, nodes as n, way_n2n as nn where w.wid=nn.wid and nn.f=n.nid and nn.t=?", + -1, &sql.select_node_next, NULL)!=SQLITE_OK) return FALSE; return TRUE;