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