GdkPixbuf *pixbuf=NULL;
gint zoff;
+if (!GTK_WIDGET_MAPPED(_map_pixmap))
+ return;
+
if (tilex<_world_size_tiles && tiley<_world_size_tiles) {
/* The tile is possible. */
for (zoff = (_curr_repo->double_size ? 1 : 0); !pixbuf && (_zoom + zoff) <= MAX_ZOOM && zoff <= TILE_SIZE_P2; zoff += 1) {
#define KM10KNOTS 5.39956803
+static void
+announce_distance_to_destination(gdouble distance, gchar *unit, gdouble climit)
+{
+gchar buffer[64];
+if (distance>climit) {
+ snprintf(buffer, sizeof(buffer), "Distance to destination: %.0f %s", distance, unit);
+} else {
+ snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", distance, unit);
+}
+speak_text(buffer);
+}
+
+static void
+announce_destination_reached()
+{
+speak_text("You have reached your destination.");
+}
+
static void
map_update_destination(gdouble lat, gdouble lon)
{
gdouble dh=0.0;
-gdouble dt;
+gdouble dt, cdist;
static gdouble prev_dt=99999.0;
static gboolean dest_reached=FALSE;
gchar buffer[64];
if (_dest.valid) {
dt=calculate_distance(lat, lon, _dest.lat, _dest.lon);
dh=calculate_course(lat, lon, _dest.lat, _dest.lon);
- snprintf(buffer, sizeof(buffer), "%.02f %s (%0.02f)", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units], dh<0 ? 360+dh : dh);
+ cdist=dt*UNITS_CONVERT[_units];
+
+ snprintf(buffer, sizeof(buffer), "%.02f %s (%0.02f)", cdist, UNITS_TEXT[_units], dh<0 ? 360+dh : dh);
gtk_label_set_label(GTK_LABEL(info_banner.distance), buffer);
+
if (dt<0.005 && dest_reached==FALSE) {
if (_center_mode>0)
- speak_text("You have reached your destination.");
+ announce_destination_reached();
dest_reached=TRUE;
} else if (dt<prev_dt-KM10KNOTS) {
- if (_center_mode>0) {
- snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
- speak_text(buffer);
- }
+ if (_center_mode>0)
+ announce_distance_to_destination(cdist, UNITS_TEXT[_units], KM10KNOTS);
prev_dt=dt;
} else if (dt>prev_dt+KM10KNOTS/4) {
prev_dt=dt;