From: Kaj-Michael Lang Date: Wed, 13 Feb 2008 12:29:40 +0000 (+0200) Subject: Move route_generate_store from route.c to path.c and rename to path_generate_store X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8d1dc60a0f60b4a8444dbe19903456300ee36d5;p=mapper Move route_generate_store from route.c to path.c and rename to path_generate_store --- diff --git a/src/cb.c b/src/cb.c index e846a08..28f2696 100644 --- a/src/cb.c +++ b/src/cb.c @@ -67,7 +67,7 @@ track_tree_view_update_store(GtkWidget *tree_view, Path *track) { GtkListStore *store; -store=route_generate_store(track); +store=path_generate_store(track); if (store!=NULL) { gtk_tree_view_set_model(tree_view, store); g_object_unref(G_OBJECT(store)); diff --git a/src/path.c b/src/path.c index 516a095..f5002ac 100644 --- a/src/path.c +++ b/src/path.c @@ -1,12 +1,15 @@ #include +#include + #include "utils.h" #include "map.h" #include "route.h" #include "mapper-types.h" - #include "track.h" #include "path.h" +#include "settings.h" +#include "latlon.h" void path_resize(Path *path, guint size) @@ -36,3 +39,56 @@ if (path->whead + wsize != path->wcap) { path->wcap = path->whead + wsize; } } + +GtkListStore * +path_generate_store(Path *path) +{ +WayPoint *wcurr; +GtkTreeIter iter; +GtkListStore *store; +gchar buffer1[80]; +gchar buffer2[32]; +gdouble lat1, lon1, lat2, lon2; +gdouble sum=0.0; + +if (path->whead==path->wtail) + return NULL; + +wcurr=path->whead; + +if (!wcurr) + return NULL; + +if (!wcurr->point) + return NULL; + +unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1); + +store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE); + +while (wcurr!=path->wtail) { + if (!wcurr) + break; + + unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2); + g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2); + sum += calculate_distance(lat1, lon1, lat2, lon2); + g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]); + + 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, + -1); + + lat1=lat2; + lon1=lon2; + + wcurr++; +} + +return store; +} diff --git a/src/path.h b/src/path.h index 12ed0ab..cba575b 100644 --- a/src/path.h +++ b/src/path.h @@ -2,6 +2,7 @@ #define _PATH_H #include +#include #define MACRO_PATH_INIT(path) { \ (path).head = (path).tail = g_new(Point, ARRAY_CHUNK_SIZE); \ @@ -76,4 +77,6 @@ Position _dest; void path_resize(Path *path, guint size); void path_wresize(Path *path, guint wsize); +GtkListStore *path_generate_store(Path *path); + #endif diff --git a/src/route.c b/src/route.c index 18cb83b..25a859b 100644 --- a/src/route.c +++ b/src/route.c @@ -735,55 +735,3 @@ if (_route.head != _route.tail) { /***/ -GtkListStore * -route_generate_store(Path *route) -{ -WayPoint *wcurr; -GtkTreeIter iter; -GtkListStore *store; -gchar buffer1[80]; -gchar buffer2[32]; -gdouble lat1, lon1, lat2, lon2; -gdouble sum=0.0; - -if (route->whead==route->wtail) - return NULL; - -wcurr=route->whead; - -if (!wcurr) - return NULL; - -if (!wcurr->point) - return NULL; - -unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1); - -store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE); - -while (wcurr!=route->wtail) { - if (!wcurr) - break; - - unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2); - g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2); - sum += calculate_distance(lat1, lon1, lat2, lon2); - g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]); - - 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, - -1); - - lat1=lat2; - lon1=lon2; - - wcurr++; -} - -return store; -} diff --git a/src/route.h b/src/route.h index 66f2acb..ee4eae4 100644 --- a/src/route.h +++ b/src/route.h @@ -55,6 +55,4 @@ void route_show_distance_to_last(); void route_show_distance_to_next(); gboolean route_show_distance_to(Point * point); -GtkListStore *route_generate_store(Path *route); - #endif