#include "gpx.h"
#include "map-download.h"
-Point _min_center = { -1, -1 };
-Point _max_center = { -1, -1 };
-Point _focus = { -1, -1 };
+#include "gtkcompass.h"
/** The "base tile" is the upper-left tile in the pixmap. */
guint _base_tilex = -5;
guint _base_tiley = -5;
guint _zoom = 3; /* zoom level, from 0 to MAX_ZOOM. */
+
+Point _min_center = { -1, -1 };
+Point _max_center = { -1, -1 };
+Point _focus = { -1, -1 };
Point _center = { -1, -1 }; /* current center location, X. */
CenterMode _center_mode = CENTER_LEAD;
+/* Drag */
static guint press[2] = { 0, 0 };
static guint release[2] = { 0, 0 };
static guint before[2] = { 0, 0 };
BOUND(_center.unitx, _min_center.unitx, _max_center.unitx);
BOUND(_center.unity, _min_center.unity, _max_center.unity);
-_base_tilex = grid2tile((gint) pixel2grid((gint) unit2pixel((gint) _center.unitx))
- - (gint) _screen_grids_halfwidth);
-_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity))
- - _screen_grids_halfheight);
+_base_tilex = grid2tile((gint) pixel2grid((gint) unit2pixel((gint) _center.unitx)) - (gint) _screen_grids_halfwidth);
+_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity)) - _screen_grids_halfheight);
/* New zoom level, so we can't reuse the old buffer's pixels. */
/* Update state variables. */
static void
map_update_destination(gdouble lat, gdouble lon)
{
+gdouble dh=0.0;
+gdouble dt;
+gchar buffer[32];
+
if (_dest.valid) {
- gchar buffer[32];
- gdouble dt=calculate_distance(lat, lon, _dest.lat, _dest.lon);
- gdouble dh=calculate_course(lat, lon, _dest.lat, _dest.lon);
+ 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);
gtk_label_set_label(GTK_LABEL(info_banner.distance), buffer);
} else {
gtk_label_set_label(GTK_LABEL(info_banner.distance), "");
}
+gtk_compass_set_dest_heading(_gps_compass, _dest.valid, (gfloat)dh);
+gtk_compass_set_dest_heading(_tab_compass, _dest.valid, (gfloat)dh);
}
static void