From d9b7d275377cb0a1831d8d27e8558818843fd828 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 19 Apr 2008 00:22:58 +0300 Subject: [PATCH] Add some comments --- src/osm-db.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/osm-db.c b/src/osm-db.c index 865e254..b4ba5ab 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -213,6 +213,10 @@ if (w!=NULL) { gboolean osm_db_prepare(sqlite3 *db) { +/***************** + * Place queries * + *****************/ + /* Select nearest place inside lat,lon+-range */ DB_PREP(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as d," " ilat,ilon,places.nid,isin_p,isin_c " @@ -231,7 +235,7 @@ DB_PREP(db, "select name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as " and places.nid=$NID order by d limit 1", sql.select_place); -/* Search */ +/* Search place names */ DB_PREP(db, "select places.nid,name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON-ilon)) as d," " rlat,rlon,type,isin_p,isin_c " " from places,nodes where " @@ -239,7 +243,10 @@ DB_PREP(db, "select places.nid,name,(($LAT-ilat)*($LAT-ilat))+(($LON-ilon)*($LON " and name like $NAME order by d limit 200", sql.select_place_search); -/* Ways */ +/*********************** + * Way related queries * + ***********************/ + /* Select nearest ways inside lat,lon+-range */ DB_PREP(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 " @@ -251,6 +258,7 @@ DB_PREP(db, "select w.wid,type,nodes,flags," " order by d", sql.select_way2); +/* Search way names inside bbox, using both primary and secondary language names */ DB_PREP(db, "select w.wid,w.name as name," "(($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 " @@ -264,19 +272,21 @@ DB_PREP(db, "select w.wid,w.name as name," " 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 " " and ww.lon between $LON-$RANGE and $LON+$RANGE " - " order by name limit 200", + " order by d, name limit 500", sql.select_way_name_search); +/* Get way segment */ DB_PREP(db, "select wn.t,ilat,ilon from way_n2n as wn,nodes where wid=? and wn.f=? and wn.t=nodes.nid limit 1", sql.select_way_next_seg); +/* Get way segment */ DB_PREP(db, "select wn.f,ilat,ilon from way_n2n as wn,nodes where wid=? and wn.t=? and wn.f=nodes.nid limit 1", sql.select_way_prev_seg); -/* Way name */ +/* Get Way name */ DB_PREP(db, "select name from way_names where wid=?", sql.select_way_name); -/* Way ref and int_ref */ +/* Get Way ref and int_ref */ DB_PREP(db, "select ref,int_ref from way_ref where rid=?", sql.select_way_ref); /* Get next, prev node + way information. For routing. */ -- 2.39.5