8 #include "mapper-types.h"
29 g_slice_free(Path, p);
33 path_resize(Path *path, guint size)
35 if (path->head + size != path->cap) {
36 Point *old_head = path->head;
38 path->head = g_renew(Point, old_head, size);
39 path->cap = path->head + size;
40 if (path->head != old_head) {
41 path->tail = path->head + (path->tail - old_head);
43 /* Adjust all of the waypoints. */
44 for (curr = path->whead - 1; curr++ != path->wtail;)
45 curr->point = path->head + (curr->point - old_head);
51 path_wresize(Path *path, guint wsize)
53 if (path->whead + wsize != path->wcap) {
54 WayPoint *old_whead = path->whead;
55 path->whead = g_renew(WayPoint, old_whead, wsize);
56 path->wtail = path->whead + (path->wtail - old_whead);
57 path->wcap = path->whead + wsize;
62 path_insert_break(Path *path)
70 if (path->tail->unity) {
73 /* To mark a "waypoint" in a track, we'll add a (0, 0) point and then
74 * another instance of the most recent track point. */
75 MACRO_PATH_INCREMENT_TAIL(*path);
76 *path->tail=_point_null;
77 MACRO_PATH_INCREMENT_TAIL(*path);
78 *path->tail=path->tail[-2];
81 /* Instead of calling map_render_paths(), we'll just draw the waypoint ourselves. */
82 x1 = unit2bufx(path->tail->unitx);
83 y1 = unit2bufy(path->tail->unity);
84 map_render_waypoint(x1, y1, _gc[COLORABLE_TRACK_BREAK]);
91 * Add a text description at current point
95 path_insert_mark_text(Path *path, gchar *text)
97 MACRO_PATH_INCREMENT_WTAIL(*path);
98 path->wtail->point = path->tail;
99 path->wtail->desc = text;
103 path_generate_store(Path *path)
110 gchar tmp1[16], tmp2[16];
111 gdouble lat1, lon1, lat2, lon2;
114 if (path->whead==path->wtail)
125 unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1);
127 store=gtk_list_store_new(ROUTE_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
129 while (wcurr!=path->wtail) {
135 g_debug("No point for waypoint (%s) skipping", wcurr->desc);
140 unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
141 lat_format(_degformat, lat2, tmp1);
142 lon_format(_degformat, lon2, tmp2);
144 g_snprintf(buffer1, sizeof(buffer1), "%s,%s", tmp1, tmp2);
145 sum += calculate_distance(lat1, lon1, lat2, lon2);
146 g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
148 gtk_list_store_append(store, &iter);
149 gtk_list_store_set(store, &iter,
150 ROUTE_LATLON, buffer1,
151 ROUTE_DISTANCE, buffer2,
152 ROUTE_WAYPOINT, wcurr->desc,