guint _num_downloads=0;
guint _curr_download=0;
-static osm_location map_loc = {NULL, NULL, NULL, FALSE, 0, 0};
+static osm_location map_loc = {NULL, NULL, NULL, FALSE, FALSE, 0, 0};
static GHashTable *map_tile_hash = NULL;
typedef struct _map_tile_rdata map_tile_rdata;
gboolean curl_download_timeout();
gchar *map_construct_url(guint tilex, guint tiley, guint zoom);
gboolean map_download_idle_refresh(ProgressUpdateInfo * pui);
-static void map_update_location(gint x, gint y);
+static void map_update_location(gint x, gint y, gboolean force);
gboolean get_next_pui(gpointer key, gpointer value, ProgressUpdateInfo ** data)
{
fclose(pui->file);
if (msg->data.result != CURLE_OK)
g_unlink(pui->dest_str); /* Delete so we try again. */
- curl_multi_remove_handle(_curl_multi,
- msg->easy_handle);
+ curl_multi_remove_handle(_curl_multi, msg->easy_handle);
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)
- map_download_idle_refresh, pui,
- NULL);
+ (GSourceFunc)map_download_idle_refresh, pui, NULL);
}
}
}
if (!pui->src_str) {
/* Failed to generate URL. */
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)map_download_idle_refresh, pui,
- NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_download_idle_refresh, pui, NULL);
continue;
}
/* We're not updating - check if file already exists. */
if (g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)
- map_download_idle_refresh,
- pui, NULL);
+ (GSourceFunc)map_download_idle_refresh, pui, NULL);
continue;
}
}
pui->dest_str);
MACRO_BANNER_SHOW_INFO(_window, buffer);
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)
- map_download_idle_refresh, pui,
+ (GSourceFunc)map_download_idle_refresh, pui,
NULL);
continue;
}
pui->tiley);
g_unlink(buffer);
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc) map_download_idle_refresh,
+ (GSourceFunc)map_download_idle_refresh,
pui, NULL);
} else
break;
TILE_SIZE_PIXELS,
TILE_SIZE_PIXELS);
} else {
-#if 1
+#if 0
map_tile_rdata *mtr;
mtr=g_slice_new(map_tile_rdata);
gboolean
map_update_location_from_gps()
{
-map_update_location(_pos.unitx, _pos.unity);
+map_update_location(_pos.unitx, _pos.unity, FALSE);
return FALSE;
}
gboolean
map_update_location_from_center()
{
-map_update_location(_center.unitx, _center.unity);
+/* Force re-validation of place if user is clicking around */
+map_loc.valid=FALSE;
+map_update_location(_center.unitx, _center.unity, TRUE);
return FALSE;
}
gtk_label_set_label(GTK_LABEL(info_banner.location), buffer);
}
-/* XXX: Move this to osm-db.c */
static void
-map_update_location(gint x, gint y)
+map_update_location(gint x, gint y, gboolean force)
{
gint ilat, ilon;
gdouble lat,lon;
ilat=lat2mp_int(lat);
ilon=lon2mp_int(lon);
-if (_gps.fix>1)
+if (_gps.fix>1 && !force)
osm_set_way_range_from_speed(_gps.speed);
else
- osm_set_way_range(OSM_RANGE_WAY);
+ osm_set_way_range(OSM_RANGE_WAY/4);
osm_progress_set_widget(_db, _progress_item);
_map_location_known=osm_get_location_data(ilat, ilon, &map_loc);
_map_location_dist=map_loc.street ? map_loc.street->dist : 900000.0;
-map_set_place_information(map_loc.street, map_loc.primary, map_loc.secondary);
+if (map_loc.valid)
+ map_set_place_information(map_loc.street, map_loc.primary, map_loc.secondary);
+else
+ map_set_place_information(NULL, NULL, NULL);
osm_progress_set_widget(_db, NULL);
+
+if (_dest.valid) {
+ gchar buffer[32];
+ gdouble dt=calculate_distance(lat, lon, _dest.lat, _dest.lon);
+ snprintf(buffer, sizeof(buffer), "%.02f %s", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+ gtk_label_set_label(GTK_LABEL(info_banner.distance), buffer);
+} else {
+ gtk_label_set_label(GTK_LABEL(info_banner.distance), "");
+}
+
inp=FALSE;
}
switch (event->button) {
case 1:
if (_center_mode > 0)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
- (_menu_ac_none_item),
- TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), TRUE);
switch (_map_mode) {
case MAP_MODE_DRAW_TRACK:
ux = x2unit((gint) (event->x + 0.5));
uy = y2unit((gint) (event->y + 0.5));
map_update_location(ux, uy);
-#endif
-
+#else
g_idle_add((GSourceFunc)map_update_location_from_center, NULL);
+#endif
map_center_unit(x2unit((gint) (event->x + 0.5)),
y2unit((gint) (event->y + 0.5)));