]> err.no Git - mapper/commitdiff
Fix SQL
authorKaj-Michael Lang <milang@tal.org>
Thu, 1 Nov 2007 01:00:58 +0000 (03:00 +0200)
committerKaj-Michael Lang <milang@tal.org>
Thu, 1 Nov 2007 01:00:58 +0000 (03:00 +0200)
src/osm-db.c

index 354b441b90f5c0a80b8e99c140eb4bb17cb81c37..ca527914a39b6c904468f8a9b8c59d290352209f 100644 (file)
@@ -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;