* redrawn.
*/
void
-map_render_path(Path * path, GdkGC ** gc)
+map_render_path(Path *path, GdkGC **gc)
{
Point *curr;
WayPoint *wcurr;
+g_return_if_fail(path);
+if (path->head==path->tail)
+ return;
+
/* gc is a pointer to the first GC to use (for plain points). (gc + 1)
* is a pointer to the GC to use for waypoints, and (gc + 2) is a pointer
* to the GC to use for breaks. */
}
}
+void
+map_render_next_waypoint(Path *path)
+{
+guint x1, y1;
+
+g_return_if_fail(path);
+if (!path->next_way)
+ return;
+
+g_return_if_fail(path->next_way->point);
+
+x1=unit2bufx(path->next_way->point->unitx);
+y1=unit2bufy(path->next_way->point->unity);
+
+if ((x1 < buf_width_pixels) && (y1 < buf_height_pixels)) {
+ /* Draw the next waypoint as a break. */
+ gdk_draw_arc(map_pixmap, _gc[COLORABLE_ROUTE_BREAK], FALSE,
+ x1 - _draw_width, y1 - _draw_width,
+ 4 * _draw_width, 4 * _draw_width, 0, 360 * 64);
+}
+}
+
void
map_render_paths(void)
{
-if ((_show_tracks & ROUTES_MASK) && _route->head != _route->tail) {
+if (_show_tracks & ROUTES_MASK) {
map_render_path(_route, _gc + COLORABLE_ROUTE);
/* Now, draw the next waypoint on top of all other waypoints. */
- if (_next_way) {
- guint x1 = unit2bufx(_next_way->point->unitx);
- guint y1 = unit2bufy(_next_way->point->unity);
-
- if ((x1 < buf_width_pixels) && (y1 < buf_height_pixels)) {
- /* Draw the next waypoint as a break. */
- gdk_draw_arc(map_pixmap, _gc[COLORABLE_ROUTE_BREAK], FALSE, /* FALSE: not filled. */
- x1 - _draw_width, y1 - _draw_width, 4 * _draw_width, 4 * _draw_width, 0, /* start at 0 degrees. */
- 360 * 64);
- }
- }
+ map_render_next_waypoint(_route);
}
if (_show_tracks & TRACKS_MASK)
map_render_path(_track, _gc + COLORABLE_TRACK);
gtk_compass_set_dest_heading(_gps_compass, _dest.valid, (gfloat)dh);
gtk_compass_set_dest_heading(_tab_compass, _dest.valid, (gfloat)dh);
-if (_next_way && _next_way->point) {
+if (_route->next_way && _route->next_way->point) {
gdouble wp_lat, wp_lon;
gfloat wc;
- unit2latlon(_next_way->point->unitx,_next_way->point->unity, wp_lat, wp_lon);
+ unit2latlon(_route->next_way->point->unitx, _route->next_way->point->unity, wp_lat, wp_lon);
wc=calculate_course(lat, lon, wp_lat, wp_lon);
gtk_compass_set_way_heading(_gps_compass, TRUE, wc);
gtk_compass_set_way_heading(_tab_compass, TRUE, wc);
if (!_announce_waypoints)
return;
-if (!_next_way)
+if (!route->next_way)
return;
announce_thres_unsquared=(20+(guint)gps->speed)*_announce_notice_ratio*3;
-if (_next_way_dist_squared<(announce_thres_unsquared * announce_thres_unsquared) && _next_way!=announced_waypoint) {
- announce_waypoint(_next_way->desc);
- announced_waypoint=_next_way;
+if (route->next_way_dist_squared<(announce_thres_unsquared * announce_thres_unsquared) && route->next_way!=announced_waypoint) {
+ announce_waypoint(route->next_way->desc);
+ announced_waypoint=route->next_way;
}
}
void
route_autoroute_check(Path *route)
{
-if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
+if (_autoroute_data.enabled && !_autoroute_data.in_progress && route->near_point_dist_squared > 400) {
MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
_autoroute_data.in_progress = TRUE;
show_directions = FALSE;
}
/**
- * Updates _near_point, _next_way, and _next_wpt. If quick is FALSE (as
+ * Updates near_point, next_way, and next_wpt. If quick is FALSE (as
* it is when this function is called from route_find_nearest_point), then
- * the entire list (starting from _near_point) is searched. Otherwise, we
+ * the entire list (starting from near_point) is searched. Otherwise, we
* stop searching when we find a point that is farther away.
*/
gboolean
* waypoint", which is defined as the waypoint after the nearest point,
* UNLESS we've passed that waypoint, in which case the waypoint after
* that waypoint becomes the "next" waypoint. */
-if (_next_way) {
+if (route->next_way) {
/* First, set near_dist_squared with the new distance from
- * _near_point. */
- near = _near_point;
+ * near_point. */
+ near = route->near_point;
near_dist_squared = DISTANCE_SQUARED(_gps->data, *near);
/* Now, search route for a closer point. If quick is TRUE, then we'll
* only search forward, only as long as we keep finding closer points.
*/
- for (curr = _near_point; curr++ != route->tail;) {
+ for (curr = route->near_point; curr++ != route->tail;) {
if (curr->unity) {
guint dist_squared = DISTANCE_SQUARED(_gps->data, *curr);
if (dist_squared <= near_dist_squared) {
}
/* Update _near_point. */
- _near_point = near;
- _near_point_dist_squared = near_dist_squared;
+ route->near_point = near;
+ route->near_point_dist_squared = near_dist_squared;
- for (wnext = wcurr = _next_way; wcurr != route->wtail; wcurr++) {
+ for (wnext = wcurr = route->next_way; wcurr != route->wtail; wcurr++) {
if (wcurr->point < near || (wcurr->point == near && quick
- && (_next_wpt && (DISTANCE_SQUARED(_gps->data, *near) > _next_way_dist_squared
- && DISTANCE_SQUARED(_gps->data, *_next_wpt) < _next_wpt_dist_squared))))
+ && (route->next_wpt && (DISTANCE_SQUARED(_gps->data, *near) > route->next_way_dist_squared
+ && DISTANCE_SQUARED(_gps->data, *route->next_wpt) < route->next_wpt_dist_squared))))
/* Okay, this else if expression warrants explanation. If the
* nearest track point happens to be a waypoint, then we want to
* check if we have "passed" that waypoint. To check this, we
}
if (wnext == route->wtail && (wnext->point < near || (wnext->point == near && quick
- && (_next_wpt && (DISTANCE_SQUARED (_gps->data, *near) > _next_way_dist_squared
- && DISTANCE_SQUARED(_gps->data, *_next_wpt) < _next_wpt_dist_squared)))))
+ && (route->next_wpt && (DISTANCE_SQUARED (_gps->data, *near) > route->next_way_dist_squared
+ && DISTANCE_SQUARED(_gps->data, *route->next_wpt) < route->next_wpt_dist_squared)))))
{
- _next_way = NULL;
- _next_wpt = NULL;
- _next_way_dist_squared = -1;
- _next_wpt_dist_squared = -1;
+ route->next_way = NULL;
+ route->next_wpt = NULL;
+ route->next_way_dist_squared = -1;
+ route->next_wpt_dist_squared = -1;
ret = TRUE;
}
- /* Only update _next_way (and consequently _next_wpt) if _next_way is
+ /* Only update next_way (and consequently _next_wpt) if _next_way is
* different, and record that fact for return. */
else {
- if (!quick || _next_way != wnext) {
- _next_way = wnext;
- _next_wpt = wnext->point;
- if (_next_wpt == route->tail)
- _next_wpt = NULL;
+ if (!quick || route->next_way != wnext) {
+ route->next_way = wnext;
+ route->next_wpt = wnext->point;
+ if (route->next_wpt == route->tail)
+ route->next_wpt = NULL;
else {
- while (!(++_next_wpt)->unity) {
- if (_next_wpt == route->tail) {
- _next_wpt = NULL;
+ while (!(++route->next_wpt)->unity) {
+ if (route->next_wpt == route->tail) {
+ route->next_wpt = NULL;
break;
}
}
}
ret = TRUE;
}
- _next_way_dist_squared = DISTANCE_SQUARED(_gps->data, *wnext->point);
- if (_next_wpt)
- _next_wpt_dist_squared = DISTANCE_SQUARED(_gps->data, *_next_wpt);
+ route->next_way_dist_squared = DISTANCE_SQUARED(_gps->data, *wnext->point);
+ if (route->next_wpt)
+ route->next_wpt_dist_squared = DISTANCE_SQUARED(_gps->data, *route->next_wpt);
}
}
return ret;
}
/**
- * Reset the _near_point data by searching the entire route for the nearest
+ * Reset the near_point data by searching the entire route for the nearest
* route point and waypoint.
*/
void
route_find_nearest_point(Path *route)
{
-/* Initialize _near_point to first non-zero point. */
-_near_point = route->head;
-while (!_near_point->unity && _near_point != route->tail)
- _near_point++;
+/* Initialize near_point to first non-zero point. */
+route->near_point = route->head;
+while (!route->near_point->unity && route->near_point != route->tail)
+ route->near_point++;
-/* Initialize _next_way. */
+/* Initialize next_way. */
if (route->wtail == route->whead - 1 || (_autoroute_data.enabled && route->wtail == route->whead))
- _next_way = NULL;
+ route->next_way = NULL;
else
/* We have at least one waypoint. */
- _next_way = (_autoroute_data.enabled ? route->whead + 1 : route->whead);
+ route->next_way = (_autoroute_data.enabled ? route->whead + 1 : route->whead);
-_next_way_dist_squared = -1;
+route->next_way_dist_squared = -1;
/* Initialize _next_wpt. */
-_next_wpt = NULL;
-_next_wpt_dist_squared = -1;
+route->next_wpt = NULL;
+route->next_wpt_dist_squared = -1;
route_update_nears(route, FALSE);
}