From dba33506e5f0f6213903fe2367d31186f0bbedfc Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 1 Nov 2007 03:00:58 +0200 Subject: [PATCH] Fix SQL --- src/osm-db.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/osm-db.c b/src/osm-db.c index 354b441..ca52791 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -140,7 +140,7 @@ osm_db_prepare(sqlite3 *db) /* Place */ /* Select nearest place inside lat,lon+-range */ if (sqlite3_prepare_v2(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as dist," - " ilat,ilon,places.nid,isin " + " ilat,ilon,places.nid,isin_p,isin_c " " from places,nodes where type=$TYPE " " and nodes.nid=places.nid " " and ilat between $LAT-$RANGE and $LAT+$RANGE" @@ -149,8 +149,8 @@ if (sqlite3_prepare_v2(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*( return FALSE; /* Select place name, distance, location, parent-place and type with given ID */ -if (sqlite3_prepare_v2(db, "select name,(($LAT-lat)*($LAT-lat))+(($LON-lon)*($LON-lon)) as dist," - " lat,lon,type,isin " +if (sqlite3_prepare_v2(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as dist," + " ilat,ilon,type,isin_p,isin_c " " from places,nodes where " " nodes.nid=places.nid " " and places.nid=$NID order by dist limit 1", @@ -159,12 +159,12 @@ if (sqlite3_prepare_v2(db, "select name,(($LAT-lat)*($LAT-lat))+(($LON-lon)*($LO /* Ways */ /* Select nearest ways inside lat,lon+-range */ -if (sqlite3_prepare_v2(db, "select wid,type,nodes,flags," - "(($LAT-n.lat)*($LAT-n.lat))+(($LON-n.lon)*($LON-n.lon)) as d,wn.f,wn.t,n.lat,n.lon " +if (sqlite3_prepare_v2(db, "select w.wid,type,nodes,flags," + "(($LAT-n.ilat)*($LAT-n.ilat))+(($LON-n.ilon)*($LON-n.ilon)) as d,wn.f,wn.t,n.ilat,n.ilon " " from way as w,way_n2n as wn,nodes as n " - " where w.wid=wn.wsid and wn.f=n.nid " - " and n.lat between $LAT-$RANGE and $LAT+$RANGE " - " and n.lon between $LON-$RANGE and $LON+$RANGE " + " where w.wid=wn.wid and wn.f=n.nid " + " and n.ilat between $LAT-$RANGE and $LAT+$RANGE " + " and n.ilon between $LON-$RANGE and $LON+$RANGE " " and w.type between $WTS and $WTY " " order by d", -1, &sql.select_way2, NULL)!=SQLITE_OK) @@ -178,7 +178,7 @@ if (sqlite3_prepare_v2(db, "select w.wid,w.name as name," " and ww.lon between $LON-$RANGE and $LON+$RANGE " " union " " select w.wid,n.name as name," - "(($LAT-ww.lat)*($LAT-ww.lat))+(($LON-ww.lon)*($LON-w.lon)) as d,ww.lat,ww.lon " + "(($LAT-ww.lat)*($LAT-ww.lat))+(($LON-ww.lon)*($LON-ww.lon)) as d,ww.lat,ww.lon " " from way_names as w, way as ww,way_names_nls as n on w.wid=n.wid where " " ww.type between $WTS and $WTY and w.wid=ww.wid and n.name like $NAME " " and ww.lat between $LAT-$RANGE and $LAT+$RANGE " @@ -187,11 +187,11 @@ if (sqlite3_prepare_v2(db, "select w.wid,w.name as 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", +if (sqlite3_prepare_v2(db, "select wn.t,ilat,ilon from way_n2n as wn,nodes where wid=? and wn.f=? and wn.t=nodes.nid limit 1", -1, &sql.select_way_next_seg, NULL)!=SQLITE_OK) return FALSE; -if (sqlite3_prepare_v2(db, "select wn.f,lat,lon from way_n2n as wn,nodes where wsid=? and wn.t=? and wn.f=nodes.nid limit 1", +if (sqlite3_prepare_v2(db, "select wn.f,ilat,ilon from way_n2n as wn,nodes where wid=? and wn.t=? and wn.f=nodes.nid limit 1", -1, &sql.select_way_prev_seg, NULL)!=SQLITE_OK) return FALSE; -- 2.39.5