#include <config.h>
-#define _GNU_SOURCE
-
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "map.h"
#include "file.h"
#include "latlon.h"
+#include "map.h"
+#include "map-download.h"
+#include "iap.h"
+
+#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)))
-void route_find_nearest_point();
+void route_find_nearest_point(void);
void cancel_autoroute(gboolean temporary);
+void route_show_distance_to_last(void);
+void route_set_destination_from_last(void);
typedef struct _OriginToggleInfo OriginToggleInfo;
struct _OriginToggleInfo {
GtkWidget *txt_to;
};
+void
+route_init(void)
+{
+memset(&_route, 0, sizeof(_route));
+MACRO_PATH_INIT(_route);
+}
+
+void
+route_deinit(void)
+{
+MACRO_PATH_FREE(_route);
+}
+
void
route_clear(void)
{
if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
cancel_autoroute(FALSE);
- MACRO_PATH_FREE(_route);
- MACRO_PATH_INIT(_route);
+ route_deinit();
+ route_init();
route_find_nearest_point();
map_force_redraw();
}
+_dest.valid=FALSE;
gtk_widget_destroy(confirm);
}
gboolean
-route_open_file()
+route_open_file(void)
{
gchar *buffer;
gint size;
-if (open_file(&buffer, NULL, &size, &_route_dir_uri, NULL, GTK_FILE_CHOOSER_ACTION_OPEN)) {
+if (file_open_get_contents(&_route_dir_uri, &buffer, &size)) {
/* If auto is enabled, append the route, otherwise replace it. */
if (parse_gpx(&_route, buffer, size, _autoroute_data.enabled ? 0 : 1)) {
cancel_autoroute(FALSE);
+ MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
/* Find the nearest route point, if we're connected. */
route_find_nearest_point();
-
map_force_redraw();
- MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
+ route_set_destination_from_last();
return TRUE;
} else {
popup_error(_window, _("Error parsing GPX file."));
return FALSE;
}
+/**
+ * Ask user to save route
+ */
gboolean
route_save(void)
{
return FALSE;
}
-gboolean
-origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti)
+/**
+ *
+ */
+static gboolean
+origin_type_selected_cb(GtkWidget * toggle, OriginToggleInfo * oti)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))) {
- if (toggle == oti->rad_use_gps) {
- gchar buffer[80];
- gchar strlat[32];
- gchar strlon[32];
- g_ascii_formatd(strlat, 32, "%.06f", _gps.lat);
- g_ascii_formatd(strlon, 32, "%.06f", _gps.lon);
- snprintf(buffer, sizeof(buffer), "%s, %s", strlat,
- strlon);
- gtk_entry_set_text(GTK_ENTRY(oti->txt_from), buffer);
- } else if (toggle == oti->rad_use_route) {
- gchar buffer[80];
- gchar strlat[32];
- gchar strlon[32];
- Point *p;
- gfloat lat, lon;
-
- /* Use last non-zero route point. */
- for (p = _route.tail; !p->unity; p--) {
- }
+if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))) {
+ if (toggle == oti->rad_use_gps) {
+ gchar buffer[80];
+ gchar strlat[32];
+ gchar strlon[32];
+ g_ascii_formatd(strlat, 32, "%.06f", _gps->data.lat);
+ g_ascii_formatd(strlon, 32, "%.06f", _gps->data.lon);
+ g_snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_from), buffer);
+ } else if (toggle == oti->rad_use_route) {
+ gchar buffer[80];
+ gchar strlat[32];
+ gchar strlon[32];
+ Point *p;
+ gdouble lat, lon;
- unit2latlon(p->unitx, p->unity, lat, lon);
- g_ascii_formatd(strlat, 32, "%.06f", lat);
- g_ascii_formatd(strlon, 32, "%.06f", lon);
- snprintf(buffer, sizeof(buffer), "%s, %s", strlat,
- strlon);
- gtk_entry_set_text(GTK_ENTRY(oti->txt_from), buffer);
+ /* Use last non-zero route point. */
+ for (p = _route.tail; !p->unity; p--) {
}
- gtk_widget_set_sensitive(oti->txt_from,
- toggle == oti->rad_use_text);
- gtk_widget_set_sensitive(oti->chk_auto,
- toggle == oti->rad_use_gps);
+ unit2latlon(p->unitx, p->unity, lat, lon);
+ g_ascii_formatd(strlat, 32, "%.06f", lat);
+ g_ascii_formatd(strlon, 32, "%.06f", lon);
+ g_snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_from), buffer);
}
- vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
- return TRUE;
+ gtk_widget_set_sensitive(oti->txt_from, toggle == oti->rad_use_text);
+ gtk_widget_set_sensitive(oti->chk_auto, toggle == oti->rad_use_gps);
+}
+return TRUE;
}
/**
void
cancel_autoroute(gboolean temporary)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (_autoroute_data.enabled) {
- if (!temporary) {
- _autoroute_data.enabled = FALSE;
-
- g_free(_autoroute_data.dest);
- _autoroute_data.dest = NULL;
+if (_autoroute_data.enabled) {
+ if (!temporary) {
+ _autoroute_data.enabled = FALSE;
- g_free(_autoroute_data.src_str);
- _autoroute_data.src_str = NULL;
- }
-
- if (_autoroute_data.curl_easy) {
- if (_curl_multi)
- curl_multi_remove_handle(_curl_multi,
- _autoroute_data.curl_easy);
- curl_easy_cleanup(_autoroute_data.curl_easy);
- _autoroute_data.curl_easy = NULL;
- }
+ g_free(_autoroute_data.dest);
+ _autoroute_data.dest = NULL;
- g_free(_autoroute_data.rdl_data.bytes);
- _autoroute_data.rdl_data.bytes = NULL;
- _autoroute_data.rdl_data.bytes_read = 0;
+ g_free(_autoroute_data.src_str);
+ _autoroute_data.src_str = NULL;
+ }
- _autoroute_data.in_progress = FALSE;
+ if (_autoroute_data.curl_easy) {
+ if (_curl_multi)
+ curl_multi_remove_handle(_curl_multi, _autoroute_data.curl_easy);
+ curl_easy_cleanup(_autoroute_data.curl_easy);
+ _autoroute_data.curl_easy = NULL;
}
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+ g_free(_autoroute_data.rdl_data.bytes);
+ _autoroute_data.rdl_data.bytes = NULL;
+ _autoroute_data.rdl_data.bytes_read = 0;
+
+ _autoroute_data.in_progress = FALSE;
+}
}
/**
* auto-route with that data.
*/
size_t
-route_dl_cb_read(void *ptr, size_t size, size_t nmemb,
- RouteDownloadData * rdl_data)
+route_dl_cb_read(void *ptr, size_t size, size_t nmemb, RouteDownloadData * rdl_data)
{
- size_t old_size = rdl_data->bytes_read;
- vprintf("%s()\n", __PRETTY_FUNCTION__);
+size_t old_size = rdl_data->bytes_read;
- rdl_data->bytes_read += size * nmemb;
- rdl_data->bytes = g_renew(gchar, rdl_data->bytes, rdl_data->bytes_read);
- g_memmove(rdl_data->bytes + old_size, ptr, size * nmemb);
+rdl_data->bytes_read += size * nmemb;
+rdl_data->bytes = g_renew(gchar, rdl_data->bytes, rdl_data->bytes_read);
+g_memmove(rdl_data->bytes + old_size, ptr, size * nmemb);
- vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, size * nmemb);
- return (size * nmemb);
+return (size * nmemb);
}
gboolean
auto_route_dl_idle()
{
- gchar latstr[32], lonstr[32], *latlonstr;
- printf("%s(%f, %f, %s)\n", __PRETTY_FUNCTION__,
- _gps.lat, _gps.lon, _autoroute_data.dest);
-
- g_ascii_dtostr(latstr, 32, _gps.lat);
- g_ascii_dtostr(lonstr, 32, _gps.lon);
- latlonstr = g_strdup_printf("%s,%s", latstr, lonstr);
- _autoroute_data.src_str =
- g_strdup_printf(_route_dl_url, latlonstr, _autoroute_data.dest);
- g_free(latlonstr);
-
- MACRO_CURL_EASY_INIT(_autoroute_data.curl_easy);
- curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_URL,
- _autoroute_data.src_str);
- curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEFUNCTION,
- route_dl_cb_read);
- curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEDATA,
- &_autoroute_data.rdl_data);
- if (!_curl_multi) {
- /* Initialize CURL. */
- _curl_multi = curl_multi_init();
- /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */
- }
- curl_multi_add_handle(_curl_multi, _autoroute_data.curl_easy);
+gchar latstr[32], lonstr[32], *latlonstr;
+
+g_ascii_dtostr(latstr, 32, _gps->data.lat);
+g_ascii_dtostr(lonstr, 32, _gps->data.lon);
+latlonstr = g_strdup_printf("%s,%s", latstr, lonstr);
+_autoroute_data.src_str =
+ g_strdup_printf(_route_dl_url, latlonstr, _autoroute_data.dest);
+g_free(latlonstr);
+
+MACRO_CURL_EASY_INIT(_autoroute_data.curl_easy);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_URL, _autoroute_data.src_str);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEDATA, &_autoroute_data.rdl_data);
+if (!_curl_multi) {
+ /* Initialize CURL. */
+ _curl_multi = curl_multi_init();
+ /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */
+}
+curl_multi_add_handle(_curl_multi, _autoroute_data.curl_easy);
-#ifdef WITH_OSSO
- if (iap_is_connected() && !_curl_sid)
-#else
- if (!_curl_sid)
-#endif
- _curl_sid = g_timeout_add(100,
- (GSourceFunc) curl_download_timeout,
- NULL);
+if (iap_is_connected() && !_curl_sid)
+ _curl_sid = g_timeout_add(100, (GSourceFunc) map_download_timeout, NULL);
- _autoroute_data.in_progress = TRUE;
+_autoroute_data.in_progress = TRUE;
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
- return FALSE;
+return FALSE;
}
/**
gboolean
route_download(gchar * to)
{
- GtkWidget *dialog;
- GtkWidget *table;
- GtkWidget *label;
- GtkWidget *txt_source_url;
- GtkWidget *hbox;
- OriginToggleInfo oti;
- GtkEntryCompletion *from_comp;
- GtkEntryCompletion *to_comp;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
-#ifdef WITH_OSSO
- iap_connect();
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_source_url;
+GtkWidget *hbox;
+OriginToggleInfo oti;
+GtkEntryCompletion *from_comp;
+GtkEntryCompletion *to_comp;
+
+iap_connect();
+
+dialog = gtk_dialog_new_with_buttons(_("Download Route"),
+ GTK_WINDOW(_window),
+ GTK_DIALOG_MODAL, GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT, NULL);
+
+help_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_DOWNROUTE);
+
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ table = gtk_table_new(2, 5, FALSE), TRUE, TRUE, 0);
+
+from_comp = gtk_entry_completion_new();
+gtk_entry_completion_set_model(from_comp, GTK_TREE_MODEL(_loc_model));
+gtk_entry_completion_set_text_column(from_comp, 0);
+to_comp = gtk_entry_completion_new();
+gtk_entry_completion_set_model(to_comp, GTK_TREE_MODEL(_loc_model));
+gtk_entry_completion_set_text_column(to_comp, 0);
+
+/* Source URL. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Source URL")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+gtk_table_attach(GTK_TABLE(table), txt_source_url = gtk_entry_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_entry_set_width_chars(GTK_ENTRY(txt_source_url), 25);
+
+/* Auto. */
+gtk_table_attach(GTK_TABLE(table),
+ hbox = gtk_hbox_new(FALSE, 6),
+ 0, 2, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_box_pack_start(GTK_BOX(hbox),
+ oti.rad_use_gps = gtk_radio_button_new_with_label(NULL, _("Use GPS Location")),
+ TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), oti.chk_auto =
+ gtk_check_button_new_with_label(_("Auto-Update")),
+ TRUE, TRUE, 0);
+gtk_widget_set_sensitive(oti.chk_auto, FALSE);
+
+/* Use End of Route. */
+gtk_table_attach(GTK_TABLE(table),
+ hbox = gtk_hbox_new(FALSE, 6),
+ 0, 2, 2, 3, GTK_FILL, 0, 2, 4);
+gtk_box_pack_start(GTK_BOX(hbox),
+ oti.rad_use_route =
+ gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON(oti.rad_use_gps),
+ _("Use End of Route")), TRUE, TRUE, 0);
+gtk_widget_set_sensitive(oti.rad_use_route, _route.head != _route.tail);
+
+/* Origin. */
+gtk_table_attach(GTK_TABLE(table),
+ oti.rad_use_text =
+ gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON(oti.rad_use_gps), _("Origin")), 0, 1,
+ 3, 4, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), oti.txt_from =
+ gtk_entry_new(), 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0,
+ 2, 4);
+gtk_entry_set_completion(GTK_ENTRY(oti.txt_from), from_comp);
+gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_from), 25);
+
+/* Destination. */
+gtk_table_attach(GTK_TABLE(table),
+ label = gtk_label_new(_("Destination")),
+ 0, 1, 4, 5, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+gtk_table_attach(GTK_TABLE(table),
+ oti.txt_to = gtk_entry_new(), 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_entry_set_completion(GTK_ENTRY(oti.txt_to), to_comp);
+gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_to), 25);
+
+g_signal_connect(G_OBJECT(oti.rad_use_gps), "toggled", G_CALLBACK(origin_type_selected_cb), &oti);
+g_signal_connect(G_OBJECT(oti.rad_use_route), "toggled", G_CALLBACK(origin_type_selected_cb), &oti);
+g_signal_connect(G_OBJECT(oti.rad_use_text), "toggled", G_CALLBACK(origin_type_selected_cb), &oti);
+
+#if defined (WITH_HILDON) && defined (HILDON_AUTOCAP)
+g_object_set(G_OBJECT(oti.txt_from), HILDON_AUTOCAP, FALSE, NULL);
+g_object_set(G_OBJECT(oti.txt_to), HILDON_AUTOCAP, FALSE, NULL);
#endif
- dialog = gtk_dialog_new_with_buttons(_("Download Route"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT, NULL);
-
-#ifdef WITH_OSSO
- /* Enable the help button. */
- ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_DOWNROUTE,
- _osso);
-#endif
-
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- table = gtk_table_new(2, 5, FALSE), TRUE, TRUE, 0);
-
- from_comp = gtk_entry_completion_new();
- gtk_entry_completion_set_model(from_comp, GTK_TREE_MODEL(_loc_model));
- gtk_entry_completion_set_text_column(from_comp, 0);
- to_comp = gtk_entry_completion_new();
- gtk_entry_completion_set_model(to_comp, GTK_TREE_MODEL(_loc_model));
- gtk_entry_completion_set_text_column(to_comp, 0);
-
- /* Source URL. */
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Source URL")),
- 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- gtk_table_attach(GTK_TABLE(table),
- txt_source_url = gtk_entry_new(),
- 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
- gtk_entry_set_width_chars(GTK_ENTRY(txt_source_url), 25);
-
- /* Auto. */
- gtk_table_attach(GTK_TABLE(table),
- hbox = gtk_hbox_new(FALSE, 6),
- 0, 2, 1, 2, GTK_FILL, 0, 2, 4);
- gtk_box_pack_start(GTK_BOX(hbox),
- oti.rad_use_gps =
- gtk_radio_button_new_with_label(NULL,
- _
- ("Use GPS Location")),
- TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), oti.chk_auto =
- gtk_check_button_new_with_label(_("Auto-Update")),
- TRUE, TRUE, 0);
- gtk_widget_set_sensitive(oti.chk_auto, FALSE);
-
- /* Use End of Route. */
- gtk_table_attach(GTK_TABLE(table),
- hbox = gtk_hbox_new(FALSE, 6),
- 0, 2, 2, 3, GTK_FILL, 0, 2, 4);
- gtk_box_pack_start(GTK_BOX(hbox),
- oti.rad_use_route =
- gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON(oti.rad_use_gps),
- _("Use End of Route")), TRUE, TRUE, 0);
- gtk_widget_set_sensitive(oti.rad_use_route, _route.head != _route.tail);
-
- /* Origin. */
- gtk_table_attach(GTK_TABLE(table),
- oti.rad_use_text =
- gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON(oti.rad_use_gps), _("Origin")), 0, 1,
- 3, 4, GTK_FILL, 0, 2, 4);
- gtk_table_attach(GTK_TABLE(table), oti.txt_from =
- gtk_entry_new(), 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0,
- 2, 4);
- gtk_entry_set_completion(GTK_ENTRY(oti.txt_from), from_comp);
- gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_from), 25);
-
- /* Destination. */
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Destination")),
- 0, 1, 4, 5, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- gtk_table_attach(GTK_TABLE(table),
- oti.txt_to = gtk_entry_new(),
- 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
- gtk_entry_set_completion(GTK_ENTRY(oti.txt_to), to_comp);
- gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_to), 25);
-
- g_signal_connect(G_OBJECT(oti.rad_use_gps), "toggled",
- G_CALLBACK(origin_type_selected), &oti);
- g_signal_connect(G_OBJECT(oti.rad_use_route), "toggled",
- G_CALLBACK(origin_type_selected), &oti);
- g_signal_connect(G_OBJECT(oti.rad_use_text), "toggled",
- G_CALLBACK(origin_type_selected), &oti);
-
-#if 0
- g_object_set(G_OBJECT(oti.txt_from), HILDON_AUTOCAP, FALSE, NULL);
- g_object_set(G_OBJECT(oti.txt_to), HILDON_AUTOCAP, FALSE, NULL);
-#endif
+/* Initialize fields. */
+gtk_entry_set_text(GTK_ENTRY(txt_source_url), _route_dl_url);
+gtk_entry_set_text(GTK_ENTRY(oti.txt_to), (to ? to : ""));
- /* Initialize fields. */
- gtk_entry_set_text(GTK_ENTRY(txt_source_url), _route_dl_url);
- gtk_entry_set_text(GTK_ENTRY(oti.txt_to), (to ? to : ""));
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_text), TRUE);
+/* Use "End of Route" by default if they have a route. */
+if (_route.head != _route.tail) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_route), TRUE);
+ gtk_widget_grab_focus(oti.rad_use_route);
+}
+/* Else use "GPS Location" if they have GPS enabled. */
+else if (_enable_gps) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps), TRUE);
+ gtk_widget_grab_focus(oti.rad_use_gps);
+}
+/* Else use text. */
+else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_text), TRUE);
+ gtk_widget_grab_focus(oti.txt_from);
+}
+
+gtk_widget_show_all(dialog);
- /* Use "End of Route" by default if they have a route. */
- if (_route.head != _route.tail) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
- (oti.rad_use_route), TRUE);
- gtk_widget_grab_focus(oti.rad_use_route);
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+ CURL *curl_easy;
+ RouteDownloadData rdl_data = { 0, 0 };
+ gchar buffer[BUFFER_SIZE];
+ const gchar *source_url, *from, *to;
+ gchar *from_escaped, *to_escaped;
+
+ source_url = gtk_entry_get_text(GTK_ENTRY(txt_source_url));
+ if (!strlen(source_url)) {
+ popup_error(dialog, _("Please specify a source URL."));
+ continue;
+ } else {
+ g_free(_route_dl_url);
+ _route_dl_url = g_strdup(source_url);
}
- /* Else use "GPS Location" if they have GPS enabled. */
- else if (_enable_gps) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps),
- TRUE);
- gtk_widget_grab_focus(oti.rad_use_gps);
+
+ from = gtk_entry_get_text(GTK_ENTRY(oti.txt_from));
+ if (!strlen(from)) {
+ popup_error(dialog, _("Please specify a start location."));
+ continue;
}
- /* Else use text. */
- else {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
- (oti.rad_use_text), TRUE);
- gtk_widget_grab_focus(oti.txt_from);
+
+ to = gtk_entry_get_text(GTK_ENTRY(oti.txt_to));
+ if (!strlen(to)) {
+ popup_error(dialog, _("Please specify an end location."));
+ continue;
}
- gtk_widget_show_all(dialog);
-
- while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
- CURL *curl_easy;
- RouteDownloadData rdl_data = { 0, 0 };
- gchar buffer[BUFFER_SIZE];
- const gchar *source_url, *from, *to;
- gchar *from_escaped, *to_escaped;
-
- source_url = gtk_entry_get_text(GTK_ENTRY(txt_source_url));
- if (!strlen(source_url)) {
- popup_error(dialog, _("Please specify a source URL."));
- continue;
- } else {
- g_free(_route_dl_url);
- _route_dl_url = g_strdup(source_url);
- }
+ from_escaped = gnome_vfs_escape_string(from);
+ to_escaped = gnome_vfs_escape_string(to);
+ g_snprintf(buffer, sizeof(buffer), source_url, from_escaped, to_escaped);
+ g_free(from_escaped);
+ g_free(to_escaped);
+
+ /* Attempt to download the route from the server. */
+ MACRO_CURL_EASY_INIT(curl_easy);
+ curl_easy_setopt(curl_easy, CURLOPT_URL, buffer);
+ curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
+ curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, &rdl_data);
+ if (CURLE_OK != curl_easy_perform(curl_easy)) {
+ popup_error(dialog, _("Failed to connect to GPX Directions server"));
+ curl_easy_cleanup(curl_easy);
+ g_free(rdl_data.bytes);
+ /* Let them try again */
+ continue;
+ }
+ curl_easy_cleanup(curl_easy);
+
+ if (strncmp(rdl_data.bytes, "<?xml", strlen("<?xml"))) {
+ /* Not an XML document - must be bad locations. */
+ popup_error(dialog,
+ _("Could not generate directions. Make sure your "
+ "source and destination are valid."));
+ g_free(rdl_data.bytes);
+ /* Let them try again. */
+ }
+ /* Else, if GPS is enabled, replace the route, otherwise append it. */
+ else if (parse_gpx(&_route, rdl_data.bytes, rdl_data.bytes_read,
+ (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(oti.rad_use_gps)) ? 0 : 1))) {
+ GtkTreeIter iter;
- from = gtk_entry_get_text(GTK_ENTRY(oti.txt_from));
- if (!strlen(from)) {
- popup_error(dialog,
- _("Please specify a start location."));
- continue;
- }
+ /* Find the nearest route point, if we're connected. */
+ route_find_nearest_point();
- to = gtk_entry_get_text(GTK_ENTRY(oti.txt_to));
- if (!strlen(to)) {
- popup_error(dialog,
- _("Please specify an end location."));
- continue;
- }
+ /* Cancel any autoroute that might be occurring. */
+ cancel_autoroute(FALSE);
- from_escaped = gnome_vfs_escape_string(from);
- to_escaped = gnome_vfs_escape_string(to);
- snprintf(buffer, sizeof(buffer), source_url, from_escaped,
- to_escaped);
- g_free(from_escaped);
- g_free(to_escaped);
-
- /* Attempt to download the route from the server. */
- MACRO_CURL_EASY_INIT(curl_easy);
- curl_easy_setopt(curl_easy, CURLOPT_URL, buffer);
- curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
- curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, &rdl_data);
- if (CURLE_OK != curl_easy_perform(curl_easy)) {
- popup_error(dialog,
- _("Failed to connect to GPX Directions server"));
- curl_easy_cleanup(curl_easy);
- g_free(rdl_data.bytes);
- /* Let them try again */
- continue;
- }
- curl_easy_cleanup(curl_easy);
+ map_force_redraw();
- if (strncmp(rdl_data.bytes, "<?xml", strlen("<?xml"))) {
- /* Not an XML document - must be bad locations. */
- popup_error(dialog,
- _("Could not generate directions. Make sure your "
- "source and destination are valid."));
- g_free(rdl_data.bytes);
- /* Let them try again. */
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(oti.chk_auto))) {
+ /* Kick off a timeout to start the first update. */
+ _autoroute_data.dest = gnome_vfs_escape_string(to);
+ _autoroute_data.enabled = TRUE;
}
- /* Else, if GPS is enabled, replace the route, otherwise append it. */
- else if (parse_gpx(&_route, rdl_data.bytes, rdl_data.bytes_read,
- (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(oti.rad_use_gps))
- ? 0 : 1))) {
- GtkTreeIter iter;
-
- /* Find the nearest route point, if we're connected. */
- route_find_nearest_point();
-
- /* Cancel any autoroute that might be occurring. */
- cancel_autoroute(FALSE);
-
- map_force_redraw();
-
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(oti.chk_auto))) {
- /* Kick off a timeout to start the first update. */
- _autoroute_data.dest = gnome_vfs_escape_string(to);
- _autoroute_data.enabled = TRUE;
- }
- /* Save Origin in Route Locations list if not from GPS. */
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps))
- && !g_slist_find_custom(_loc_list, from, (GCompareFunc) strcmp)) {
- _loc_list = g_slist_prepend(_loc_list, g_strdup(from));
- gtk_list_store_insert_with_values(_loc_model,
- &iter, INT_MAX, 0, from, -1);
- }
+ /* Save Origin in Route Locations list if not from GPS. */
+ if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps))
+ && !g_slist_find_custom(_loc_list, from, (GCompareFunc) strcmp)) {
+ _loc_list = g_slist_prepend(_loc_list, g_strdup(from));
+ gtk_list_store_insert_with_values(_loc_model, &iter, INT_MAX, 0, from, -1);
+ }
- /* Save Destination in Route Locations list. */
- if (!g_slist_find_custom(_loc_list, to, (GCompareFunc) strcmp)) {
- _loc_list = g_slist_prepend(_loc_list, g_strdup(to));
- gtk_list_store_insert_with_values(_loc_model,
- &iter,
- INT_MAX, 0,
- to, -1);
- }
+ /* Save Destination in Route Locations list. */
+ if (!g_slist_find_custom(_loc_list, to, (GCompareFunc) strcmp)) {
+ _loc_list = g_slist_prepend(_loc_list, g_strdup(to));
+ gtk_list_store_insert_with_values(_loc_model, &iter, INT_MAX, 0, to, -1);
+ }
- MACRO_BANNER_SHOW_INFO(_window, _("Route Downloaded"));
- g_free(rdl_data.bytes);
+ MACRO_BANNER_SHOW_INFO(_window, _("Route Downloaded"));
+ g_free(rdl_data.bytes);
+ route_set_destination_from_last();
- /* Success! Get out of the while loop. */
- break;
- } else {
- popup_error(dialog, _("Error parsing GPX file."));
- g_free(rdl_data.bytes);
- /* Let them try again. */
- }
+ /* Success! Get out of the while loop. */
+ break;
+ } else {
+ popup_error(dialog, _("Error parsing GPX file."));
+ g_free(rdl_data.bytes);
+ /* Let them try again. */
}
+}
- gtk_widget_hide(dialog); /* Destroying causes a crash (!?!?!??!) */
+gtk_widget_hide(dialog); /* Destroying causes a crash (!?!?!??!) */
- vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
- return TRUE;
+return TRUE;
}
WayPoint *
find_nearest_waypoint(guint unitx, guint unity)
{
- WayPoint *wcurr;
- WayPoint *wnear;
- guint64 nearest_squared;
- Point pos = { unitx, unity, 0, NAN };
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- wcurr = wnear = _route.whead;
- if (wcurr && 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;
- }
+WayPoint *wcurr;
+WayPoint *wnear;
+guint64 nearest_squared;
+Point pos = { unitx, unity, 0, NAN };
+
+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) {
- /* 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;
- }
+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."));
+MACRO_BANNER_SHOW_INFO(_window, _("There are no waypoints."));
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
- return NULL;
+return NULL;
}
/**
gboolean
route_update_nears(gboolean quick)
{
- gboolean ret = FALSE;
- Point *curr, *near;
- WayPoint *wcurr, *wnext;
- guint64 near_dist_squared;
- printf("%s(%d)\n", __PRETTY_FUNCTION__, quick);
-
- /* If we have waypoints (_next_way != NULL), then determine the "next
- * waypoint", which is defined as the waypoint after the nearest point,
- * UNLESS we've passed that waypoint, in which case the waypoint after
- * that waypoint becomes the "next" waypoint. */
- if (_next_way) {
- /* First, set near_dist_squared with the new distance from
- * _near_point. */
- near = _near_point;
- near_dist_squared = DISTANCE_SQUARED(_pos, *near);
-
- /* Now, search _route for a closer point. If quick is TRUE, then we'll
- * only search forward, only as long as we keep finding closer points.
- */
- for (curr = _near_point; curr++ != _route.tail;) {
- if (curr->unity) {
- guint dist_squared =
- DISTANCE_SQUARED(_pos, *curr);
- if (dist_squared <= near_dist_squared) {
- near = curr;
- near_dist_squared = dist_squared;
- } else if (quick)
- break;
- }
- }
-
- /* Update _near_point. */
- _near_point = near;
- _near_point_dist_squared = near_dist_squared;
-
- for (wnext = wcurr = _next_way; wcurr != _route.wtail; wcurr++) {
- if (wcurr->point < near
- /* Okay, this else if expression warrants explanation. If the
- * nearest track point happens to be a waypoint, then we want to
- * check if we have "passed" that waypoint. To check this, we
- * test the distance from _pos to the waypoint and from _pos to
- * _next_wpt, and if the former is increasing and the latter is
- * decreasing, then we have passed the waypoint, and thus we
- * should skip it. Note that if there is no _next_wpt, then
- * there is no next waypoint, so we do not skip it in that case. */
- || (wcurr->point == near && quick
- && (_next_wpt
- && (DISTANCE_SQUARED(_pos, *near) >
- _next_way_dist_squared
- && DISTANCE_SQUARED(_pos, *_next_wpt)
- < _next_wpt_dist_squared))))
- wnext = wcurr + 1;
- else
+gboolean ret = FALSE;
+Point *curr, *near;
+WayPoint *wcurr, *wnext;
+guint64 near_dist_squared;
+
+/* If we have waypoints (_next_way != NULL), then determine the "next
+ * waypoint", which is defined as the waypoint after the nearest point,
+ * UNLESS we've passed that waypoint, in which case the waypoint after
+ * that waypoint becomes the "next" waypoint. */
+if (_next_way) {
+ /* First, set near_dist_squared with the new distance from
+ * _near_point. */
+ near = _near_point;
+ near_dist_squared = DISTANCE_SQUARED(_gps->data, *near);
+
+ /* Now, search _route for a closer point. If quick is TRUE, then we'll
+ * only search forward, only as long as we keep finding closer points.
+ */
+ for (curr = _near_point; curr++ != _route.tail;) {
+ if (curr->unity) {
+ guint dist_squared = DISTANCE_SQUARED(_gps->data, *curr);
+ if (dist_squared <= near_dist_squared) {
+ near = curr;
+ near_dist_squared = dist_squared;
+ } else if (quick)
break;
}
+ }
- if (wnext == _route.wtail && (wnext->point < near
- || (wnext->point == near && quick
- && (_next_wpt
- &&
- (DISTANCE_SQUARED
- (_pos,
- *near) >
- _next_way_dist_squared
- && DISTANCE_SQUARED(_pos,
- *_next_wpt)
- <
- _next_wpt_dist_squared)))))
- {
- _next_way = NULL;
- _next_wpt = NULL;
- _next_way_dist_squared = -1;
- _next_wpt_dist_squared = -1;
- ret = TRUE;
- }
- /* Only update _next_way (and consequently _next_wpt) if _next_way is
- * different, and record that fact for return. */
- else {
- if (!quick || _next_way != wnext) {
- _next_way = wnext;
- _next_wpt = wnext->point;
- if (_next_wpt == _route.tail)
- _next_wpt = NULL;
- else {
- while (!(++_next_wpt)->unity) {
- if (_next_wpt == _route.tail) {
- _next_wpt = NULL;
- break;
- }
+ /* Update _near_point. */
+ _near_point = near;
+ _near_point_dist_squared = near_dist_squared;
+
+ for (wnext = wcurr = _next_way; wcurr != _route.wtail; wcurr++) {
+ if (wcurr->point < near || (wcurr->point == near && quick
+ && (_next_wpt && (DISTANCE_SQUARED(_gps->data, *near) > _next_way_dist_squared
+ && DISTANCE_SQUARED(_gps->data, *_next_wpt) < _next_wpt_dist_squared))))
+ /* Okay, this else if expression warrants explanation. If the
+ * nearest track point happens to be a waypoint, then we want to
+ * check if we have "passed" that waypoint. To check this, we
+ * test the distance from _gps to the waypoint and from _gps to
+ * _next_wpt, and if the former is increasing and the latter is
+ * decreasing, then we have passed the waypoint, and thus we
+ * should skip it. Note that if there is no _next_wpt, then
+ * there is no next waypoint, so we do not skip it in that case. */
+ wnext = wcurr + 1;
+ else
+ break;
+ }
+
+ if (wnext == _route.wtail && (wnext->point < near || (wnext->point == near && quick
+ && (_next_wpt && (DISTANCE_SQUARED (_gps->data, *near) > _next_way_dist_squared
+ && DISTANCE_SQUARED(_gps->data, *_next_wpt) < _next_wpt_dist_squared)))))
+ {
+ _next_way = NULL;
+ _next_wpt = NULL;
+ _next_way_dist_squared = -1;
+ _next_wpt_dist_squared = -1;
+ ret = TRUE;
+ }
+ /* Only update _next_way (and consequently _next_wpt) if _next_way is
+ * different, and record that fact for return. */
+ else {
+ if (!quick || _next_way != wnext) {
+ _next_way = wnext;
+ _next_wpt = wnext->point;
+ if (_next_wpt == _route.tail)
+ _next_wpt = NULL;
+ else {
+ while (!(++_next_wpt)->unity) {
+ if (_next_wpt == _route.tail) {
+ _next_wpt = NULL;
+ break;
}
}
- ret = TRUE;
}
- _next_way_dist_squared =
- DISTANCE_SQUARED(_pos, *wnext->point);
- if (_next_wpt)
- _next_wpt_dist_squared =
- DISTANCE_SQUARED(_pos, *_next_wpt);
+ ret = TRUE;
}
+ _next_way_dist_squared = DISTANCE_SQUARED(_gps->data, *wnext->point);
+ if (_next_wpt)
+ _next_wpt_dist_squared = DISTANCE_SQUARED(_gps->data, *_next_wpt);
}
-
- vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, ret);
- return ret;
+}
+return ret;
}
/**
void
route_find_nearest_point()
{
- printf("%s()\n", __PRETTY_FUNCTION__);
+/* Initialize _near_point to first non-zero point. */
+_near_point = _route.head;
+while (!_near_point->unity && _near_point != _route.tail)
+ _near_point++;
- /* Initialize _near_point to first non-zero point. */
- _near_point = _route.head;
- while (!_near_point->unity && _near_point != _route.tail)
- _near_point++;
-
- /* Initialize _next_way. */
- if (_route.wtail == _route.whead - 1
- || (_autoroute_data.enabled && _route.wtail == _route.whead))
- _next_way = NULL;
- else
- /* We have at least one waypoint. */
- _next_way =
- (_autoroute_data.enabled ? _route.whead + 1 : _route.whead);
- _next_way_dist_squared = -1;
+/* Initialize _next_way. */
+if (_route.wtail == _route.whead - 1 || (_autoroute_data.enabled && _route.wtail == _route.whead))
+ _next_way = NULL;
+else
+ /* We have at least one waypoint. */
+ _next_way = (_autoroute_data.enabled ? _route.whead + 1 : _route.whead);
- /* Initialize _next_wpt. */
- _next_wpt = NULL;
- _next_wpt_dist_squared = -1;
+_next_way_dist_squared = -1;
- route_update_nears(FALSE);
+/* Initialize _next_wpt. */
+_next_wpt = NULL;
+_next_wpt_dist_squared = -1;
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+route_update_nears(FALSE);
}
/**
* next waypoint.
*/
gboolean
-route_show_distance_to(Point * point)
+route_show_distance_to(Point *point)
{
- gchar buffer[80];
- gfloat lat1, lon1, lat2, lon2;
- gdouble sum = 0.0;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- /* If point is NULL, use the next waypoint. */
- if (point == NULL && _next_way)
- point = _next_way->point;
-
- /* If point is still NULL, return an error. */
- if (point == NULL) {
- printf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
- return FALSE;
- }
+gchar buffer[80];
+gdouble lat1, lon1, lat2, lon2;
+gdouble sum = 0.0;
- unit2latlon(_pos.unitx, _pos.unity, lat1, lon1);
- if (point > _near_point) {
- Point *curr;
- /* Skip _near_point in case we have already passed it. */
- for (curr = _near_point + 1; curr <= point; ++curr) {
- if (curr->unity) {
- unit2latlon(curr->unitx, curr->unity, lat2,
- lon2);
- sum += calculate_distance(lat1, lon1, lat2, lon2);
- lat1 = lat2;
- lon1 = lon2;
- }
+/* If point is NULL, use the next waypoint. */
+if (point == NULL && _next_way)
+ point = _next_way->point;
+
+/* If point is still NULL, return an error. */
+if (point == NULL)
+ return FALSE;
+
+unit2latlon(_gps->data.unitx, _gps->data.unity, lat1, lon1);
+if (point > _near_point) {
+ Point *curr;
+ /* Skip _near_point in case we have already passed it. */
+ for (curr = _near_point + 1; curr <= point; ++curr) {
+ if (curr->unity) {
+ unit2latlon(curr->unitx, curr->unity, lat2, lon2);
+ sum += calculate_distance(lat1, lon1, lat2, lon2);
+ lat1 = lat2;
+ lon1 = lon2;
}
- } else if (point < _near_point) {
- Point *curr;
- /* Skip _near_point in case we have already passed it. */
- for (curr = _near_point - 1; curr >= point; --curr) {
- if (curr->unity) {
- unit2latlon(curr->unitx, curr->unity, lat2,
- lon2);
- sum += calculate_distance(lat1, lon1, lat2, lon2);
- lat1 = lat2;
- lon1 = lon2;
- }
+ }
+} else if (point < _near_point) {
+ Point *curr;
+ /* Skip _near_point in case we have already passed it. */
+ for (curr = _near_point - 1; curr >= point; --curr) {
+ if (curr->unity) {
+ unit2latlon(curr->unitx, curr->unity, lat2, lon2);
+ sum += calculate_distance(lat1, lon1, lat2, lon2);
+ lat1 = lat2;
+ lon1 = lon2;
}
- } else {
- /* Waypoint _is_ the nearest point. */
- unit2latlon(_near_point->unitx, _near_point->unity, lat2, lon2);
- sum += calculate_distance(lat1, lon1, lat2, lon2);
}
+} else {
+ /* Waypoint _is_ the nearest point. */
+ unit2latlon(_near_point->unitx, _near_point->unity, lat2, lon2);
+ sum += calculate_distance(lat1, lon1, lat2, lon2);
+}
- snprintf(buffer, sizeof(buffer), "%s: %.02f %s", _("Distance"),
- sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
- MACRO_BANNER_SHOW_INFO(_window, buffer);
+g_snprintf(buffer, sizeof(buffer), "%s: %.02f %s", _("Distance"), sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+MACRO_BANNER_SHOW_INFO(_window, buffer);
- return TRUE;
- printf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+return TRUE;
}
void
route_show_distance_to_next()
{
- printf("%s()\n", __PRETTY_FUNCTION__);
+if (!route_show_distance_to(NULL)) {
+ MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
+}
+}
- if (!route_show_distance_to(NULL)) {
- MACRO_BANNER_SHOW_INFO(_window,
- _("There is no next waypoint."));
- }
- printf("%s(): return\n", __PRETTY_FUNCTION__);
+void
+route_set_destination_from_last(void)
+{
+Point *p;
+gdouble lat,lon;
+if (_route.head == _route.tail)
+ return;
+
+/* Find last non-zero point. */
+for (p = _route.tail; !p->unity; p--) {
+}
+unit2latlon(p->unitx, p->unity, lat, lon);
+_dest.valid=TRUE;
+_dest.lat=lat;
+_dest.lon=lon;
}
void
-route_show_distance_to_last()
+route_show_distance_to_last(void)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
+Point *p;
- if (_route.head != _route.tail) {
- /* Find last non-zero point. */
- Point *p;
- for (p = _route.tail; !p->unity; p--) {
- }
- route_show_distance_to(p);
- } else {
- MACRO_BANNER_SHOW_INFO(_window,
- _("The current route is empty."));
+if (_route.head != _route.tail) {
+ /* Find last non-zero point. */
+ for (p = _route.tail; !p->unity; p--) {
+ }
+ route_show_distance_to(p);
+} else {
+ MACRO_BANNER_SHOW_INFO(_window, _("The current route is empty."));
}
- printf("%s(): return\n", __PRETTY_FUNCTION__);
}
+
+/***/
+