]> err.no Git - mapper/commitdiff
Quick hack to use the new info banner and osm-db place query.
authorKaj-Michael Lang <milang@angel.tal.org>
Sat, 21 Jul 2007 17:54:47 +0000 (20:54 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Sat, 21 Jul 2007 17:54:47 +0000 (20:54 +0300)
src/map.c

index 03fdd4d4c3bd4b15f49072b97f618f4ceff95504..2f092b807699cbdda5096af2c19bc5d0f295d955 100644 (file)
--- 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)