NEW_POINT, /* A new point was appended to track track */
NEW_BREAK, /* A break was appended to the track */
NEW_WAYPOINT, /* A new waypoint/marker has been added */
- NEAR_WAYPOINT, /* We are near the next route waypoint */
- REACHED_WAYPOINT, /* We have reached the next route waypoint */
+ NEAR_WAYPOINT, /* We are near the next route waypoint, announce it */
+ REACHED_WAYPOINT, /* We have reached the next route waypoint, announce it */
REACHED_DESTINATION, /* We have reached the last route waypoint */
CLEARED, /* Path was cleared */
LAST_SIGNAL
G_DEFINE_TYPE(Path, path, G_TYPE_OBJECT);
-/* #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PATH_TYPE, PathPrivate)) */
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PATH_TYPE, PathPrivate))
static void
path_dispose(GObject *object)
}
if (wnear && wnear->point) {
- /* Only use the waypoint if it is within a 6*_draw_width square drawn
- * around the position. This is consistent with select_poi(). */
if (abs(unitx - wnear->point->unitx) < pixel2unit(3 * path->sensitivity) && abs(unity - wnear->point->unity) < pixel2unit(3 * path->sensitivity))
return wnear;
}
return NULL;
}
+/**
+ * Check if we should announce upcoming waypoint.
+ */
+void
+path_check_waypoint_announce(Path *route, GpsData *gps)
+{
+guint a_thres_near, a_thre_at;
+
+g_return_if_fail(path);
+g_return_if_fail(gps);
+
+if (!path->next_way)
+ return;
+
+a_thres_near=(20+(guint)gps->speed)*path->announce_notice_ratio*3;
+a_thres_at=(20+(guint)gps->speed);
+
+if (path->next_way_dist_squared<(a_thres_near * a_thres_near) && path->next_way!=path->announced_waypoint) {
+ g_signal_emit(G_OBJECT(path), signals[NEAR_WAYPOINT], 0, NULL);
+ announced_waypoint=route->next_way;
+} else if (path->next_way_dist_squared<(a_thres_at * a_thres_at) && path->next_way!=path->announced_waypoint) {
+ g_signal_emit(G_OBJECT(path), signals[REACHED_WAYPOINT], 0, NULL);
+ announced_waypoint=route->next_way;
+}
+
/******************************************************************************/
gdouble