From fc3f84e3c7210a3f04359689787d9acb86aa90af Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 21 Jul 2007 20:54:47 +0300 Subject: [PATCH] Quick hack to use the new info banner and osm-db place query. --- src/map.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/map.c b/src/map.c index 03fdd4d..2f092b8 100644 --- a/src/map.c +++ b/src/map.c @@ -25,6 +25,8 @@ #include "utils.h" #include "map.h" +#include "osm.h" +#include "osm-db.h" #include "route.h" #include "gps.h" #include "bt.h" @@ -1352,16 +1354,43 @@ static void map_draw_track(gint x, gint y) refresh_mark(); } +void +map_set_place_information(osm_place *m, osm_place *s) +{ +gchar buffer[256]; + +snprintf(buffer, sizeof(buffer), "Near %s in %s", + s->name ? s->name : "Unknown", + m->name ? m->name : "Unknown" ); +gtk_label_set_label(GTK_LABEL(_info_banner), buffer); +} + static void map_print_int_latlon(gint x, gint y) { gint ux, uy; +gint ilat, ilon; gdouble lat,lon; +osm_place mplace; +osm_place splace; ux = x2unit((gint) (x + 0.5)); uy = y2unit((gint) (y + 0.5)); unit2latlon(ux, uy, lat, lon); -g_printf("IntPos: %d , %d\n", lat2mp_int(lat), lon2mp_int(lon)); +ilat=lat2mp_int(lat); +ilon=lon2mp_int(lon); + +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 (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) + g_printf("Near town: %s\n", mplace.name); + +map_set_place_information(&mplace, &splace); } gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event) -- 2.39.5