From eca877e2dd0f9d9c01fd30dfdca258826e378b75 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 15 Oct 2007 11:39:51 +0300 Subject: [PATCH] Update compass when setting destination. Misc other changes. --- src/map.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/map.c b/src/map.c index e8b073d..47ce72c 100644 --- a/src/map.c +++ b/src/map.c @@ -41,19 +41,22 @@ #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 }; @@ -377,10 +380,8 @@ _max_center.unity = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfheight) - 1; 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. */ @@ -982,15 +983,20 @@ gtk_label_set_label(GTK_LABEL(info_banner.location), buffer); 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 -- 2.39.5