]> err.no Git - mapper/blob - src/mapper-types.h
Add route table column IDs
[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 /* Route list */
54 typedef enum {
55         ROUTE_LATLON,
56         ROUTE_DISTANCE,
57         ROUTE_WAYPOINT,
58         ROUTE_NUM_COLUMNS
59 } RouteList;
60
61 /** Category list **/
62 typedef enum {
63         CAT_ID,
64         CAT_ENABLED,
65         CAT_LABEL,
66         CAT_DESC,
67         CAT_POI_CNT,
68         CAT_NUM_COLUMNS
69 } CategoryList;
70
71 /** POI list **/
72 typedef enum {
73         POI_POIID,
74         POI_CATID,
75         POI_LAT,
76         POI_LON,
77         POI_LATLON,
78         POI_LABEL,
79         POI_DESC,
80         POI_CATLAB,
81         POI_NUM_COLUMNS
82 } POIList;
83
84 /** This enum defines the possible units we can use. */
85 typedef enum {
86         UNITS_KM,
87         UNITS_MI,
88         UNITS_NM,
89         UNITS_ENUM_COUNT
90 } UnitType;
91 gchar *UNITS_TEXT[UNITS_ENUM_COUNT];
92
93 /* UNITS_CONVERTS, when multiplied, converts from NM. */
94 #define EARTH_RADIUS (3440.06479f)
95 gfloat UNITS_CONVERT[UNITS_ENUM_COUNT];
96
97 /** This enum defines the possible font sizes. */
98 typedef enum {
99         INFO_FONT_XXSMALL,
100         INFO_FONT_XSMALL,
101         INFO_FONT_SMALL,
102         INFO_FONT_MEDIUM,
103         INFO_FONT_LARGE,
104         INFO_FONT_XLARGE,
105         INFO_FONT_XXLARGE,
106         INFO_FONT_ENUM_COUNT
107 } InfoFontSize;
108 gchar *INFO_FONT_TEXT[INFO_FONT_ENUM_COUNT];
109
110 /** This enum defines all of the key-customizable actions. */
111 typedef enum {
112         CUSTOM_ACTION_PAN_NORTH,
113         CUSTOM_ACTION_PAN_WEST,
114         CUSTOM_ACTION_PAN_SOUTH,
115         CUSTOM_ACTION_PAN_EAST,
116         CUSTOM_ACTION_TOGGLE_AUTOCENTER,
117         CUSTOM_ACTION_ZOOM_IN,
118         CUSTOM_ACTION_ZOOM_OUT,
119         CUSTOM_ACTION_TOGGLE_FULLSCREEN,
120         CUSTOM_ACTION_TOGGLE_TRACKS,
121         CUSTOM_ACTION_TOGGLE_SCALE,
122         CUSTOM_ACTION_TOGGLE_POI,
123         CUSTOM_ACTION_CHANGE_REPO,
124         CUSTOM_ACTION_ROUTE_DISTNEXT,
125         CUSTOM_ACTION_ROUTE_DISTLAST,
126         CUSTOM_ACTION_TRACK_BREAK,
127         CUSTOM_ACTION_TRACK_DISTLAST,
128         CUSTOM_ACTION_TRACK_DISTFIRST,
129         CUSTOM_ACTION_TOGGLE_GPS,
130         CUSTOM_ACTION_TOGGLE_GPSINFO,
131         CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
132         CUSTOM_ACTION_ENUM_COUNT
133 } CustomAction;
134 gchar *CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ENUM_COUNT];
135
136 /** This enum defines all of the customizable keys. */
137 typedef enum {
138         CUSTOM_KEY_UP,
139         CUSTOM_KEY_LEFT,
140         CUSTOM_KEY_DOWN,
141         CUSTOM_KEY_RIGHT,
142         CUSTOM_KEY_SELECT,
143         CUSTOM_KEY_INCREASE,
144         CUSTOM_KEY_DECREASE,
145         CUSTOM_KEY_FULLSCREEN,
146         CUSTOM_KEY_ESC,
147         CUSTOM_KEY_ENUM_COUNT
148 } CustomKey;
149 gchar *CUSTOM_KEY_GCONF[CUSTOM_KEY_ENUM_COUNT];
150 gchar *CUSTOM_KEY_ICON[CUSTOM_KEY_ENUM_COUNT];
151 CustomAction CUSTOM_KEY_DEFAULT[CUSTOM_KEY_ENUM_COUNT];
152
153 /** This enum defines all of the colorable objects. */
154 typedef enum {
155         COLORABLE_MARK,
156         COLORABLE_MARK_VELOCITY,
157         COLORABLE_MARK_OLD,
158         COLORABLE_TRACK,
159         COLORABLE_TRACK_MARK,
160         COLORABLE_TRACK_BREAK,
161         COLORABLE_ROUTE,
162         COLORABLE_ROUTE_WAY,
163         COLORABLE_ROUTE_BREAK,
164         COLORABLE_POI,
165         COLORABLE_ENUM_COUNT
166 } Colorable;
167 gchar *COLORABLE_GCONF[COLORABLE_ENUM_COUNT];
168 GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT];
169
170 typedef enum {
171         DDPDDDDD,
172         DD_MMPMMM,
173         DD_MM_SSPS,
174         DDPDDDDD_NSEW,
175         DD_MMPMMM_NSEW,
176         DD_MM_SSPS_NSEW,
177         DEG_FORMAT_ENUM_COUNT
178 } DegFormat;
179 gchar *DEG_FORMAT_TEXT[DEG_FORMAT_ENUM_COUNT];
180
181 typedef enum {
182         SPEED_LOCATION_TOP_LEFT,
183         SPEED_LOCATION_TOP_RIGHT,
184         SPEED_LOCATION_BOTTOM_RIGHT,
185         SPEED_LOCATION_BOTTOM_LEFT,
186         SPEED_LOCATION_ENUM_COUNT
187 } SpeedLocation;
188 gchar *SPEED_LOCATION_TEXT[SPEED_LOCATION_ENUM_COUNT];
189
190 /** A lat/lon/alt position */
191 typedef struct _Position Position;
192 struct _Position {
193         gdouble lat;
194         gdouble lon;
195         gfloat altitude;
196         gboolean valid;
197 };
198
199 /** A general definition of a point in the Mapper unit system. */
200 typedef struct _Point Point;
201 struct _Point {
202         guint unitx;
203         guint unity;
204         time_t time;
205         gfloat altitude;
206 };
207
208 /** A WayPoint, which is a Point with a description. */
209 typedef struct _WayPoint WayPoint;
210 struct _WayPoint {
211         Point *point;
212         gchar *desc;
213 };
214
215 /** A Path is a set of PathPoints and WayPoints. */
216 typedef struct _Path Path;
217 struct _Path {
218         Point *head;            /* points to first element in array; NULL if empty. */
219         Point *tail;            /* points to last element in array. */
220         Point *cap;             /* points after last slot in array. */
221         WayPoint *whead;        /* points to first element in array; NULL if empty. */
222         WayPoint *wtail;        /* points to last element in array. */
223         WayPoint *wcap;         /* points after last slot in array. */
224 };
225
226 /** Data used during the SAX parsing operation. */
227 typedef struct _SaxData SaxData;
228 struct _SaxData {
229         Path path;
230         SaxState state;
231         SaxState prev_state;
232         guint unknown_depth;
233         gboolean at_least_one_trkpt;
234         GString *chars;
235 };
236
237 /** Data regarding a map repository. */
238 typedef struct _RepoData RepoData;
239 struct _RepoData {
240         gchar *name;
241         gchar *url;
242         gchar *cache_dir;
243         guint dl_zoom_steps;
244         guint view_zoom_steps;
245         gboolean double_size;
246         gboolean nextable;
247         RepoType type;
248         GtkWidget *menu_item;
249 };
250
251 /** Data used during the asynchronous progress update phase of automatic map
252  * downloading. */
253 typedef struct _ProgressUpdateInfo ProgressUpdateInfo;
254 struct _ProgressUpdateInfo {
255         gchar *src_str;
256         gchar *dest_str;
257         RepoData *repo;
258         guint tilex, tiley, zoom;       /* for refresh. */
259         gint retries;           /* if equal to zero, it means we're DELETING maps. */
260         guint priority;
261         FILE *file;
262 };
263
264 typedef struct _RouteDownloadData RouteDownloadData;
265 struct _RouteDownloadData {
266         gchar *bytes;
267         guint bytes_read;
268 };
269
270 /** Data used during the asynchronous automatic route downloading operation. */
271 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
272 struct _AutoRouteDownloadData {
273         gboolean enabled;
274         gboolean in_progress;
275         gchar *dest;
276         CURL *curl_easy;
277         gchar *src_str;
278         RouteDownloadData rdl_data;
279 };
280
281 typedef struct _BrowseInfo BrowseInfo;
282 struct _BrowseInfo {
283         GtkWidget *dialog;
284         GtkWidget *txt;
285 };
286
287 Point _point_null;
288
289 Position _home;
290 Position _dest;
291
292 #endif