From 6e98c901ec4cee1f613877beed76212d47a77c56 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 19 Oct 2007 14:38:22 +0300 Subject: [PATCH] Set destination to last route point. --- src/route.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/route.c b/src/route.c index 07772aa..afc3241 100644 --- a/src/route.c +++ b/src/route.c @@ -31,8 +31,10 @@ #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); -- 2.39.5