]> err.no Git - mapper/blob - src/mapper-types.h
434aaccd7730be731cd359467648154ab3f3d28e
[mapper] / src / mapper-types.h
1 #include "config.h"
2
3 #define _GNU_SOURCE
4
5 #include <math.h>
6
7 #ifndef _MAPPER_TYPES_H
8 #define _MAPPER_TYPES_H
9
10 /** This enumerated type defines the supported types of repositories. */
11 typedef enum {
12         REPOTYPE_NONE,          /* No URL set. */
13         REPOTYPE_XYZ,           /* x=%d, y=%d, and zoom=%d */
14         REPOTYPE_XYZ_INV,       /* zoom=%0d, x=%d, y=%d */
15         REPOTYPE_QUAD_QRST,     /* t=%s   (%s = {qrst}*) */
16         REPOTYPE_QUAD_ZERO,     /* t=%0s  (%0s = {0123}*) */
17         REPOTYPE_WMS            /* "service=wms" */
18 } RepoType;
19
20 /** Possible center modes.  The "WAS" modes imply no current center mode;
21  * they only hint at what the last center mode was, so that it can be
22  * recalled. */
23 typedef enum {
24         CENTER_WAS_LATLON = -2,
25         CENTER_WAS_LEAD = -1,
26         CENTER_MANUAL =0,
27         CENTER_LEAD = 1,
28         CENTER_LATLON = 2
29 } CenterMode;
30
31 /** This enum defines the states of the SAX parsing state machine. */
32 typedef enum {
33         START,
34         INSIDE_GPX,
35         INSIDE_PATH,
36         INSIDE_PATH_SEGMENT,
37         INSIDE_PATH_POINT,
38         INSIDE_PATH_POINT_ELE,
39         INSIDE_PATH_POINT_TIME,
40         INSIDE_PATH_POINT_DESC,
41         FINISH,
42         UNKNOWN,
43         ERROR,
44 } SaxState;
45
46 /** POI dialog action **/
47 typedef enum {
48         ACTION_ADD_POI,
49         ACTION_EDIT_POI,
50 } POIAction;
51
52 /** Category list **/
53 typedef enum {
54         CAT_ID,
55         CAT_ENABLED,
56         CAT_LABEL,
57         CAT_DESC,
58         CAT_POI_CNT,
59         CAT_NUM_COLUMNS
60 } CategoryList;
61
62 /** POI list **/
63 typedef enum {
64         POI_POIID,
65         POI_CATID,
66         POI_LAT,
67         POI_LON,
68         POI_LATLON,
69         POI_LABEL,
70         POI_DESC,
71         POI_CATLAB,
72         POI_NUM_COLUMNS
73 } POIList;
74
75 /** This enum defines the possible units we can use. */
76 typedef enum {
77         UNITS_KM,
78         UNITS_MI,
79         UNITS_NM,
80         UNITS_ENUM_COUNT
81 } UnitType;
82 gchar *UNITS_TEXT[UNITS_ENUM_COUNT];
83
84 /* UNITS_CONVERTS, when multiplied, converts from NM. */
85 #define EARTH_RADIUS (3440.06479f)
86 gfloat UNITS_CONVERT[UNITS_ENUM_COUNT];
87
88 /** This enum defines the possible font sizes. */
89 typedef enum {
90         INFO_FONT_XXSMALL,
91         INFO_FONT_XSMALL,
92         INFO_FONT_SMALL,
93         INFO_FONT_MEDIUM,
94         INFO_FONT_LARGE,
95         INFO_FONT_XLARGE,
96         INFO_FONT_XXLARGE,
97         INFO_FONT_ENUM_COUNT
98 } InfoFontSize;
99 gchar *INFO_FONT_TEXT[INFO_FONT_ENUM_COUNT];
100
101 /** This enum defines all of the key-customizable actions. */
102 typedef enum {
103         CUSTOM_ACTION_PAN_NORTH,
104         CUSTOM_ACTION_PAN_WEST,
105         CUSTOM_ACTION_PAN_SOUTH,
106         CUSTOM_ACTION_PAN_EAST,
107         CUSTOM_ACTION_TOGGLE_AUTOCENTER,
108         CUSTOM_ACTION_ZOOM_IN,
109         CUSTOM_ACTION_ZOOM_OUT,
110         CUSTOM_ACTION_TOGGLE_FULLSCREEN,
111         CUSTOM_ACTION_TOGGLE_TRACKS,
112         CUSTOM_ACTION_TOGGLE_SCALE,
113         CUSTOM_ACTION_TOGGLE_POI,
114         CUSTOM_ACTION_CHANGE_REPO,
115         CUSTOM_ACTION_ROUTE_DISTNEXT,
116         CUSTOM_ACTION_ROUTE_DISTLAST,
117         CUSTOM_ACTION_TRACK_BREAK,
118         CUSTOM_ACTION_TRACK_DISTLAST,
119         CUSTOM_ACTION_TRACK_DISTFIRST,
120         CUSTOM_ACTION_TOGGLE_GPS,
121         CUSTOM_ACTION_TOGGLE_GPSINFO,
122         CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
123         CUSTOM_ACTION_RESET_BLUETOOTH,
124         CUSTOM_ACTION_ENUM_COUNT
125 } CustomAction;
126 gchar *CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ENUM_COUNT];
127
128 /** This enum defines all of the customizable keys. */
129 typedef enum {
130         CUSTOM_KEY_UP,
131         CUSTOM_KEY_LEFT,
132         CUSTOM_KEY_DOWN,
133         CUSTOM_KEY_RIGHT,
134         CUSTOM_KEY_SELECT,
135         CUSTOM_KEY_INCREASE,
136         CUSTOM_KEY_DECREASE,
137         CUSTOM_KEY_FULLSCREEN,
138         CUSTOM_KEY_ESC,
139         CUSTOM_KEY_ENUM_COUNT
140 } CustomKey;
141 gchar *CUSTOM_KEY_GCONF[CUSTOM_KEY_ENUM_COUNT];
142 gchar *CUSTOM_KEY_ICON[CUSTOM_KEY_ENUM_COUNT];
143 CustomAction CUSTOM_KEY_DEFAULT[CUSTOM_KEY_ENUM_COUNT];
144
145 /** This enum defines all of the colorable objects. */
146 typedef enum {
147         COLORABLE_MARK,
148         COLORABLE_MARK_VELOCITY,
149         COLORABLE_MARK_OLD,
150         COLORABLE_TRACK,
151         COLORABLE_TRACK_MARK,
152         COLORABLE_TRACK_BREAK,
153         COLORABLE_ROUTE,
154         COLORABLE_ROUTE_WAY,
155         COLORABLE_ROUTE_BREAK,
156         COLORABLE_POI,
157         COLORABLE_ENUM_COUNT
158 } Colorable;
159 gchar *COLORABLE_GCONF[COLORABLE_ENUM_COUNT];
160 GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT];
161
162 typedef enum {
163         DDPDDDDD,
164         DD_MMPMMM,
165         DD_MM_SSPS,
166         DDPDDDDD_NSEW,
167         DD_MMPMMM_NSEW,
168         DD_MM_SSPS_NSEW,
169         DEG_FORMAT_ENUM_COUNT
170 } DegFormat;
171 gchar *DEG_FORMAT_TEXT[DEG_FORMAT_ENUM_COUNT];
172
173 typedef enum {
174         SPEED_LOCATION_TOP_LEFT,
175         SPEED_LOCATION_TOP_RIGHT,
176         SPEED_LOCATION_BOTTOM_RIGHT,
177         SPEED_LOCATION_BOTTOM_LEFT,
178         SPEED_LOCATION_ENUM_COUNT
179 } SpeedLocation;
180 gchar *SPEED_LOCATION_TEXT[SPEED_LOCATION_ENUM_COUNT];
181
182 /** A lat/lon/alt position */
183 typedef struct _Position Position;
184 struct _Position {
185         gdouble lat;
186         gdouble lon;
187         gfloat altitude;
188 };
189
190 /** A general definition of a point in the Mapper unit system. */
191 typedef struct _Point Point;
192 struct _Point {
193         guint unitx;
194         guint unity;
195         time_t time;
196         gfloat altitude;
197 };
198
199 /** A WayPoint, which is a Point with a description. */
200 typedef struct _WayPoint WayPoint;
201 struct _WayPoint {
202         Point *point;
203         gchar *desc;
204 };
205
206 /** A Path is a set of PathPoints and WayPoints. */
207 typedef struct _Path Path;
208 struct _Path {
209         Point *head;            /* points to first element in array; NULL if empty. */
210         Point *tail;            /* points to last element in array. */
211         Point *cap;             /* points after last slot in array. */
212         WayPoint *whead;        /* points to first element in array; NULL if empty. */
213         WayPoint *wtail;        /* points to last element in array. */
214         WayPoint *wcap;         /* points after last slot in array. */
215 };
216
217 /** Data used during the SAX parsing operation. */
218 typedef struct _SaxData SaxData;
219 struct _SaxData {
220         Path path;
221         SaxState state;
222         SaxState prev_state;
223         guint unknown_depth;
224         gboolean at_least_one_trkpt;
225         GString *chars;
226 };
227
228 /** Data regarding a map repository. */
229 typedef struct _RepoData RepoData;
230 struct _RepoData {
231         gchar *name;
232         gchar *url;
233         gchar *cache_dir;
234         guint dl_zoom_steps;
235         guint view_zoom_steps;
236         gboolean double_size;
237         gboolean nextable;
238         RepoType type;
239         GtkWidget *menu_item;
240 };
241
242 /** Data used during the asynchronous progress update phase of automatic map
243  * downloading. */
244 typedef struct _ProgressUpdateInfo ProgressUpdateInfo;
245 struct _ProgressUpdateInfo {
246         gchar *src_str;
247         gchar *dest_str;
248         RepoData *repo;
249         guint tilex, tiley, zoom;       /* for refresh. */
250         gint retries;           /* if equal to zero, it means we're DELETING maps. */
251         guint priority;
252         FILE *file;
253 };
254
255 typedef struct _RouteDownloadData RouteDownloadData;
256 struct _RouteDownloadData {
257         gchar *bytes;
258         guint bytes_read;
259 };
260
261 /** Data used during the asynchronous automatic route downloading operation. */
262 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
263 struct _AutoRouteDownloadData {
264         gboolean enabled;
265         gboolean in_progress;
266         gchar *dest;
267         CURL *curl_easy;
268         gchar *src_str;
269         RouteDownloadData rdl_data;
270 };
271
272 typedef struct _BrowseInfo BrowseInfo;
273 struct _BrowseInfo {
274         GtkWidget *dialog;
275         GtkWidget *txt;
276 };
277
278 Point _point_null;
279 Position _home;
280
281 #endif