]> git.street.me.uk Git - andy/viking.git/blame - src/viktrack.h
The geonamesearch should not be calling display updates.
[andy/viking.git] / src / viktrack.h
CommitLineData
50a14534
EB
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
a25c4c50
GB
25#include <time.h>
26#include <glib.h>
21700912 27#include <gtk/gtk.h>
a25c4c50
GB
28
29#include "vikcoord.h"
30
722b5481
RN
31G_BEGIN_DECLS
32
50a14534
EB
33/* todo important: put these in their own header file, maybe.probably also rename */
34
35#define VIK_TRACK(x) ((VikTrack *)(x))
36#define VIK_TRACKPOINT(x) ((VikTrackpoint *)(x))
37
38typedef struct _VikTrackpoint VikTrackpoint;
39struct _VikTrackpoint {
40 VikCoord coord;
41 gboolean newsegment;
42 gboolean has_timestamp;
43 time_t timestamp;
2d920ee9 44 gdouble altitude; /* VIK_DEFAULT_ALTITUDE if data unavailable */
2d920ee9
T
45 gdouble speed; /* NAN if data unavailable */
46 gdouble course; /* NAN if data unavailable */
47 guint nsats; /* number of satellites used. 0 if data unavailable */
a2817d3c
QT
48#define VIK_GPS_MODE_NOT_SEEN 0 /* mode update not seen yet */
49#define VIK_GPS_MODE_NO_FIX 1 /* none */
50#define VIK_GPS_MODE_2D 2 /* good for latitude/longitude */
51#define VIK_GPS_MODE_3D 3 /* good for altitude/climb too */
2d920ee9
T
52 gint fix_mode; /* VIK_GPS_MODE_NOT_SEEN if data unavailable */
53 gdouble hdop; /* VIK_DEFAULT_DOP if data unavailable */
54 gdouble vdop; /* VIK_DEFAULT_DOP if data unavailable */
55 gdouble pdop; /* VIK_DEFAULT_DOP if data unavailable */
50a14534
EB
56};
57
0d2b891f
RN
58// Instead of having a separate VikRoute type, routes are considered tracks
59// Thus all track operations must cope with a 'route' version
60// [track functions handle having no timestamps anyway - so there is no practical difference in most cases]
61// This is simpler than having to rewrite particularly every track function for route version
62// given that they do the same things
63// Mostly this matters in the display in deciding where and how they are shown
50a14534
EB
64typedef struct _VikTrack VikTrack;
65struct _VikTrack {
66 GList *trackpoints;
67 gboolean visible;
0d2b891f 68 gboolean is_route;
50a14534 69 gchar *comment;
6b2f262e 70 gchar *description;
50a14534 71 guint8 ref_count;
ce4bd1cf 72 gchar *name;
b1453c16
RN
73 GtkWidget *property_dialog;
74 gboolean has_color;
75 GdkColor color;
50a14534
EB
76};
77
78VikTrack *vik_track_new();
0fa0c0b7
RN
79void vik_track_set_name(VikTrack *tr, const gchar *name);
80void vik_track_set_comment(VikTrack *tr, const gchar *comment);
6b2f262e 81void vik_track_set_description(VikTrack *tr, const gchar *description);
50a14534
EB
82void vik_track_ref(VikTrack *tr);
83void vik_track_free(VikTrack *tr);
03817fbf 84VikTrack *vik_track_copy ( const VikTrack *tr, gboolean copy_points );
50a14534
EB
85void vik_track_set_comment_no_copy(VikTrack *tr, gchar *comment);
86VikTrackpoint *vik_trackpoint_new();
87void vik_trackpoint_free(VikTrackpoint *tp);
88VikTrackpoint *vik_trackpoint_copy(VikTrackpoint *tp);
89gdouble vik_track_get_length(const VikTrack *tr);
90gdouble vik_track_get_length_including_gaps(const VikTrack *tr);
91gulong vik_track_get_tp_count(const VikTrack *tr);
92guint vik_track_get_segment_count(const VikTrack *tr);
93VikTrack **vik_track_split_into_segments(VikTrack *tr, guint *ret_len);
ce1c0489 94guint vik_track_merge_segments(VikTrack *tr);
50a14534
EB
95void vik_track_reverse(VikTrack *tr);
96
97gulong vik_track_get_dup_point_count ( const VikTrack *vt );
4f48c541 98gulong vik_track_remove_dup_points ( VikTrack *vt );
2a0cbd46
RN
99gulong vik_track_get_same_time_point_count ( const VikTrack *vt );
100gulong vik_track_remove_same_time_points ( VikTrack *vt );
50a14534 101
2f5d7ea1
RN
102void vik_track_to_routepoints ( VikTrack *tr );
103
50a14534
EB
104gdouble vik_track_get_max_speed(const VikTrack *tr);
105gdouble vik_track_get_average_speed(const VikTrack *tr);
4c21c2fa 106gdouble vik_track_get_average_speed_moving ( const VikTrack *tr, int stop_length_seconds );
50a14534
EB
107
108void vik_track_convert ( VikTrack *tr, VikCoordMode dest_mode );
109gdouble *vik_track_make_elevation_map ( const VikTrack *tr, guint16 num_chunks );
110void vik_track_get_total_elevation_gain(const VikTrack *tr, gdouble *up, gdouble *down);
ddc2372e
QT
111VikTrackpoint *vik_track_get_closest_tp_by_percentage_dist ( VikTrack *tr, gdouble reldist, gdouble *meters_from_start );
112VikTrackpoint *vik_track_get_closest_tp_by_percentage_time ( VikTrack *tr, gdouble reldist, time_t *seconds_from_start );
03e7da75 113VikTrackpoint *vik_track_get_tp_by_max_speed ( const VikTrack *tr );
c28faca8
RN
114VikTrackpoint *vik_track_get_tp_by_max_alt ( const VikTrack *tr );
115VikTrackpoint *vik_track_get_tp_by_min_alt ( const VikTrack *tr );
0ba33e1d 116gdouble *vik_track_make_gradient_map ( const VikTrack *tr, guint16 num_chunks );
25e44eac 117gdouble *vik_track_make_speed_map ( const VikTrack *tr, guint16 num_chunks );
926c8140 118gdouble *vik_track_make_distance_map ( const VikTrack *tr, guint16 num_chunks );
8de26632 119gdouble *vik_track_make_elevation_time_map ( const VikTrack *tr, guint16 num_chunks );
7b624086 120gdouble *vik_track_make_speed_dist_map ( const VikTrack *tr, guint16 num_chunks );
b42a25ba 121gboolean vik_track_get_minmax_alt ( const VikTrack *tr, gdouble *min_alt, gdouble *max_alt );
ddc47a46
AF
122void vik_track_marshall ( VikTrack *tr, guint8 **data, guint *len);
123VikTrack *vik_track_unmarshall (guint8 *data, guint datalen);
24d5c7e2 124
55906514 125void vik_track_apply_dem_data ( VikTrack *tr);
e85535ea
RN
126/*
127 * Apply DEM data (if available) - to only the last trackpoint
128 */
129void vik_track_apply_dem_data_last_trackpoint ( VikTrack *tr );
bddd2056
EB
130
131/* appends t2 to t1, leaving t2 with no trackpoints */
132void vik_track_steal_and_append_trackpoints ( VikTrack *t1, VikTrack *t2 );
ad0a8c2d 133
c3deba01 134/* starting at the end, looks backwards for the last "double point", a duplicate trackpoint.
7ff7d728
RN
135 * If there is no double point, deletes all the trackpoints.
136 * Returns the new end of the track (or the start if there are no double points
c3deba01
EB
137 */
138VikCoord *vik_track_cut_back_to_double_point ( VikTrack *tr );
139
21700912
QT
140void vik_track_set_property_dialog(VikTrack *tr, GtkWidget *dialog);
141void vik_track_clear_property_dialog(VikTrack *tr);
ad0a8c2d 142
722b5481
RN
143G_END_DECLS
144
50a14534 145#endif