]> err.no Git - mapper/commitdiff
Add way name search sql statement. Finalize statements in deinit
authorKaj-Michael Lang <milang@tal.org>
Wed, 31 Oct 2007 07:28:32 +0000 (09:28 +0200)
committerKaj-Michael Lang <milang@tal.org>
Wed, 31 Oct 2007 07:28:32 +0000 (09:28 +0200)
src/osm-db.c

index 2d375eb23411ca1830d516f387f2ecb38eb5f68e..f53bd239b1352d08a58b7ccec5d657e05d3d5661 100644 (file)
@@ -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);