]> err.no Git - mapper/commitdiff
Path: More fixes and adjustments
authorKaj-Michael Lang <milang@tal.org>
Thu, 22 May 2008 07:36:17 +0000 (10:36 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 22 May 2008 07:36:17 +0000 (10:36 +0300)
src/mapper-types.h
src/path.c
src/path.h
src/route.c
src/ui-common.c

index 1be33ac53de0ed5114e1d48f9078a559dcc48af4..a0da73c37dc145ddf6519f37f828fe5bf21e69e9 100644 (file)
@@ -7,16 +7,6 @@
 #include <gtk/gtk.h>
 #include <curl/multi.h>
 
-/* 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,
index c833abab462a92a869d1f9c650b6fe92563688d8..8c1567acfcd7d0a0b79dfcd4b2eebfbefec14ded 100644 (file)
  */
 #include <config.h>
 
+#include <glib.h>
 #include <gtk/gtk.h>
+#include <sqlite3.h>
 
-#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;
index 213724a9d2bae97cef631cee5c19664139177d15..b0c5ff2fcffa29ac475a03c6c4d93077c0a60307 100644 (file)
@@ -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);
index 04173ada78e938484768b680ba5229271d358ece..53470245301aca27f49ff835cfb18b02dc9db2b6 100644 (file)
@@ -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);
index 90f875f65ad6e23d0e4ac794a80bbf88a1c10e42..a44d641471140b3bd6bf82c6669ff3d5cc617821 100644 (file)
@@ -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;