8 #include "mapper-types.h"
15 path_resize(Path *path, guint size)
17 if (path->head + size != path->cap) {
18 Point *old_head = path->head;
20 path->head = g_renew(Point, old_head, size);
21 path->cap = path->head + size;
22 if (path->head != old_head) {
23 path->tail = path->head + (path->tail - old_head);
25 /* Adjust all of the waypoints. */
26 for (curr = path->whead - 1; curr++ != path->wtail;)
27 curr->point = path->head + (curr->point - old_head);
33 path_wresize(Path *path, guint wsize)
35 if (path->whead + wsize != path->wcap) {
36 WayPoint *old_whead = path->whead;
37 path->whead = g_renew(WayPoint, old_whead, wsize);
38 path->wtail = path->whead + (path->wtail - old_whead);
39 path->wcap = path->whead + wsize;
44 path_generate_store(Path *path)
51 gdouble lat1, lon1, lat2, lon2;
54 if (path->whead==path->wtail)
65 unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1);
67 store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
69 while (wcurr!=path->wtail) {
76 unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
77 g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2);
78 sum += calculate_distance(lat1, lon1, lat2, lon2);
79 g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
81 gtk_list_store_append(store, &iter);
82 gtk_list_store_set(store, &iter,
83 ROUTE_LATLON, buffer1,
84 ROUTE_DISTANCE, buffer2,
85 ROUTE_WAYPOINT, wcurr->desc,