]> git.street.me.uk Git - andy/viking.git/blob - src/viktrack.h
Support GPX src field on Waypoints, Tracks and Routes.
[andy/viking.git] / src / viktrack.h
1 /*
2  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3  *
4  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef _VIKING_TRACK_H
23 #define _VIKING_TRACK_H
24
25 #include <time.h>
26 #include <glib.h>
27 #include <gtk/gtk.h>
28
29 #include "vikcoord.h"
30 #include "bbox.h"
31
32 G_BEGIN_DECLS
33
34 /* todo important: put these in their own header file, maybe.probably also rename */
35
36 #define VIK_TRACK(x) ((VikTrack *)(x))
37 #define VIK_TRACKPOINT(x) ((VikTrackpoint *)(x))
38
39 typedef struct _VikTrackpoint VikTrackpoint;
40 struct _VikTrackpoint {
41   gchar* name;
42   VikCoord coord;
43   gboolean newsegment;
44   gboolean has_timestamp;
45   time_t timestamp;
46   gdouble altitude;     /* VIK_DEFAULT_ALTITUDE if data unavailable */
47   gdouble speed;        /* NAN if data unavailable */
48   gdouble course;   /* NAN if data unavailable */
49   guint nsats;      /* number of satellites used. 0 if data unavailable */
50 #define VIK_GPS_MODE_NOT_SEEN   0       /* mode update not seen yet */
51 #define VIK_GPS_MODE_NO_FIX     1       /* none */
52 #define VIK_GPS_MODE_2D         2       /* good for latitude/longitude */
53 #define VIK_GPS_MODE_3D         3       /* good for altitude/climb too */
54 #define VIK_GPS_MODE_DGPS       4
55 #define VIK_GPS_MODE_PPS        5       /* military signal used */
56   gint fix_mode;    /* VIK_GPS_MODE_NOT_SEEN if data unavailable */
57   gdouble hdop;     /* VIK_DEFAULT_DOP if data unavailable */
58   gdouble vdop;     /* VIK_DEFAULT_DOP if data unavailable */
59   gdouble pdop;     /* VIK_DEFAULT_DOP if data unavailable */
60 };
61
62 typedef enum {
63   TRACK_DRAWNAME_NO=0,
64   TRACK_DRAWNAME_CENTRE,
65   TRACK_DRAWNAME_START,
66   TRACK_DRAWNAME_END,
67   TRACK_DRAWNAME_START_END,
68   TRACK_DRAWNAME_START_END_CENTRE,
69   NUM_TRACK_DRAWNAMES
70 } VikTrackDrawnameType;
71
72 // Instead of having a separate VikRoute type, routes are considered tracks
73 //  Thus all track operations must cope with a 'route' version
74 //  [track functions handle having no timestamps anyway - so there is no practical difference in most cases]
75 //  This is simpler than having to rewrite particularly every track function for route version
76 //   given that they do the same things
77 //  Mostly this matters in the display in deciding where and how they are shown
78 typedef struct _VikTrack VikTrack;
79 struct _VikTrack {
80   GList *trackpoints;
81   gboolean visible;
82   gboolean is_route;
83   VikTrackDrawnameType draw_name_mode;
84   guint8 max_number_dist_labels;
85   gchar *comment;
86   gchar *description;
87   gchar *source;
88   guint8 ref_count;
89   gchar *name;
90   GtkWidget *property_dialog;
91   gboolean has_color;
92   GdkColor color;
93   LatLonBBox bbox;
94 };
95
96 VikTrack *vik_track_new();
97 void vik_track_set_defaults(VikTrack *tr);
98 void vik_track_set_name(VikTrack *tr, const gchar *name);
99 void vik_track_set_comment(VikTrack *tr, const gchar *comment);
100 void vik_track_set_description(VikTrack *tr, const gchar *description);
101 void vik_track_set_source(VikTrack *tr, const gchar *source);
102 void vik_track_ref(VikTrack *tr);
103 void vik_track_free(VikTrack *tr);
104 VikTrack *vik_track_copy ( const VikTrack *tr, gboolean copy_points );
105 void vik_track_set_comment_no_copy(VikTrack *tr, gchar *comment);
106 VikTrackpoint *vik_trackpoint_new();
107 void vik_trackpoint_free(VikTrackpoint *tp);
108 VikTrackpoint *vik_trackpoint_copy(VikTrackpoint *tp);
109 void vik_trackpoint_set_name(VikTrackpoint *tp, const gchar *name);
110
111 void vik_track_add_trackpoint(VikTrack *tr, VikTrackpoint *tp, gboolean recalculate);
112 gdouble vik_track_get_length_to_trackpoint (const VikTrack *tr, const VikTrackpoint *tp);
113 gdouble vik_track_get_length(const VikTrack *tr);
114 gdouble vik_track_get_length_including_gaps(const VikTrack *tr);
115 gulong vik_track_get_tp_count(const VikTrack *tr);
116 guint vik_track_get_segment_count(const VikTrack *tr);
117 VikTrack **vik_track_split_into_segments(VikTrack *tr, guint *ret_len);
118 guint vik_track_merge_segments(VikTrack *tr);
119 void vik_track_reverse(VikTrack *tr);
120 time_t vik_track_get_duration(const VikTrack *trk, gboolean include_segments);
121
122 gulong vik_track_get_dup_point_count ( const VikTrack *vt );
123 gulong vik_track_remove_dup_points ( VikTrack *vt );
124 gulong vik_track_get_same_time_point_count ( const VikTrack *vt );
125 gulong vik_track_remove_same_time_points ( VikTrack *vt );
126
127 void vik_track_to_routepoints ( VikTrack *tr );
128
129 gdouble vik_track_get_max_speed(const VikTrack *tr);
130 gdouble vik_track_get_average_speed(const VikTrack *tr);
131 gdouble vik_track_get_average_speed_moving ( const VikTrack *tr, int stop_length_seconds );
132
133 void vik_track_convert ( VikTrack *tr, VikCoordMode dest_mode );
134 gdouble *vik_track_make_elevation_map ( const VikTrack *tr, guint16 num_chunks );
135 void vik_track_get_total_elevation_gain(const VikTrack *tr, gdouble *up, gdouble *down);
136 VikTrackpoint *vik_track_get_tp_by_dist ( VikTrack *trk, gdouble meters_from_start, gboolean get_next_point, gdouble *tp_metres_from_start );
137 VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdouble reldist, gdouble *meters_from_start );
138 VikTrackpoint *vik_track_get_closest_tp_by_percentage_time ( VikTrack *tr, gdouble reldist, time_t *seconds_from_start );
139 VikTrackpoint *vik_track_get_tp_by_max_speed ( const VikTrack *tr );
140 VikTrackpoint *vik_track_get_tp_by_max_alt ( const VikTrack *tr );
141 VikTrackpoint *vik_track_get_tp_by_min_alt ( const VikTrack *tr );
142 VikTrackpoint *vik_track_get_tp_first ( const VikTrack *tr );
143 VikTrackpoint *vik_track_get_tp_last ( const VikTrack *tr );
144 VikTrackpoint *vik_track_get_tp_prev ( const VikTrack *tr, VikTrackpoint *tp );
145 gdouble *vik_track_make_gradient_map ( const VikTrack *tr, guint16 num_chunks );
146 gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks );
147 gdouble *vik_track_make_distance_map ( const VikTrack *tr, guint16 num_chunks );
148 gdouble *vik_track_make_elevation_time_map ( const VikTrack *tr, guint16 num_chunks );
149 gdouble *vik_track_make_speed_dist_map ( const VikTrack *tr, guint16 num_chunks );
150 gboolean vik_track_get_minmax_alt ( const VikTrack *tr, gdouble *min_alt, gdouble *max_alt );
151 void vik_track_marshall ( VikTrack *tr, guint8 **data, guint *len);
152 VikTrack *vik_track_unmarshall (guint8 *data, guint datalen);
153
154 void vik_track_calculate_bounds ( VikTrack *trk );
155
156 void vik_track_anonymize_times ( VikTrack *tr );
157 void vik_track_interpolate_times ( VikTrack *tr );
158 gulong vik_track_apply_dem_data ( VikTrack *tr, gboolean skip_existing );
159 void vik_track_apply_dem_data_last_trackpoint ( VikTrack *tr );
160 gulong vik_track_smooth_missing_elevation_data ( VikTrack *tr, gboolean flat );
161
162 void vik_track_steal_and_append_trackpoints ( VikTrack *t1, VikTrack *t2 );
163
164 VikCoord *vik_track_cut_back_to_double_point ( VikTrack *tr );
165
166 int vik_track_compare_timestamp (const void *x, const void *y);
167
168 void vik_track_set_property_dialog(VikTrack *tr, GtkWidget *dialog);
169 void vik_track_clear_property_dialog(VikTrack *tr);
170
171 G_END_DECLS
172
173 #endif