]> err.no Git - mapper/blob - src/mapper-types.h
Build fixes
[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 /** This enumerated type defines the supported types of repositories. */
12 typedef enum {
13         REPOTYPE_NONE,          /* No URL set. */
14         REPOTYPE_XYZ,           /* x=%d, y=%d, and zoom=%d */
15         REPOTYPE_XYZ_INV,       /* zoom=%0d, x=%d, y=%d */
16         REPOTYPE_QUAD_QRST,     /* t=%s   (%s = {qrst}*) */
17         REPOTYPE_QUAD_ZERO,     /* t=%0s  (%0s = {0123}*) */
18         REPOTYPE_WMS            /* "service=wms" */
19 } RepoType;
20
21 /** Possible center modes.  The "WAS" modes imply no current center mode;
22  * they only hint at what the last center mode was, so that it can be
23  * recalled. */
24 typedef enum {
25         CENTER_WAS_LATLON = -2,
26         CENTER_WAS_LEAD = -1,
27         CENTER_MANUAL =0,
28         CENTER_LEAD = 1,
29         CENTER_LATLON = 2
30 } CenterMode;
31
32 /** This enum defines the states of the SAX parsing state machine. */
33 typedef enum {
34         START,
35         INSIDE_GPX,
36         INSIDE_PATH,
37         INSIDE_PATH_SEGMENT,
38         INSIDE_PATH_POINT,
39         INSIDE_PATH_POINT_ELE,
40         INSIDE_PATH_POINT_TIME,
41         INSIDE_PATH_POINT_DESC,
42         FINISH,
43         UNKNOWN,
44         ERROR,
45 } SaxState;
46
47 /** POI dialog action **/
48 typedef enum {
49         ACTION_ADD_POI,
50         ACTION_EDIT_POI,
51 } POIAction;
52
53 /** Category list **/
54 typedef enum {
55         CAT_ID,
56         CAT_ENABLED,
57         CAT_LABEL,
58         CAT_DESC,
59         CAT_POI_CNT,
60         CAT_NUM_COLUMNS
61 } CategoryList;
62
63 /** POI list **/
64 typedef enum {
65         POI_POIID,
66         POI_CATID,
67         POI_LAT,
68         POI_LON,
69         POI_LATLON,
70         POI_LABEL,
71         POI_DESC,
72         POI_CATLAB,
73         POI_NUM_COLUMNS
74 } POIList;
75
76 /** This enum defines the possible units we can use. */
77 typedef enum {
78         UNITS_KM,
79         UNITS_MI,
80         UNITS_NM,
81         UNITS_ENUM_COUNT
82 } UnitType;
83 gchar *UNITS_TEXT[UNITS_ENUM_COUNT];
84
85 /* UNITS_CONVERTS, when multiplied, converts from NM. */
86 #define EARTH_RADIUS (3440.06479f)
87 gfloat UNITS_CONVERT[UNITS_ENUM_COUNT];
88
89 /** This enum defines the possible font sizes. */
90 typedef enum {
91         INFO_FONT_XXSMALL,
92         INFO_FONT_XSMALL,
93         INFO_FONT_SMALL,
94         INFO_FONT_MEDIUM,
95         INFO_FONT_LARGE,
96         INFO_FONT_XLARGE,
97         INFO_FONT_XXLARGE,
98         INFO_FONT_ENUM_COUNT
99 } InfoFontSize;
100 gchar *INFO_FONT_TEXT[INFO_FONT_ENUM_COUNT];
101
102 /** This enum defines all of the key-customizable actions. */
103 typedef enum {
104         CUSTOM_ACTION_PAN_NORTH,
105         CUSTOM_ACTION_PAN_WEST,
106         CUSTOM_ACTION_PAN_SOUTH,
107         CUSTOM_ACTION_PAN_EAST,
108         CUSTOM_ACTION_TOGGLE_AUTOCENTER,
109         CUSTOM_ACTION_ZOOM_IN,
110         CUSTOM_ACTION_ZOOM_OUT,
111         CUSTOM_ACTION_TOGGLE_FULLSCREEN,
112         CUSTOM_ACTION_TOGGLE_TRACKS,
113         CUSTOM_ACTION_TOGGLE_SCALE,
114         CUSTOM_ACTION_TOGGLE_POI,
115         CUSTOM_ACTION_CHANGE_REPO,
116         CUSTOM_ACTION_ROUTE_DISTNEXT,
117         CUSTOM_ACTION_ROUTE_DISTLAST,
118         CUSTOM_ACTION_TRACK_BREAK,
119         CUSTOM_ACTION_TRACK_DISTLAST,
120         CUSTOM_ACTION_TRACK_DISTFIRST,
121         CUSTOM_ACTION_TOGGLE_GPS,
122         CUSTOM_ACTION_TOGGLE_GPSINFO,
123         CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
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         gboolean valid;
189 };
190
191 /** A general definition of a point in the Mapper unit system. */
192 typedef struct _Point Point;
193 struct _Point {
194         guint unitx;
195         guint unity;
196         time_t time;
197         gfloat altitude;
198 };
199
200 /** A WayPoint, which is a Point with a description. */
201 typedef struct _WayPoint WayPoint;
202 struct _WayPoint {
203         Point *point;
204         gchar *desc;
205 };
206
207 /** A Path is a set of PathPoints and WayPoints. */
208 typedef struct _Path Path;
209 struct _Path {
210         Point *head;            /* points to first element in array; NULL if empty. */
211         Point *tail;            /* points to last element in array. */
212         Point *cap;             /* points after last slot in array. */
213         WayPoint *whead;        /* points to first element in array; NULL if empty. */
214         WayPoint *wtail;        /* points to last element in array. */
215         WayPoint *wcap;         /* points after last slot in array. */
216 };
217
218 /** Data used during the SAX parsing operation. */
219 typedef struct _SaxData SaxData;
220 struct _SaxData {
221         Path path;
222         SaxState state;
223         SaxState prev_state;
224         guint unknown_depth;
225         gboolean at_least_one_trkpt;
226         GString *chars;
227 };
228
229 /** Data regarding a map repository. */
230 typedef struct _RepoData RepoData;
231 struct _RepoData {
232         gchar *name;
233         gchar *url;
234         gchar *cache_dir;
235         guint dl_zoom_steps;
236         guint view_zoom_steps;
237         gboolean double_size;
238         gboolean nextable;
239         RepoType type;
240         GtkWidget *menu_item;
241 };
242
243 /** Data used during the asynchronous progress update phase of automatic map
244  * downloading. */
245 typedef struct _ProgressUpdateInfo ProgressUpdateInfo;
246 struct _ProgressUpdateInfo {
247         gchar *src_str;
248         gchar *dest_str;
249         RepoData *repo;
250         guint tilex, tiley, zoom;       /* for refresh. */
251         gint retries;           /* if equal to zero, it means we're DELETING maps. */
252         guint priority;
253         FILE *file;
254 };
255
256 typedef struct _RouteDownloadData RouteDownloadData;
257 struct _RouteDownloadData {
258         gchar *bytes;
259         guint bytes_read;
260 };
261
262 /** Data used during the asynchronous automatic route downloading operation. */
263 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
264 struct _AutoRouteDownloadData {
265         gboolean enabled;
266         gboolean in_progress;
267         gchar *dest;
268         CURL *curl_easy;
269         gchar *src_str;
270         RouteDownloadData rdl_data;
271 };
272
273 typedef struct _BrowseInfo BrowseInfo;
274 struct _BrowseInfo {
275         GtkWidget *dialog;
276         GtkWidget *txt;
277 };
278
279 Point _point_null;
280
281 Position _home;
282 Position _dest;
283
284 #endif