]> git.itanic.dy.fi Git - maemo-mapper/blob - src/types.h
Added (default) support for SQLite3 in lieu of GDBM.
[maemo-mapper] / src / types.h
1 /*
2  * Copyright (C) 2006, 2007 John Costigan.
3  *
4  * POI and GPS-Info code originally written by Cezary Jackiewicz.
5  *
6  * Default map data provided by http://www.openstreetmap.org/
7  *
8  * This file is part of Maemo Mapper.
9  *
10  * Maemo Mapper is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * Maemo Mapper is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Maemo Mapper.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  *  
24  * Parts of this code have been ported from Xastir by Rob Williams (10 Aug 2008):
25  * 
26  *  * XASTIR, Amateur Station Tracking and Information Reporting
27  * Copyright (C) 1999,2000  Frank Giannandrea
28  * Copyright (C) 2000-2007  The Xastir Group
29  * 
30  */
31
32 #ifndef MAEMO_MAPPER_TYPES_H
33 #define MAEMO_MAPPER_TYPES_H
34
35
36 #ifdef HAVE_CONFIG_H
37 #    include "config.h"
38 #endif
39
40 #include <time.h>
41 #include <gdbm.h>
42 #include <gtk/gtk.h>
43 #include <libgnomevfs/gnome-vfs.h>
44
45 #define _(String) gettext(String)
46
47 #include "sqlite3.h"
48
49 // Latitude and longitude string formats.
50 #define CONVERT_HP_NORMAL       0
51 #define CONVERT_HP_NOSP         1
52 #define CONVERT_LP_NORMAL       2
53 #define CONVERT_LP_NOSP         3
54 #define CONVERT_DEC_DEG         4
55 #define CONVERT_UP_TRK          5
56 #define CONVERT_DMS_NORMAL      6
57 #define CONVERT_VHP_NOSP        7
58 #define CONVERT_DMS_NORMAL_FORMATED      8
59 #define CONVERT_HP_NORMAL_FORMATED       9
60 #define CONVERT_DEC_DEG_N       10
61
62 #define MAX_DEVICE_BUFFER       4096
63
64 /** This enumerated type defines the possible connection states. */
65 typedef enum
66 {
67     /** The receiver is "off", meaning that either the bluetooth radio is
68      * off or the user has requested not to connect to the GPS receiver.
69      * No gtk_banner is visible. */
70     RCVR_OFF,
71
72     /** The connection with the receiver is down.  A gtk_banner is visible with
73      * the text, "Connecting to GPS receiver". */
74     RCVR_DOWN,
75
76     /** The connection with the receiver is up, but a GPS fix is not available.
77      * A gtk_banner is visible with the text, "(Re-)Establishing GPS fix". */
78     RCVR_UP,
79
80     /** The connection with the receiver is up and a GPS fix IS available.
81      * No gtk_banner is visible. */
82     RCVR_FIXED
83 } ConnState;
84
85 /** This enumerated type defines the supported types of repositories. */
86 typedef enum
87 {
88     REPOTYPE_NONE, /* No URL set. */
89     REPOTYPE_XYZ, /* x=%d, y=%d, and zoom=%d */
90     REPOTYPE_XYZ_SIGNED, /* x=%d, y=%d, and zoom=%d-2 */
91     REPOTYPE_XYZ_INV, /* zoom=%0d, x=%d, y=%d */
92     REPOTYPE_QUAD_QRST, /* t=%s   (%s = {qrst}*) */
93     REPOTYPE_QUAD_ZERO, /* t=%0s  (%0s = {0123}*) */
94     REPOTYPE_WMS        /* "service=wms" */
95 } RepoType;
96
97 /** Possible center modes.  The "WAS" modes imply no current center mode;
98  * they only hint at what the last center mode was, so that it can be
99  * recalled. */
100 typedef enum
101 {
102     CENTER_WAS_LATLON = -2,
103     CENTER_WAS_LEAD = -1,
104     CENTER_LEAD = 1,
105     CENTER_LATLON = 2
106 } CenterMode;
107
108 /** POI dialog action **/
109 typedef enum
110 {
111     ACTION_ADD_POI,
112     ACTION_EDIT_POI,
113 } POIAction;
114
115 /** Category list **/
116 typedef enum
117 {
118     CAT_ID,
119     CAT_ENABLED,
120     CAT_LABEL,
121     CAT_DESC,
122     CAT_POI_CNT,
123     CAT_NUM_COLUMNS
124 } CategoryList;
125
126 /** POI list **/
127 typedef enum
128 {
129     POI_SELECTED,
130     POI_POIID,
131     POI_CATID,
132     POI_LAT,
133     POI_LON,
134     POI_LATLON,
135     POI_BEARING,
136     POI_DISTANCE,
137     POI_LABEL,
138     POI_DESC,
139     POI_CLABEL,
140     POI_NUM_COLUMNS
141 } POIList;
142
143 /** This enum defines the possible units we can use. */
144 typedef enum
145 {
146     UNITS_KM,
147     UNITS_MI,
148     UNITS_NM,
149     UNITS_ENUM_COUNT
150 } UnitType;
151
152 typedef enum
153 {
154     UNBLANK_WITH_GPS,
155     UNBLANK_WHEN_MOVING,
156     UNBLANK_FULLSCREEN,
157     UNBLANK_WAYPOINT,
158     UNBLANK_NEVER,
159     UNBLANK_ENUM_COUNT
160 } UnblankOption;
161
162 /** This enum defines the possible font sizes. */
163 typedef enum
164 {
165     INFO_FONT_XXSMALL,
166     INFO_FONT_XSMALL,
167     INFO_FONT_SMALL,
168     INFO_FONT_MEDIUM,
169     INFO_FONT_LARGE,
170     INFO_FONT_XLARGE,
171     INFO_FONT_XXLARGE,
172     INFO_FONT_ENUM_COUNT
173 } InfoFontSize;
174
175 /** This enum defines the possible font sizes. */
176 typedef enum
177 {
178     ROTATE_DIR_UP,
179     ROTATE_DIR_RIGHT,
180     ROTATE_DIR_DOWN,
181     ROTATE_DIR_LEFT,
182     ROTATE_DIR_ENUM_COUNT
183 } RotateDir;
184
185 /** This enum defines all of the key-customizable actions. */
186 typedef enum
187 {
188     CUSTOM_ACTION_PAN_NORTH,
189     CUSTOM_ACTION_PAN_WEST,
190     CUSTOM_ACTION_PAN_SOUTH,
191     CUSTOM_ACTION_PAN_EAST,
192     CUSTOM_ACTION_PAN_UP,
193     CUSTOM_ACTION_PAN_DOWN,
194     CUSTOM_ACTION_PAN_LEFT,
195     CUSTOM_ACTION_PAN_RIGHT,
196     CUSTOM_ACTION_RESET_VIEW_ANGLE,
197     CUSTOM_ACTION_ROTATE_CLOCKWISE,
198     CUSTOM_ACTION_ROTATE_COUNTERCLOCKWISE,
199     CUSTOM_ACTION_TOGGLE_AUTOCENTER,
200     CUSTOM_ACTION_TOGGLE_AUTOROTATE,
201     CUSTOM_ACTION_ZOOM_IN,
202     CUSTOM_ACTION_ZOOM_OUT,
203     CUSTOM_ACTION_TOGGLE_FULLSCREEN,
204     CUSTOM_ACTION_TOGGLE_TRACKING,
205     CUSTOM_ACTION_TOGGLE_TRACKS,
206     CUSTOM_ACTION_TOGGLE_SCALE,
207     CUSTOM_ACTION_TOGGLE_POI,
208     CUSTOM_ACTION_CHANGE_REPO,
209     CUSTOM_ACTION_ROUTE_DISTNEXT,
210     CUSTOM_ACTION_ROUTE_DISTLAST,
211     CUSTOM_ACTION_TRACK_BREAK,
212     CUSTOM_ACTION_TRACK_CLEAR,
213     CUSTOM_ACTION_TRACK_DISTLAST,
214     CUSTOM_ACTION_TRACK_DISTFIRST,
215     CUSTOM_ACTION_TOGGLE_GPS,
216     CUSTOM_ACTION_TOGGLE_GPSINFO,
217     CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
218     CUSTOM_ACTION_RESET_BLUETOOTH,
219     CUSTOM_ACTION_TOGGLE_LAYERS,
220     CUSTOM_ACTION_ENUM_COUNT
221 } CustomAction;
222
223 /** This enum defines all of the customizable keys. */
224 typedef enum
225 {
226     CUSTOM_KEY_UP,
227     CUSTOM_KEY_LEFT,
228     CUSTOM_KEY_DOWN,
229     CUSTOM_KEY_RIGHT,
230     CUSTOM_KEY_SELECT,
231     CUSTOM_KEY_INCREASE,
232     CUSTOM_KEY_DECREASE,
233     CUSTOM_KEY_FULLSCREEN,
234     CUSTOM_KEY_ESC,
235     CUSTOM_KEY_ENUM_COUNT
236 } CustomKey;
237
238 /** This enum defines all of the colorable objects. */
239 typedef enum
240 {
241     COLORABLE_MARK,
242     COLORABLE_MARK_VELOCITY,
243     COLORABLE_MARK_OLD,
244     COLORABLE_TRACK,
245     COLORABLE_TRACK_MARK,
246     COLORABLE_TRACK_BREAK,
247     COLORABLE_ROUTE,
248     COLORABLE_ROUTE_WAY,
249     COLORABLE_ROUTE_BREAK,
250     COLORABLE_POI,
251 #ifdef INCLUDE_APRS
252     COLORABLE_APRS_STATION,
253 #endif // INCLUDE_APRS
254     COLORABLE_ENUM_COUNT
255 } Colorable;
256
257 typedef enum
258 {
259     DDPDDDDD,
260     DD_MMPMMM,
261     DD_MM_SSPS,
262     DDPDDDDD_NSEW,
263     DD_MMPMMM_NSEW,
264     DD_MM_SSPS_NSEW,
265     NSEW_DDPDDDDD,
266     NSEW_DD_MMPMMM,
267     NSEW_DD_MM_SSPS,
268     UK_OSGB,
269     UK_NGR, // 8 char grid ref
270     UK_NGR6,// 6 char grid ref
271     IARU_LOC,
272     DEG_FORMAT_ENUM_COUNT
273 } DegFormat;
274
275 typedef struct _CoordFormatSetup CoordFormatSetup;
276 struct _CoordFormatSetup 
277 {
278         gchar    *name;
279         gchar    *short_field_1;
280         gchar    *long_field_1;
281         gchar    *short_field_2;
282         gchar    *long_field_2;
283         gboolean field_2_in_use;
284 } _CoordFormatSetup;
285
286 typedef enum
287 {
288     SPEED_LOCATION_BOTTOM_LEFT,
289     SPEED_LOCATION_BOTTOM_RIGHT,
290     SPEED_LOCATION_TOP_RIGHT,
291     SPEED_LOCATION_TOP_LEFT,
292     SPEED_LOCATION_ENUM_COUNT
293 } SpeedLocation;
294
295 typedef enum
296 {
297     MAP_UPDATE_ADD,
298     MAP_UPDATE_OVERWRITE,
299     MAP_UPDATE_AUTO,
300     MAP_UPDATE_DELETE,
301     MAP_UPDATE_ENUM_COUNT
302 } MapUpdateType;
303
304 typedef enum
305 {
306     GPS_RCVR_BT,
307     GPS_RCVR_GPSD,
308     GPS_RCVR_FILE,
309     GPS_RCVR_ENUM_COUNT
310 } GpsRcvrType;
311
312 /** A general definition of a point in the Maemo Mapper unit system. */
313 typedef struct _Point Point;
314 struct _Point {
315     gint unitx;
316     gint unity;
317     time_t time;
318     gint altitude;
319 };
320
321 /** A WayPoint, which is a Point with a description. */
322 typedef struct _WayPoint WayPoint;
323 struct _WayPoint {
324     Point *point;
325     gchar *desc;
326 };
327
328 /** A Path is a set of PathPoints and WayPoints. */
329 typedef struct _Path Path;
330 struct _Path {
331     Point *head; /* points to first element in array; NULL if empty. */
332     Point *tail; /* points to last element in array. */
333     Point *cap; /* points after last slot in array. */
334     WayPoint *whead; /* points to first element in array; NULL if empty. */
335     WayPoint *wtail; /* points to last element in array. */
336     WayPoint *wcap; /* points after last slot in array. */
337 };
338
339 /** Data to describe a POI. */
340 typedef struct _PoiInfo PoiInfo;
341 struct _PoiInfo {
342     gint poi_id;
343     gint cat_id;
344     gdouble lat;
345     gdouble lon;
346     gchar *label;
347     gchar *desc;
348     gchar *clabel;
349 };
350
351 /** Data regarding a map repository. */
352 typedef struct _RepoData RepoData;
353 struct _RepoData {
354     gchar *name;
355     gchar *url;
356     gchar *db_filename;
357     gchar *db_dirname;
358     gint dl_zoom_steps;
359     gint view_zoom_steps;
360     gboolean double_size;
361     gboolean nextable;
362     gint min_zoom;
363     gint max_zoom;
364     RepoType type;
365     RepoData *layers;
366     gint8 layer_level;
367     gboolean layer_enabled;
368     gboolean layer_was_enabled; /* needed for ability to temporarily toggle layers on and off */
369     gint layer_refresh_interval;
370     gint layer_refresh_countdown;
371     gboolean is_sqlite;
372     sqlite3 *sqlite_db;
373     sqlite3_stmt *stmt_map_select;
374     sqlite3_stmt *stmt_map_exists;
375     sqlite3_stmt *stmt_map_update;
376     sqlite3_stmt *stmt_map_delete;
377     GDBM_FILE gdbm_db;
378     GtkWidget *menu_item;
379 };
380
381 /** GPS Data and Satellite **/
382 typedef struct _GpsData GpsData;
383 struct _GpsData {
384     gint fix;
385     gint fixquality;
386     gdouble lat;
387     gdouble lon;
388     gfloat speed;    /* in knots */
389     gfloat maxspeed;    /* in knots */
390     gfloat heading;
391     gfloat hdop;
392     gfloat pdop;
393     gfloat vdop;
394     gint satinview;
395     gint satinuse;
396     gint satforfix[12];
397 };
398
399 typedef struct _GpsSatelliteData GpsSatelliteData;
400 struct _GpsSatelliteData {
401     gint prn;
402     gint elevation;
403     gint azimuth;
404     gint snr;
405 };
406
407 /** Data used for rendering the entire screen. */
408 typedef struct _MapRenderTask MapRenderTask;
409 struct _MapRenderTask
410 {
411     RepoData *repo;
412     Point new_center;
413     gint old_offsetx;
414     gint old_offsety;
415     gint screen_width_pixels;
416     gint screen_height_pixels;
417     gint zoom;
418     gint rotate_angle;
419     gboolean smooth_pan;
420     GdkPixbuf *pixbuf;
421 };
422
423 /** Data used for rendering the entire screen. */
424 typedef struct _MapOffsetArgs MapOffsetArgs;
425 struct _MapOffsetArgs
426 {
427     gfloat old_center_offset_devx;
428     gfloat old_center_offset_devy;
429     gfloat new_center_offset_devx;
430     gfloat new_center_offset_devy;
431     gint rotate_angle;
432     gfloat percent_complete;
433 };
434
435 typedef struct _ThreadLatch ThreadLatch;
436 struct _ThreadLatch
437 {
438     gboolean is_open;
439     gboolean is_done_adding_tasks;
440     gint num_tasks;
441     gint num_done;
442     GMutex *mutex;
443     GCond *cond;
444 };
445
446 /** Data used during the asynchronous progress update phase of automatic map
447  * downloading. */
448 typedef struct _MapUpdateTask MapUpdateTask;
449 struct _MapUpdateTask
450 {
451     gint priority;
452     gint tilex;
453     gint tiley;
454     ThreadLatch *refresh_latch;
455     GdkPixbuf *pixbuf;
456     RepoData *repo;
457     gint8 update_type;
458     gint8 zoom;
459     gint8 vfs_result;
460     gint8 batch_id;
461     gint8 layer_level;
462 };
463
464 /** Data used during the asynchronous automatic route downloading operation. */
465 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
466 struct _AutoRouteDownloadData {
467     gboolean enabled;
468     gboolean in_progress;
469     gchar *source_url;
470     gchar *dest;
471     gboolean avoid_highways;
472 };
473
474 /** Data to describe the GPS connection. */
475 typedef struct _GpsRcvrInfo GpsRcvrInfo;
476 struct _GpsRcvrInfo {
477     GpsRcvrType type;
478     gchar *bt_mac;
479     gchar *file_path;
480     gchar *gpsd_host;
481     gint gpsd_port;
482 };
483
484 typedef struct _BrowseInfo BrowseInfo;
485 struct _BrowseInfo {
486     GtkWidget *dialog;
487     GtkWidget *txt;
488 };
489
490
491 #ifdef INCLUDE_APRS
492
493 // --------------------------------------------------------------------------------------
494 // Start of APRS Types - Code taken from Xastir code 25 March 2008 by Rob Williams
495 // Modification made to fit in with Maemo mapper
496 // --------------------------------------------------------------------------------------
497
498 typedef struct _TWriteBuffer TWriteBuffer;
499 struct _TWriteBuffer
500 {
501     int    write_in_pos;                          /* current write buffer input pos          */
502     int    write_out_pos;                         /* current write buffer output pos         */
503     GMutex* write_lock;                      /* Lock for writing the port data          */
504     char   device_write_buffer[MAX_DEVICE_BUFFER];/* write buffer for this port              */
505     int    errors;
506 };
507
508
509 typedef enum
510 {
511         TNC_CONNECTION_BT,
512         TNC_CONNECTION_FILE
513 } TTncConnection;
514
515 typedef enum
516 {
517         APRS_PORT_INET,
518         APRS_PORT_TTY,
519         APRS_PORT_COUNT
520 } TAprsPort;
521
522 // We should probably be using APRS_DF in extract_bearing_NRQ()
523 // and extract_omnidf() functions.  We aren't currently.
524 /* Define APRS Types */
525 enum APRS_Types {
526     APRS_NULL,
527     APRS_MSGCAP,
528     APRS_FIXED,
529     APRS_DOWN,      // Not used anymore
530     APRS_MOBILE,
531     APRS_DF,
532     APRS_OBJECT,
533     APRS_ITEM,
534     APRS_STATUS,
535     APRS_WX1,
536     APRS_WX2,
537     APRS_WX3,
538     APRS_WX4,
539     APRS_WX5,
540     APRS_WX6,
541     QM_WX,
542     PEET_COMPLETE,
543     RSWX200,
544     GPS_RMC,
545     GPS_GGA,
546     GPS_GLL,
547     STATION_CALL_DATA,
548     OTHER_DATA,
549     APRS_MICE,
550     APRS_GRID,
551     DALLAS_ONE_WIRE,
552     DAVISMETEO
553 };
554
555
556 /* Define Record Types */
557 #define NORMAL_APRS     'N'
558 #define MOBILE_APRS     'M'
559 #define DF_APRS         'D'
560 #define DOWN_APRS       'Q'
561 #define NORMAL_GPS_RMC  'C'
562 #define NORMAL_GPS_GGA  'A'
563 #define NORMAL_GPS_GLL  'L'
564
565 /* define RECORD ACTIVES */
566 #define RECORD_ACTIVE    'A'
567 #define RECORD_NOTACTIVE 'N'
568 #define RECORD_CLOSED     'C'
569
570 /* define data from info type */
571 #define DATA_VIA_LOCAL 'L'
572 #define DATA_VIA_TNC   'T'
573 #define DATA_VIA_NET   'I'
574 #define DATA_VIA_FILE  'F'
575
576
577 /* define Heard info type */
578 #define VIA_TNC         'Y'
579 #define NOT_VIA_TNC     'N'
580
581 /* define Message types */
582 #define MESSAGE_MESSAGE  'M'
583 #define MESSAGE_BULLETIN 'B'
584 #define MESSAGE_NWS      'W'
585
586
587 // trail flag definitions
588 #define MAX_CALLSIGN 9
589 #define MAX_TIME             20
590 #define MAX_LONG             12
591 #define MAX_LAT              11
592 #define MAX_ALTITUDE         10         //-32808.4 to 300000.0? feet
593 #define MAX_SPEED             9         /* ?? 3 in knots */
594 #define MAX_COURSE            7         /* ?? */
595 #define MAX_POWERGAIN         7
596 #define MAX_STATION_TIME     10         /* 6+1 */
597 #define MAX_SAT               4
598 #define MAX_DISTANCE         10
599 #define MAX_WXSTATION        50
600 #define MAX_TEMP            100
601 #define MAX_MULTIPOINTS 35
602
603 #define MAX_DEVICE_BUFFER 4096
604
605 /* define max size of info field */
606 #define MAX_INFO_FIELD_SIZE 256
607
608 // Number of times to send killed objects/items before ceasing to
609 // transmit them.
610 #define MAX_KILLED_OBJECT_RETRANSMIT 20
611
612 // Check entire station list at this rate for objects/items that
613 // might need to be transmitted via the decaying algorithm.  This is
614 // the start rate, which gets doubled on each transmit.
615 #define OBJECT_CHECK_RATE 20
616
617
618 #define MAX_MESSAGE_LENGTH  100
619 #define MAX_MESSAGE_ORDER    10
620
621
622 #define CHECKMALLOC(m)  if (!m) { fprintf(stderr, "***** Malloc Failed *****\n"); exit(0); }
623
624
625 #define STATION_REMOVE_CYCLE 300    /* check station remove in seconds (every 5 minutes) */
626 #define MESSAGE_REMOVE_CYCLE 600    /* check message remove in seconds (every 10 minutes) */
627 #define IN_VIEW_MIN         600l    /* margin for off-screen stations, with possible trails on screen, in minutes */
628 #define TRAIL_POINT_MARGIN   30l    /* margin for off-screen trails points, for segment to be drawn, in minutes */
629 #define TRAIL_MAX_SPEED      900    /* max. acceptible speed for drawing trails, in mph */
630 #define MY_TRAIL_COLOR      0x16    /* trail color index reserved for my station */
631 #define TRAIL_ECHO_TIME       30    /* check for delayed echos during last 30 minutes */
632 /* MY_TRAIL_DIFF_COLOR changed to user configurable my_trail_diff_color  */
633
634
635 typedef struct { 
636     int digis;
637     int wxs;
638     int other_mobiles;
639     int mobiles_in_motion;
640     int homes;
641     int total;
642 } aloha_stats;
643
644
645 // station flag definitions.  We have 16 bits available here as
646 // "flag" in "DataRow" is defined as a short.
647 //
648 #define ST_OBJECT       0x01    // station is an object
649 #define ST_ITEM         0x02    // station is an item
650 #define ST_ACTIVE       0x04    // station is active (deleted objects are
651                                 // inactive)
652 #define ST_MOVING       0x08    // station is moving
653 #define ST_DIRECT       0x10    // heard direct (not via digis)
654 #define ST_VIATNC       0x20    // station heard via TNC
655 #define ST_3RD_PT       0x40    // third party traffic (not used yet)
656 #define ST_MSGCAP       0x80    // message capable (not used yet)
657 #define ST_STATUS       0x100   // got real status message
658 #define ST_INVIEW       0x200   // station is in current screen view
659 #define ST_MYSTATION    0x400   // station is owned by my call-SSID
660 #define ST_MYOBJITEM    0x800   // object/item owned by me
661
662
663 #define TR_LOCAL        0x01    // heard direct (not via digis)
664 #define TR_NEWTRK       0x02    // start new track
665
666
667 enum AprsAreaObjectTypes {
668     AREA_OPEN_CIRCLE     = 0x0,
669     AREA_LINE_LEFT       = 0x1,
670     AREA_OPEN_ELLIPSE    = 0x2,
671     AREA_OPEN_TRIANGLE   = 0x3,
672     AREA_OPEN_BOX        = 0x4,
673     AREA_FILLED_CIRCLE   = 0x5,
674     AREA_LINE_RIGHT      = 0x6,
675     AREA_FILLED_ELLIPSE  = 0x7,
676     AREA_FILLED_TRIANGLE = 0x8,
677     AREA_FILLED_BOX      = 0x9,
678     AREA_MAX             = 0x9,
679     AREA_NONE            = 0xF
680 };
681
682
683
684 enum AprsAreaObjectColors {
685     AREA_BLACK_HI  = 0x0,
686     AREA_BLUE_HI   = 0x1,
687     AREA_GREEN_HI  = 0x2,
688     AREA_CYAN_HI   = 0x3,
689     AREA_RED_HI    = 0x4,
690     AREA_VIOLET_HI = 0x5,
691     AREA_YELLOW_HI = 0x6,
692     AREA_GRAY_HI   = 0x7,
693     AREA_BLACK_LO  = 0x8,
694     AREA_BLUE_LO   = 0x9,
695     AREA_GREEN_LO  = 0xA,
696     AREA_CYAN_LO   = 0xB,
697     AREA_RED_LO    = 0xC,
698     AREA_VIOLET_LO = 0xD,
699     AREA_YELLOW_LO = 0xE,
700     AREA_GRAY_LO   = 0xF
701 };
702
703
704 typedef struct {
705     unsigned type : 4;
706     unsigned color : 4;
707     unsigned sqrt_lat_off : 8;
708     unsigned sqrt_lon_off : 8;
709     unsigned corridor_width : 16;
710 } AprsAreaObject;
711
712 typedef struct {
713     char aprs_type;
714     char aprs_symbol;
715     char special_overlay;
716     AprsAreaObject area_object;
717 } APRS_Symbol;
718
719 // Struct for holding track data.  Keeps a dynamically allocated
720 // doubly-linked list of track points.  The first record should have its
721 // "prev" pointer set to NULL and the last record should have its "next"
722 // pointer set to NULL.  If no track storage exists then the pointers to
723 // these structs in the DataRow struct should be NULL.
724 typedef struct _AprsTrackRow{
725     long    trail_long_pos;     // coordinate of trail point
726     long    trail_lat_pos;      // coordinate of trail point
727     time_t  sec;                // date/time of position
728     long    speed;              // in 0.1 km/h   undefined: -1
729     int     course;             // in degrees    undefined: -1
730     long    altitude;           // in 0.1 m      undefined: -99999
731     char    flag;               // several flags, see below
732     struct  _AprsTrackRow *prev;    // pointer to previous record in list
733     struct  _AprsTrackRow *next;    // pointer to next record in list
734 } AprsTrackRow;
735
736
737
738 // Struct for holding current weather data.
739 // This struct is pointed to by the DataRow structure.
740 // An empty string indicates undefined data.
741 typedef struct {                //                      strlen
742     time_t  wx_sec_time;
743     int     wx_storm;           // Set to one if severe storm
744     char    wx_time[MAX_TIME];
745     char    wx_course[4];       // in °                     3
746     char    wx_speed[4];        // in mph                   3
747     time_t  wx_speed_sec_time;
748     char    wx_gust[4];         // in mph                   3
749     char    wx_hurricane_radius[4];  //nautical miles       3
750     char    wx_trop_storm_radius[4]; //nautical miles       3
751     char    wx_whole_gale_radius[4]; // nautical miles      3
752     char    wx_temp[5];         // in °F                    3
753     char    wx_rain[10];        // in hundredths inch/h     3
754     char    wx_rain_total[10];  // in hundredths inch
755     char    wx_snow[6];         // in inches/24h            3
756     char    wx_prec_24[10];     // in hundredths inch/day   3
757     char    wx_prec_00[10];     // in hundredths inch       3
758     char    wx_hum[5];          // in %                     3
759     char    wx_baro[10];        // in hPa                   6
760     char    wx_fuel_temp[5];    // in °F                    3
761     char    wx_fuel_moisture[5];// in %                     2
762     char    wx_type;
763     char    wx_station[MAX_WXSTATION];
764 } AprsWeatherRow;
765
766
767 // Struct for holding comment/status data.  Will keep a dynamically
768 // allocated list of text.  Every different comment field will be
769 // stored in a separate line.
770 typedef struct _AprsCommentRow{
771     char   *text_ptr;           // Ptr to the comment text
772     time_t sec_heard;           // Latest timestamp for this comment/status
773     struct _AprsCommentRow *next;   // Ptr to next record or NULL
774 } AprsCommentRow;
775
776
777
778
779 // Struct for holding multipoint data.
780 typedef struct _AprsMultipointRow{
781     long multipoints[MAX_MULTIPOINTS][2];
782 } AprsMultipointRow;
783
784 typedef struct _AprsDisplayData
785 {
786     gchar *call_sign; // call sign or name index or object/item
787                                     // name
788     gdouble coord_lon;
789     gdouble coord_lat;
790
791     gchar   *coord_lat_lon;
792     gchar   *path;
793     
794     gchar   *comment;
795     gchar   *status;
796 } AprsDisplayData;
797
798 typedef struct _AprsDataRow {
799
800     struct _AprsDataRow *n_next;    // pointer to next element in name ordered list
801     struct _AprsDataRow *n_prev;    // pointer to previous element in name ordered
802                                 // list
803     struct _AprsDataRow *t_newer;   // pointer to next element in time ordered
804                                 // list (newer)
805     struct _AprsDataRow *t_older;   // pointer to previous element in time ordered
806                                 // list (older)
807
808     
809     char call_sign[MAX_CALLSIGN+1]; // call sign or name index or object/item
810                                     // name
811     char *tactical_call_sign;   // Tactical callsign.  NULL if not assigned
812     APRS_Symbol aprs_symbol;
813     long coord_lon;             // Xastir coordinates 1/100 sec, 0 = 180°W
814     long coord_lat;             // Xastir coordinates 1/100 sec, 0 =  90°N
815
816     int  time_sn;               // serial number for making time index unique
817     time_t sec_heard;           // time last heard, used also for time index
818     time_t heard_via_tnc_last_time;
819     time_t direct_heard;        // KC2ELS - time last heard direct
820
821 // Change into time_t structs?  It'd save us a bunch of space.
822     char packet_time[MAX_TIME];
823     char pos_time[MAX_TIME];
824
825     short flag;                 // several flags, see below
826     char pos_amb;               // Position ambiguity, 0 = none,
827                                 // 1 = 0.1 minute...
828
829     unsigned int error_ellipse_radius; // Degrades precision for this
830                                 // station, from 0 to 65535 cm or
831                                 // 655.35 meters.  Assigned when we
832                                 // decode each type of packet.
833                                 // Default is 6.0 meters (600 cm)
834                                 // unless we know the GPS position
835                                 // is augmented, or is degraded by
836                                 // less precision in the packet.
837
838     unsigned int lat_precision; // In 100ths of a second latitude
839     unsigned int lon_precision; // In 100ths of a second longitude
840
841     int trail_color;            // trail color (when assigned)
842     char record_type;
843     //char data_via;              // L local, T TNC, I internet, F file
844
845 // Change to char's to save space?
846     int  heard_via_tnc_port;    // Current this will always be 0, but keep for future
847     TAprsPort  last_port_heard;       // Current this will always be 0, but keep for future
848     unsigned int  num_packets;
849     char *node_path_ptr;        // Pointer to path string
850     char altitude[MAX_ALTITUDE]; // in meters (feet gives better resolution ??)
851     char speed[MAX_SPEED+1];    // in knots (same as nautical miles/hour)
852     char course[MAX_COURSE+1];
853     char bearing[MAX_COURSE+1];
854     char NRQ[MAX_COURSE+1];
855     char power_gain[MAX_POWERGAIN+1];   // Holds the phgd values
856     char signal_gain[MAX_POWERGAIN+1];  // Holds the shgd values (for DF'ing)
857
858     AprsWeatherRow *weather_data;   // Pointer to weather data or NULL
859  
860     AprsCommentRow *status_data;    // Ptr to status records or NULL
861     AprsCommentRow *comment_data;   // Ptr to comment records or NULL
862
863     // Below two pointers are NULL if only one position has been received
864     AprsTrackRow *oldest_trackpoint; // Pointer to oldest track point in
865                                  // doubly-linked list
866     AprsTrackRow *newest_trackpoint; // Pointer to newest track point in
867                                  // doubly-linked list
868
869     // When the station is an object, it can include coordinates
870     // of related points. Currently these are being used to draw
871     // outlines of NWS severe weather watches and warnings, and
872     // storm regions. The coordinates are stored here in Xastir
873     // coordinate form. Element [x][0] is the latitude, and 
874     // element [x][1] is the longitude.  --KG4NBB
875     //
876     // Is there anything preventing a multipoint string from being
877     // in other types of packets, in the comment field?  --WE7U
878     //
879     int num_multipoints;
880     char type;      // from '0' to '9'
881     char style;     // from 'a' to 'z'
882     AprsMultipointRow *multipoint_data;
883
884
885 ///////////////////////////////////////////////////////////////////////
886 // Optional stuff for Objects/Items only (I think, needs to be
887 // checked).  These could be moved into an ObjectRow structure, with
888 // only a NULL pointer here if not an object/item.
889 ///////////////////////////////////////////////////////////////////////
890  
891     char origin[MAX_CALLSIGN+1]; // call sign originating an object
892     short object_retransmit;     // Number of times to retransmit object.
893                                  // -1 = forever
894                                  // Used currently to stop sending killed
895                                  // objects.
896     time_t last_transmit_time;   // Time we last transmitted an object/item.
897                                  // Used to implement decaying transmit time
898                                  // algorithm
899     short transmit_time_increment; // Seconds to add to transmit next time
900                                    // around.  Used to implement decaying
901                                    // transmit time algorithm
902 //    time_t last_modified_time;   // Seconds since the object/item
903                                  // was last modified.  We'll
904                                  // eventually use this for
905                                  // dead-reckoning.
906     char signpost[5+1];          // Holds signpost data
907     int  df_color;
908     char sats_visible[MAX_SAT];
909     char probability_min[10+1];  // Holds prob_min (miles)
910     char probability_max[10+1];  // Holds prob_max (miles)
911
912 } AprsDataRow;
913
914 typedef enum
915 {
916     APRSPOI_SELECTED,
917     APRSPOI_CALLSIGN,
918 //    APRSPOI_LAT,
919 //    APRSPOI_LON,
920 //    APRSPOI_LATLON,
921 //    APRSPOI_BEARING,
922 //    APRSPOI_DISTANCE,
923 //    APRSPOI_PATH,
924 //    APRSPOI_COMMENT,
925 //    APRSPOI_STATUS,
926     APRSPOI_NUM_COLUMNS
927 } APRSPOIList;
928
929
930
931 typedef struct _AprsStationList{
932     struct  _AprsStationList *next;    // pointer to next record in list
933     AprsDataRow *station;
934 } AprsStationList;
935
936
937
938
939 // --------------------------------------------------------------------------------------
940 // End of APRS Types - Code taken from Xastir code 25 March 2008 by Rob Williams M1BGT
941 // Modification made to fit in with Maemo mapper
942 // --------------------------------------------------------------------------------------
943 #endif // INCLUDE_APRS
944
945
946 #endif /* ifndef MAEMO_MAPPER_TYPES_H */