From fd61d30c64af498a0aff235ad0d596171069758d Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 21 Jul 2007 21:06:23 +0300 Subject: [PATCH] Start to handle place isin id #. We still need to handle storing it in osm.c --- src/map.c | 6 +++++- src/osm-db.c | 15 ++++++++++++--- src/osm.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/map.c b/src/map.c index 2f092b8..f3a3c99 100644 --- a/src/map.c +++ b/src/map.c @@ -1384,7 +1384,11 @@ g_printf("IntPos: %d , %d\n", ilat, ilon); if (osm_find_nearest_place(NODE_PLACE_SUBURB, ilat, ilon, &splace)==TRUE) g_printf("Near suburb: %s\n", splace.name); - +if (splace.isin!=0) { +#if 0 + osm_get_place(splace.isin, &mplace); +#endif +} if (osm_find_nearest_place(NODE_PLACE_CITY, ilat, ilon, &mplace)==TRUE) g_printf("Near city: %s\n", mplace.name); else if (osm_find_nearest_place(NODE_PLACE_TOWN, ilat, ilon, &mplace)==TRUE) diff --git a/src/osm-db.c b/src/osm-db.c index 62c07ae..3fda99c 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -29,7 +29,7 @@ osm_db_prepare(sqlite3 *db) /* 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 " + " lat,lon,places.nid,isin " " from places,nodes where type=$TYPE " " and nodes.nid=places.nid " " and lat between $LAT-$RANGE and $LAT+$RANGE" @@ -85,11 +85,19 @@ gint range; switch (type) { case NODE_PLACE_SUBURB: - range=70000; + range=75000; break; - default: + case NODE_PLACE_CITY: + case NODE_PLACE_TOWN: + range=250000; + break; + case NODE_PLACE_HAMLET: + case NODE_PLACE_VILLAGE: range=100000; break; + default: + range=80000; + break; } g_assert(n); @@ -115,6 +123,7 @@ if (SQLITE_ROW == sqlite3_step(sql.select_place)) { n->lat=sqlite3_column_int(sql.select_place, 2); n->lon=sqlite3_column_int(sql.select_place, 3); n->id=sqlite3_column_int(sql.select_place, 4); + n->isin=sqlite3_column_int(sql.select_place, 5); n->type=type; g_printf("Place(%d): %s distance: %f\n", type, place, sqrt((float)dist)); diff --git a/src/osm.h b/src/osm.h index b28a256..a51afe0 100644 --- a/src/osm.h +++ b/src/osm.h @@ -96,6 +96,7 @@ struct _osm_place { gint lat; gint lon; gint dist; + guint32 isin; }; typedef struct _osm_way osm_way; -- 2.39.5