{
/* Place */
/* Select nearest place inside lat,lon+-range */
-if (sqlite3_prepare_v2(db, "select name,(($LAT-lat)*($LAT-lat))+(($LON-lon)*($LON-lon)) as dist,"
- " lat,lon,places.nid,isin "
+if (sqlite3_prepare_v2(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as dist,"
+ " ilat,ilon,places.nid,isin "
" from places,nodes where type=$TYPE "
" and nodes.nid=places.nid "
- " and lat between $LAT-$RANGE and $LAT+$RANGE"
- " and lon between $LON-$RANGE and $LON+$RANGE order by dist limit 1",
+ " and ilat between $LAT-$RANGE and $LAT+$RANGE"
+ " and ilon between $LON-$RANGE and $LON+$RANGE order by dist limit 1",
-1, &sql.select_near_place, NULL)!=SQLITE_OK)
return FALSE;
/* Ways */
/* Select nearest ways inside lat,lon+-range */
if (sqlite3_prepare_v2(db, "select wid,type,nodes,flags,"
- "(($LAT-lat)*($LAT-lat))+(($LON-lon)*($LON-lon)) as d,wn.f,wn.t,n.lat,n.lon "
+ "(($LAT-n.lat)*($LAT-n.lat))+(($LON-n.lon)*($LON-n.lon)) as d,wn.f,wn.t,n.lat,n.lon "
" 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 "
return FALSE;
if (sqlite3_prepare_v2(db, "select w.wid,w.name as name,"
- "(($LAT-lat)*($LAT-lat))+(($LON-lon)*($LON-lon)) as d,wn.f,w.lat,wlon "
+ "(($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 where "
" ww.type between $WTS and $WTY and w.wid=ww.wid and w.name like $NAME "
- " and w.lat between $LAT-$RANGE and $LAT+$RANGE "
- " and w.lon between $LON-$RANGE and $LON+$RANGE "
+ " and ww.lat between $LAT-$RANGE and $LAT+$RANGE "
+ " and ww.lon between $LON-$RANGE and $LON+$RANGE "
" union "
" select w.wid,n.name as name,"
- "(($LAT-w.lat)*($LAT-w.lat))+(($LON-w.lon)*($LON-w.lon)) as d,wn.f,w.lat,wlon "
+ "(($LAT-ww.lat)*($LAT-ww.lat))+(($LON-ww.lon)*($LON-w.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 w.lat between $LAT-$RANGE and $LAT+$RANGE "
- " and w.lon between $LON-$RANGE and $LON+$RANGE "
+ " and ww.lat between $LAT-$RANGE and $LAT+$RANGE "
+ " and ww.lon between $LON-$RANGE and $LON+$RANGE "
" order by d",
-1, &sql.select_way_name_search, NULL)!=SQLITE_OK)
return FALSE;
return map_loc->street ? TRUE : FALSE;
}
+/**
+ * osm_way_search
+ *
+ * Search for a street(way) starting with given 'text', next given lat/lon
+ *
+ */
gboolean
osm_way_search(gdouble lat, gdouble lon, gchar *text, GtkListStore **store)
{
ltext=g_strdup_printf("%s%%", text);
-
if (SQLITE_OK != sqlite3_bind_double(sql.select_way_name_search, 1, lat) ||
SQLITE_OK != sqlite3_bind_double(sql.select_way_name_search, 2, lon) ||
SQLITE_OK != sqlite3_bind_int(sql.select_way_name_search, 3, WAY_ROAD_START) ||
return FALSE;
}
+if (ltext)
+ g_free(ltext);
+
*store = gtk_list_store_new(ITEM_NUM_COLUMNS,
G_TYPE_INT, /* ID */
G_TYPE_INT, /* Category ID */
G_TYPE_STRING, /* Lat/Lon */
G_TYPE_STRING, /* Label */
G_TYPE_STRING, /* Desc. */
- G_TYPE_STRING); /* Category Label */
+ G_TYPE_STRING); /* Category */
while (SQLITE_ROW == sqlite3_step(sql.select_way_name_search)) {
gdouble rlat, rlon, dist;
- rlat=sqlite3_column_double(sql.select_way_name_search, 0);
- rlon=sqlite3_column_double(sql.select_way_name_search, 1);
+ rlat=sqlite3_column_double(sql.select_way_name_search, 2);
+ rlon=sqlite3_column_double(sql.select_way_name_search, 3);
lat_format(rlat, tmp1);
lon_format(rlon, tmp2);
dist=0.0;
gtk_list_store_append(*store, &iter);
gtk_list_store_set(*store, &iter,
- ITEM_ID, sqlite3_column_int(sql.select_way_name_search, 2),
- ITEM_CATID, sqlite3_column_int(sql.select_way_name_search, 5),
+ ITEM_ID, sqlite3_column_int(sql.select_way_name_search, 0),
ITEM_LAT, rlat,
ITEM_LON, rlon,
ITEM_DIST, dist,
ITEM_LATLON, g_strdup_printf("%s, %s", tmp1, tmp2),
- ITEM_LABEL, sqlite3_column_text(sql.select_way_name_search, 3),
+ ITEM_LABEL, sqlite3_column_text(sql.select_way_name_search, 1),
ITEM_DESC, sqlite3_column_text(sql.select_way_name_search, 4),
- ITEM_CATLAB, sqlite3_column_text(sql.select_way_name_search, 6),
-1);
rows++;
}
sqlite3_reset(sql.select_way_name_search);
sqlite3_clear_bindings(sql.select_way_name_search);
-if (ltext)
- g_free(ltext);
-
return TRUE;
}