void
map_draw_position_icon(Position *pos)
{
-guint x,y;
+guint x,y, x1,y1;
GdkPixbuf *p;
latlon2unit(pos->lat, pos->lon, x, y);
+x1=unit2bufx(x);
+y1=unit2bufy(y);
+
+if ((x1 > BUF_WIDTH_PIXELS) || (y1 > BUF_HEIGHT_PIXELS))
+ return;
+
p=gdk_pixbuf_new_from_file(DATADIR "/pixmaps/mapper/home.png", NULL);
if (p) {
map_draw_pixbuf(x,y,p);
void
map_render_paths(void)
{
- if ((_show_tracks & ROUTES_MASK) && _route.head != _route.tail) {
- map_render_path(&_route, _gc + COLORABLE_ROUTE);
-
- /* Now, draw the next waypoint on top of all other waypoints. */
- if (_next_way) {
- guint x1 = unit2bufx(_next_way->point->unitx);
- guint y1 = unit2bufy(_next_way->point->unity);
- if ((x1 < BUF_WIDTH_PIXELS)
- && (y1 < BUF_HEIGHT_PIXELS)) {
- /* Draw the next waypoint as a break. */
- gdk_draw_arc(_map_pixmap, _gc[COLORABLE_ROUTE_BREAK], FALSE, /* FALSE: not filled. */
- x1 - _draw_width, y1 - _draw_width, 2 * _draw_width, 2 * _draw_width, 0, /* start at 0 degrees. */
- 360 * 64);
- }
+if ((_show_tracks & ROUTES_MASK) && _route.head != _route.tail) {
+ map_render_path(&_route, _gc + COLORABLE_ROUTE);
+
+ /* Now, draw the next waypoint on top of all other waypoints. */
+ if (_next_way) {
+ guint x1 = unit2bufx(_next_way->point->unitx);
+ guint y1 = unit2bufy(_next_way->point->unity);
+
+ if ((x1 < BUF_WIDTH_PIXELS) && (y1 < BUF_HEIGHT_PIXELS)) {
+ /* Draw the next waypoint as a break. */
+ gdk_draw_arc(_map_pixmap, _gc[COLORABLE_ROUTE_BREAK], FALSE, /* FALSE: not filled. */
+ x1 - _draw_width, y1 - _draw_width, 4 * _draw_width, 4 * _draw_width, 0, /* start at 0 degrees. */
+ 360 * 64);
}
}
- if (_show_tracks & TRACKS_MASK)
- map_render_path(&_track, _gc + COLORABLE_TRACK);
+}
+if (_show_tracks & TRACKS_MASK)
+ map_render_path(&_track, _gc + COLORABLE_TRACK);
}
/**
*
*
*/
-static
-gboolean map_follow_move(GtkWidget *widget, GdkEventMotion *event)
+static gboolean
+map_follow_move_cb(GtkWidget *widget, GdkEventMotion *event)
{
GdkModifierType state;
gint xx, yy;
gdouble dh=0.0;
gdouble dt;
static gdouble prev_dt=99999.0;
+static gboolean dest_reached=FALSE;
gchar buffer[64];
if (_dest.valid) {
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);
- if (dt<prev_dt-KM10KNOTS) {
+ if (dt<0.005 && dest_reached==FALSE) {
+ speak_text("You have reached your destination.");
+ dest_reached=TRUE;
+ } else if (dt<prev_dt-KM10KNOTS) {
snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
speak_text(buffer);
prev_dt=dt;
- } else if (dt>prev_dt+KM10KNOTS) {
+ } else if (dt>prev_dt+KM10KNOTS/4) {
prev_dt=dt;
}
+ if (dt>0.05) {
+ dest_reached=FALSE;
+ }
+#if 0
g_printf("%f (Prev:%f)\n", prev_dt, dt);
+#endif
} else {
+ dest_reached=FALSE;
prev_dt=99999.0;
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);
+
+if (_next_way && _next_way->point) {
+ gdouble wp_lat, wp_lon;
+ gfloat wc;
+
+ unit2latlon(_next_way->point->unitx,_next_way->point->unity, wp_lat, wp_lon);
+ wc=calculate_course(lat, lon, wp_lat, wp_lon);
+ gtk_compass_set_way_heading(_gps_compass, TRUE, wc);
+ gtk_compass_set_way_heading(_tab_compass, TRUE, wc);
+} else {
+ gtk_compass_set_way_heading(_gps_compass, FALSE, 0);
+ gtk_compass_set_way_heading(_tab_compass, FALSE, 0);
+}
+
}
static void
press[1] = y;
before[0] = press[0];
before[1] = press[1];
-map_drag_id=g_signal_connect(G_OBJECT(_map_widget), "motion_notify_event", G_CALLBACK(map_follow_move), NULL);
+map_drag_id=g_signal_connect(G_OBJECT(_map_widget), "motion_notify_event", G_CALLBACK(map_follow_move_cb), NULL);
}
/**