From 88e8b424cfbbd81288fc1486eb80ec0b6466ffd1 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 31 Oct 2007 09:28:32 +0200 Subject: [PATCH] Add way name search sql statement. Finalize statements in deinit --- src/osm-db.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/osm-db.c b/src/osm-db.c index 2d375eb..f53bd23 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -56,6 +56,7 @@ struct sql_select_stmt { sqlite3_stmt *select_way_nodes; sqlite3_stmt *select_way_name; sqlite3_stmt *select_way_name_nls; + sqlite3_stmt *select_way_name_search; sqlite3_stmt *select_way_ref; sqlite3_stmt *select_place; sqlite3_stmt *select_near_place; @@ -168,6 +169,13 @@ if (sqlite3_prepare_v2(db, "select wid,type,nodes,flags," -1, &sql.select_way2, NULL)!=SQLITE_OK) return FALSE; +if (sqlite3_prepare_v2(db, "select w.wid,w.name as name from way_names where w.type between $WTS and $WTY and w.name like ? " + " union " + " select w.wid,n.name as name from way_names as w,way_names_nls as n on w.wid=n.wid where " + " w.type between $WTS and $WTY and n.name like ? order by name", + -1, &sql.select_way_name_search, NULL)!=SQLITE_OK) + return FALSE; + if (sqlite3_prepare_v2(db, "select wn.t,lat,lon from way_n2n as wn,nodes where wsid=? and wn.f=? and wn.t=nodes.nid limit 1", -1, &sql.select_way_next_seg, NULL)!=SQLITE_OK) return FALSE; @@ -180,11 +188,6 @@ if (sqlite3_prepare_v2(db, "select wn.f,lat,lon from way_n2n as wn,nodes where w if (sqlite3_prepare_v2(db, "select name from way_names where wid=?", -1, &sql.select_way_name, NULL)!=SQLITE_OK) return FALSE; -#if 0 -if (sqlite3_prepare_v2(db, "select name from way_names_nls where wid=? and lang=?", - -1, &sql.select_way_name, NULL)!=SQLITE_OK) - return FALSE; -#endif /* Way ref and int_ref */ if (sqlite3_prepare_v2(db, "select ref,int_ref from way_ref where rid=?", @@ -197,6 +200,14 @@ return TRUE; void osm_deinit(void) { +sqlite3_finalize(sql.select_way_ref); +sqlite3_finalize(sql.select_way_name); +sqlite3_finalize(sql.select_way_next_seg); +sqlite3_finalize(sql.select_way_prev_seg); +sqlite3_finalize(sql.select_way_name_search); +sqlite3_finalize(sql.select_way2); +sqlite3_finalize(sql.select_place); +sqlite3_finalize(sql.select_near_place); osmdb=NULL; g_hash_table_destroy(place_cache); g_timer_destroy(dbt); -- 2.39.5