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