]> err.no Git - mapper/commitdiff
Set destination to last route point.
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:38:22 +0000 (14:38 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:38:22 +0000 (14:38 +0300)
src/route.c

index 07772aa6aab3bab0be85e44b133a896872a4a5b4..afc3241a064e6d14e591009054911b017608ec55 100644 (file)
 #include "map-download.h"
 #include "iap.h"
 
-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 {
@@ -71,6 +73,7 @@ if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
        route_find_nearest_point();
        map_force_redraw();
 }
+_dest.valid=FALSE;
 gtk_widget_destroy(confirm);
 }
 
@@ -90,6 +93,7 @@ if (open_file(&buffer, NULL, &size, &_route_dir_uri, NULL, GTK_FILE_CHOOSER_ACTI
 
                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."));
@@ -466,6 +470,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
 
                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;
@@ -706,12 +711,30 @@ if (!route_show_distance_to(NULL)) {
 }
 }
 
+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)
 {
+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);