guint _num_downloads=0;
guint _curr_download=0;
+static osm_location map_loc = {NULL, NULL, NULL};
static GHashTable *map_tile_hash = NULL;
void map_render_paths();
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
+gboolean
+map_update_location_from_gps()
+{
+map_update_location(_pos.unitx, _pos.unity);
+return FALSE;
+}
+
+gboolean
+map_update_location_from_center()
+{
+map_update_location(_center.unitx, _center.unity);
+return FALSE;
+}
+
/**
* Make sure the mark is up-to-date. This function triggers a panning of
* the view if the mark is appropriately close to the edge of the view.
speed_limit();
if (_center_mode>0)
- map_update_location(_pos.unitx, _pos.unity);
+ g_idle_add((GSourceFunc)map_update_location_from_gps, NULL);
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
map_update_location(gint x, gint y)
{
gint ilat, ilon;
-gdouble lat,lon;
-osm_way *street;
+gdouble lat,lon, dist;
osm_place mplace;
osm_place splace;
PoiInfo *p;
ilat=lat2mp_int(lat);
ilon=lon2mp_int(lon);
+/* Check if we are still near the same way as last time */
+if (map_loc.street && osm_way_distance(ilat, ilon, map_loc.street->node_f, map_loc.street->node_t, &dist)==TRUE) {
+ if (dist>15000.0) {
+ osm_way_free(map_loc.street);
+ map_loc.street=osm_find_nearest_way(ilat, ilon);
+ }
+} else {
+ osm_way_free(map_loc.street);
+ map_loc.street=osm_find_nearest_way(ilat, ilon);
+}
+
mplace.name=NULL;
splace.name=NULL;
p=poi_find_nearest(lat, lon);
-street=osm_find_nearest_way(ilat, ilon);
osm_find_nearest_place(NODE_PLACE_SUBURB, ilat, ilon, &splace);
if (splace.isin!=0) {
} else {
g_printf("In %s\n", mplace.name);
}
-} else if (street && street->isin!=0) {
- if (osm_place_get(street->isin, ilat, ilon, &mplace)==FALSE) {
+} else if (map_loc.street && map_loc.street->isin!=0) {
+ if (osm_place_get(map_loc.street->isin, ilat, ilon, &mplace)==FALSE) {
} else {
g_printf("In %s\n", mplace.name);
}
-map_set_place_information(street, &mplace, &splace, p);
-osm_way_free(street);
+map_set_place_information(map_loc.street, &mplace, &splace, p);
}
gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event)
break;
}
+#if 0
ux = x2unit((gint) (event->x + 0.5));
uy = y2unit((gint) (event->y + 0.5));
-
map_update_location(ux, uy);
+#endif
+
+ g_idle_add((GSourceFunc)map_update_location_from_center, NULL);
+
map_center_unit(x2unit((gint) (event->x + 0.5)),
y2unit((gint) (event->y + 0.5)));