NEAR_WAYPOINT, /* We are near the next route waypoint */
REACHED_WAYPOINT, /* We have reached the next route waypoint */
REACHED_DESTINATION, /* We have reached the last route waypoint */
+ CLEARED, /* Path was cleared */
LAST_SIGNAL
};
static guint32 signals[LAST_SIGNAL] = {0};
path_free(Path *path)
{
g_return_if_fail(path);
-g_debug("path_free");
g_object_unref(path);
}
}
+WayPoint *
+path_find_nearest_waypoint(Path *path, guint unitx, guint unity)
+{
+WayPoint *wcurr;
+WayPoint *wnear;
+guint64 nearest_squared;
+Point pos = { unitx, unity, 0, NAN };
+
+g_return_val_if_fail(path, NULL);
+
+wcurr=wnear=path->whead;
+if (wcurr && wcurr->point && wcurr!=path->wtail) {
+ nearest_squared=DISTANCE_SQUARED(pos, *(wcurr->point));
+
+ while (wcurr++!=path->wtail) {
+ guint64 test_squared=DISTANCE_SQUARED(pos, *(wcurr->point));
+ if (test_squared < nearest_squared) {
+ wnear=wcurr;
+ nearest_squared=test_squared;
+ }
+ }
+}
+
+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;
+}
+
/******************************************************************************/
gdouble
path->wtail->desc=text;
} else {
path->wpcnt++;
- path->wtail->desc=g_strdup_printf("WP: %u", path->wpcnt);
+ path->wtail->desc=g_strdup_printf("WPT:#%u", path->wpcnt);
}
g_signal_emit(G_OBJECT(path), signals[NEW_WAYPOINT], 0, NULL);
}
+void
+path_insert_mark_autonumber(Path *path)
+{
+path_insert_mark_text(path, NULL);
+}
+
/******************************************************************************/
#if 0
static void
#include "help.h"
#define DISTANCE_SQUARED(a, b) \
- ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx))\
- + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
+ ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx))\
+ + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
static gboolean show_directions=TRUE;
gtk_list_store_insert_with_values(_loc_model, &iter, INT_MAX, 0, to, -1);
}
- map_force_redraw();
-
MACRO_BANNER_SHOW_INFO(_window, _("Route Downloaded"));
g_free(rdl_data.bytes);
route_set_destination_from_last(route, &_dest);
return r;
}
-WayPoint *
-route_find_nearest_waypoint(Path *route, guint unitx, guint unity)
-{
-WayPoint *wcurr;
-WayPoint *wnear;
-guint64 nearest_squared;
-Point pos = { unitx, unity, 0, NAN };
-
-g_return_val_if_fail(route, NULL);
-
-wcurr = wnear = route->whead;
-if (wcurr && wcurr->point && wcurr != route->wtail) {
- nearest_squared = DISTANCE_SQUARED(pos, *(wcurr->point));
-
- while (wcurr++ != route->wtail) {
- guint64 test_squared = DISTANCE_SQUARED(pos, *(wcurr->point));
- if (test_squared < nearest_squared) {
- wnear = wcurr;
- nearest_squared = test_squared;
- }
- }
-}
-
-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 * _draw_width) && abs(unity - wnear->point->unity) < pixel2unit(3 * _draw_width))
- return wnear;
-}
-
-MACRO_BANNER_SHOW_INFO(_window, _("There are no waypoints."));
-
-return NULL;
-}
-
/**
* Show the distance from the current GPS location to the given point,
* following the route. If point is NULL, then the distance is shown to the