]> git.street.me.uk Git - andy/viking.git/blob - src/viktrack.h
SF#3601584: Fix minimum vertical size for the track properties dialog.
[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   VikCoord coord;
42   gboolean newsegment;
43   gboolean has_timestamp;
44   time_t timestamp;
45   gdouble altitude;     /* VIK_DEFAULT_ALTITUDE if data unavailable */
46   gdouble speed;        /* NAN if data unavailable */
47   gdouble course;   /* NAN if data unavailable */
48   guint nsats;      /* number of satellites used. 0 if data unavailable */
49 #define VIK_GPS_MODE_NOT_SEEN   0       /* mode update not seen yet */
50 #define VIK_GPS_MODE_NO_FIX     1       /* none */
51 #define VIK_GPS_MODE_2D         2       /* good for latitude/longitude */
52 #define VIK_GPS_MODE_3D         3       /* good for altitude/climb too */
53   gint fix_mode;    /* VIK_GPS_MODE_NOT_SEEN if data unavailable */
54   gdouble hdop;     /* VIK_DEFAULT_DOP if data unavailable */
55   gdouble vdop;     /* VIK_DEFAULT_DOP if data unavailable */
56   gdouble pdop;     /* VIK_DEFAULT_DOP if data unavailable */
57 };
58
59 // Instead of having a separate VikRoute type, routes are considered tracks
60 //  Thus all track operations must cope with a 'route' version
61 //  [track functions handle having no timestamps anyway - so there is no practical difference in most cases]
62 //  This is simpler than having to rewrite particularly every track function for route version
63 //   given that they do the same things
64 //  Mostly this matters in the display in deciding where and how they are shown
65 typedef struct _VikTrack VikTrack;
66 struct _VikTrack {
67   GList *trackpoints;
68   gboolean visible;
69   gboolean is_route;
70   gchar *comment;
71   gchar *description;
72   guint8 ref_count;
73   gchar *name;
74   GtkWidget *property_dialog;
75   gboolean has_color;
76   GdkColor color;
77   LatLonBBox bbox;
78 };
79
80 VikTrack *vik_track_new();
81 void vik_track_set_name(VikTrack *tr, const gchar *name);
82 void vik_track_set_comment(VikTrack *tr, const gchar *comment);
83 void vik_track_set_description(VikTrack *tr, const gchar *description);
84 void vik_track_ref(VikTrack *tr);
85 void vik_track_free(VikTrack *tr);
86 VikTrack *vik_track_copy ( const VikTrack *tr, gboolean copy_points );
87 void vik_track_set_comment_no_copy(VikTrack *tr, gchar *comment);
88 VikTrackpoint *vik_trackpoint_new();
89 void vik_trackpoint_free(VikTrackpoint *tp);
90 VikTrackpoint *vik_trackpoint_copy(VikTrackpoint *tp);
91 gdouble vik_track_get_length(const VikTrack *tr);
92 gdouble vik_track_get_length_including_gaps(const VikTrack *tr);
93 gulong vik_track_get_tp_count(const VikTrack *tr);
94 guint vik_track_get_segment_count(const VikTrack *tr);
95 VikTrack **vik_track_split_into_segments(VikTrack *tr, guint *ret_len);
96 guint vik_track_merge_segments(VikTrack *tr);
97 void vik_track_reverse(VikTrack *tr);
98
99 gulong vik_track_get_dup_point_count ( const VikTrack *vt );
100 gulong vik_track_remove_dup_points ( VikTrack *vt );
101 gulong vik_track_get_same_time_point_count ( const VikTrack *vt );
102 gulong vik_track_remove_same_time_points ( VikTrack *vt );
103
104 void vik_track_to_routepoints ( VikTrack *tr );
105
106 gdouble vik_track_get_max_speed(const VikTrack *tr);
107 gdouble vik_track_get_average_speed(const VikTrack *tr);
108 gdouble vik_track_get_average_speed_moving ( const VikTrack *tr, int stop_length_seconds );
109
110 void vik_track_convert ( VikTrack *tr, VikCoordMode dest_mode );
111 gdouble *vik_track_make_elevation_map ( const VikTrack *tr, guint16 num_chunks );
112 void vik_track_get_total_elevation_gain(const VikTrack *tr, gdouble *up, gdouble *down);
113 VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdouble reldist, gdouble *meters_from_start );
114 VikTrackpoint *vik_track_get_closest_tp_by_percentage_time ( VikTrack *tr, gdouble reldist, time_t *seconds_from_start );
115 VikTrackpoint *vik_track_get_tp_by_max_speed ( const VikTrack *tr );
116 VikTrackpoint *vik_track_get_tp_by_max_alt ( const VikTrack *tr );
117 VikTrackpoint *vik_track_get_tp_by_min_alt ( const VikTrack *tr );
118 gdouble *vik_track_make_gradient_map ( const VikTrack *tr, guint16 num_chunks );
119 gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks );
120 gdouble *vik_track_make_distance_map ( const VikTrack *tr, guint16 num_chunks );
121 gdouble *vik_track_make_elevation_time_map ( const VikTrack *tr, guint16 num_chunks );
122 gdouble *vik_track_make_speed_dist_map ( const VikTrack *tr, guint16 num_chunks );
123 gboolean vik_track_get_minmax_alt ( const VikTrack *tr, gdouble *min_alt, gdouble *max_alt );
124 void vik_track_marshall ( VikTrack *tr, guint8 **data, guint *len);
125 VikTrack *vik_track_unmarshall (guint8 *data, guint datalen);
126
127 void vik_track_calculate_bounds ( VikTrack *trk );
128
129 void vik_track_apply_dem_data ( VikTrack *tr);
130 void vik_track_apply_dem_data_last_trackpoint ( VikTrack *tr );
131
132 void vik_track_steal_and_append_trackpoints ( VikTrack *t1, VikTrack *t2 );
133
134 VikCoord *vik_track_cut_back_to_double_point ( VikTrack *tr );
135
136 void vik_track_set_property_dialog(VikTrack *tr, GtkWidget *dialog);
137 void vik_track_clear_property_dialog(VikTrack *tr);
138
139 G_END_DECLS
140
141 #endif