2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _VIKING_TRACK_H
23 #define _VIKING_TRACK_H
31 /* todo important: put these in their own header file, maybe.probably also rename */
33 #define VIK_TRACK(x) ((VikTrack *)(x))
34 #define VIK_TRACKPOINT(x) ((VikTrackpoint *)(x))
36 typedef struct _VikTrackpoint VikTrackpoint;
37 struct _VikTrackpoint {
40 gboolean has_timestamp;
42 gdouble altitude; /* VIK_DEFAULT_ALTITUDE if data unavailable */
43 gdouble speed; /* NAN if data unavailable */
44 gdouble course; /* NAN if data unavailable */
45 guint nsats; /* number of satellites used. 0 if data unavailable */
46 #define VIK_GPS_MODE_NOT_SEEN 0 /* mode update not seen yet */
47 #define VIK_GPS_MODE_NO_FIX 1 /* none */
48 #define VIK_GPS_MODE_2D 2 /* good for latitude/longitude */
49 #define VIK_GPS_MODE_3D 3 /* good for altitude/climb too */
50 gint fix_mode; /* VIK_GPS_MODE_NOT_SEEN if data unavailable */
51 gdouble hdop; /* VIK_DEFAULT_DOP if data unavailable */
52 gdouble vdop; /* VIK_DEFAULT_DOP if data unavailable */
53 gdouble pdop; /* VIK_DEFAULT_DOP if data unavailable */
56 typedef struct _VikTrack VikTrack;
62 GtkWidget *property_dialog;
66 VikTrack *vik_track_new();
67 void vik_track_set_name(VikTrack *wp, const gchar *name);
68 void vik_track_set_comment(VikTrack *wp, const gchar *comment);
69 void vik_track_ref(VikTrack *tr);
70 void vik_track_free(VikTrack *tr);
71 VikTrack *vik_track_copy ( const VikTrack *tr );
72 void vik_track_set_comment_no_copy(VikTrack *tr, gchar *comment);
73 VikTrackpoint *vik_trackpoint_new();
74 void vik_trackpoint_free(VikTrackpoint *tp);
75 VikTrackpoint *vik_trackpoint_copy(VikTrackpoint *tp);
76 gdouble vik_track_get_length(const VikTrack *tr);
77 gdouble vik_track_get_length_including_gaps(const VikTrack *tr);
78 gulong vik_track_get_tp_count(const VikTrack *tr);
79 guint vik_track_get_segment_count(const VikTrack *tr);
80 VikTrack **vik_track_split_into_segments(VikTrack *tr, guint *ret_len);
81 void vik_track_reverse(VikTrack *tr);
83 gulong vik_track_get_dup_point_count ( const VikTrack *vt );
84 void vik_track_remove_dup_points ( VikTrack *vt );
86 gdouble vik_track_get_max_speed(const VikTrack *tr);
87 gdouble vik_track_get_average_speed(const VikTrack *tr);
88 gdouble vik_track_get_average_speed_moving ( const VikTrack *tr, int stop_length_seconds );
90 void vik_track_convert ( VikTrack *tr, VikCoordMode dest_mode );
91 gdouble *vik_track_make_elevation_map ( const VikTrack *tr, guint16 num_chunks );
92 void vik_track_get_total_elevation_gain(const VikTrack *tr, gdouble *up, gdouble *down);
93 VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdouble reldist, gdouble *meters_from_start );
94 VikTrackpoint *vik_track_get_closest_tp_by_percentage_time ( VikTrack *tr, gdouble reldist, time_t *seconds_from_start );
95 VikTrackpoint *vik_track_get_tp_by_max_speed ( const VikTrack *tr );
96 VikTrackpoint *vik_track_get_tp_by_max_alt ( const VikTrack *tr );
97 VikTrackpoint *vik_track_get_tp_by_min_alt ( const VikTrack *tr );
98 gdouble *vik_track_make_gradient_map ( const VikTrack *tr, guint16 num_chunks );
99 gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks );
100 gdouble *vik_track_make_distance_map ( const VikTrack *tr, guint16 num_chunks );
101 gdouble *vik_track_make_elevation_time_map ( const VikTrack *tr, guint16 num_chunks );
102 gdouble *vik_track_make_speed_dist_map ( const VikTrack *tr, guint16 num_chunks );
103 gboolean vik_track_get_minmax_alt ( const VikTrack *tr, gdouble *min_alt, gdouble *max_alt );
104 void vik_track_marshall ( VikTrack *tr, guint8 **data, guint *len);
105 VikTrack *vik_track_unmarshall (guint8 *data, guint datalen);
107 void vik_track_apply_dem_data ( VikTrack *tr);
109 * Apply DEM data (if available) - to only the last trackpoint
111 void vik_track_apply_dem_data_last_trackpoint ( VikTrack *tr );
113 /* appends t2 to t1, leaving t2 with no trackpoints */
114 void vik_track_steal_and_append_trackpoints ( VikTrack *t1, VikTrack *t2 );
116 /* starting at the end, looks backwards for the last "double point", a duplicate trackpoint.
117 * If there is no double point, deletes all the trackpoints.
118 * Returns the new end of the track (or the start if there are no double points
120 VikCoord *vik_track_cut_back_to_double_point ( VikTrack *tr );
122 void vik_track_set_property_dialog(VikTrack *tr, GtkWidget *dialog);
123 void vik_track_clear_property_dialog(VikTrack *tr);