From: Kaj-Michael Lang Date: Thu, 22 May 2008 07:36:17 +0000 (+0300) Subject: Path: More fixes and adjustments X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d45ed742d781ae1fd7e974a511719d02bd81cd09;p=mapper Path: More fixes and adjustments --- diff --git a/src/mapper-types.h b/src/mapper-types.h index 1be33ac..a0da73c 100644 --- a/src/mapper-types.h +++ b/src/mapper-types.h @@ -7,16 +7,6 @@ #include #include -/* Route list */ -typedef enum { - ROUTE_LATLON, - ROUTE_DISTANCE, - ROUTE_WAYPOINT, - ROUTE_LAT, - ROUTE_LON, - ROUTE_NUM_COLUMNS -} RouteList; - /** This enum defines the possible font sizes. */ typedef enum { INFO_FONT_XXSMALL, diff --git a/src/path.c b/src/path.c index c833aba..8c1567a 100644 --- a/src/path.c +++ b/src/path.c @@ -19,13 +19,13 @@ */ #include +#include #include +#include -#include "mapper-types.h" #include "path.h" +#include "position.h" #include "utils.h" -#include "track.h" -#include "route.h" #include "gps.h" #include "settings.h" #include "latlon.h" @@ -540,7 +540,7 @@ path_set_destination_from_last(Path *path, Position *pos) Point *p; gdouble lat,lon; -g_return_val_if_fail(route, FALSE); +g_return_val_if_fail(path, FALSE); g_return_val_if_fail(pos, FALSE); if (path->head==path->tail) { @@ -548,7 +548,7 @@ if (path->head==path->tail) { return FALSE; } -p=path_find_last_point(route); +p=path_find_last_point(path); if (p) { unit2latlon(p->unitx, p->unity, &lat, &lon); position_set(pos, TRUE, lat, lon, 0); @@ -614,11 +614,11 @@ g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UN gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, - ROUTE_LATLON, buffer1, - ROUTE_DISTANCE, buffer2, - ROUTE_WAYPOINT, wcurr->desc, - ROUTE_LAT, lat2, - ROUTE_LON, lon2, + PATH_LATLON, buffer1, + PATH_DISTANCE, buffer2, + PATH_WAYPOINT, wcurr->desc, + PATH_LAT, lat2, + PATH_LON, lon2, -1); lat1=lat2; @@ -650,7 +650,7 @@ g_return_val_if_fail(wcurr->point!=NULL, NULL); if (!path_has_waypoints(path)) return NULL; -store=gtk_list_store_new(ROUTE_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE); +store=gtk_list_store_new(PATH_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE); unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1); @@ -674,11 +674,11 @@ while (wcurr!=path->wtail) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, - ROUTE_LATLON, buffer1, - ROUTE_DISTANCE, buffer2, - ROUTE_WAYPOINT, wcurr->desc, - ROUTE_LAT, lat2, - ROUTE_LON, lon2, + PATH_LATLON, buffer1, + PATH_DISTANCE, buffer2, + PATH_WAYPOINT, wcurr->desc, + PATH_LAT, lat2, + PATH_LON, lon2, -1); lat1=lat2; diff --git a/src/path.h b/src/path.h index 213724a..b0c5ff2 100644 --- a/src/path.h +++ b/src/path.h @@ -40,6 +40,17 @@ typedef enum { PATH_TYPE_FRIEND, } PathType; +/* Path store items */ +typedef enum { + PATH_LATLON, + PATH_DISTANCE, + PATH_WAYPOINT, + PATH_LAT, + PATH_LON, + PATH_NUM_COLUMNS +} PathStoreList; + + /* Fixed ID's */ #define PATH_ID_MY_TRACK (1) #define PATH_ID_MY_ROUTE (2) @@ -155,6 +166,7 @@ gboolean path_wresize(Path *path, guint wsize); gdouble path_get_distance_to(Path *path, Point *point, gdouble lat, gdouble lon); +void path_find_nearest_point(Path *path); gboolean path_update_nears(Path *route, Point *point, gboolean quick); gboolean path_insert_break(Path *path); diff --git a/src/route.c b/src/route.c index 04173ad..5347024 100644 --- a/src/route.c +++ b/src/route.c @@ -539,7 +539,7 @@ gdouble sum; g_return_val_if_fail(route, FALSE); g_return_val_if_fail(point, FALSE); -unit2latlon(_gps->data.unitx, _gps->data.unity, lat, lon); +unit2latlon(point->unitx, point->unity, &lat, &lon); sum=path_get_distance_to(route, point, lat, lon); g_snprintf(buffer, sizeof(buffer), "%s: %.02f %s", _("Distance"), sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]); MACRO_BANNER_SHOW_INFO(_window, buffer); diff --git a/src/ui-common.c b/src/ui-common.c index 90f875f..a44d641 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -575,15 +575,15 @@ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE); renderer=gtk_cell_renderer_text_new(); -column=gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", ROUTE_LATLON, NULL); +column=gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", PATH_LATLON, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); renderer=gtk_cell_renderer_text_new(); -column=gtk_tree_view_column_new_with_attributes(_("Distance"), renderer, "text", ROUTE_DISTANCE, NULL); +column=gtk_tree_view_column_new_with_attributes(_("Distance"), renderer, "text", PATH_DISTANCE, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); renderer=gtk_cell_renderer_text_new(); -column=gtk_tree_view_column_new_with_attributes(_("Waypoint"), renderer, "text", ROUTE_WAYPOINT, NULL); +column=gtk_tree_view_column_new_with_attributes(_("Waypoint"), renderer, "text", PATH_WAYPOINT, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); return tree_view;