2 * Copyright (C) 2006, 2007 John Costigan.
4 * POI and GPS-Info code originally written by Cezary Jackiewicz.
6 * Default map data provided by http://www.openstreetmap.org/
8 * This file is part of Maemo Mapper.
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.
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.
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/>.
24 * Parts of this code have been ported from Xastir by Rob Williams (10 Aug 2008):
26 * * XASTIR, Amateur Station Tracking and Information Reporting
27 * Copyright (C) 1999,2000 Frank Giannandrea
28 * Copyright (C) 2000-2007 The Xastir Group
32 #ifndef MAEMO_MAPPER_TYPES_H
33 #define MAEMO_MAPPER_TYPES_H
43 #include <libgnomevfs/gnome-vfs.h>
45 #define _(String) gettext(String)
47 /* #define MAPDB_SQLITE */
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
66 #define MAX_DEVICE_BUFFER 4096
68 /** This enumerated type defines the possible connection states. */
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. */
76 /** The connection with the receiver is down. A gtk_banner is visible with
77 * the text, "Connecting to GPS receiver". */
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". */
84 /** The connection with the receiver is up and a GPS fix IS available.
85 * No gtk_banner is visible. */
89 /** This enumerated type defines the supported types of repositories. */
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" */
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
106 CENTER_WAS_LATLON = -2,
107 CENTER_WAS_LEAD = -1,
112 /** POI dialog action **/
119 /** Category list **/
147 /** This enum defines the possible units we can use. */
166 /** This enum defines the possible font sizes. */
179 /** This enum defines the possible font sizes. */
186 ROTATE_DIR_ENUM_COUNT
189 /** This enum defines all of the key-customizable actions. */
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
227 /** This enum defines all of the customizable keys. */
237 CUSTOM_KEY_FULLSCREEN,
239 CUSTOM_KEY_ENUM_COUNT
242 /** This enum defines all of the colorable objects. */
246 COLORABLE_MARK_VELOCITY,
249 COLORABLE_TRACK_MARK,
250 COLORABLE_TRACK_BREAK,
253 COLORABLE_ROUTE_BREAK,
256 COLORABLE_APRS_STATION,
257 #endif // INCLUDE_APRS
273 UK_NGR, // 8 char grid ref
274 UK_NGR6,// 6 char grid ref
276 DEG_FORMAT_ENUM_COUNT
279 typedef struct _CoordFormatSetup CoordFormatSetup;
280 struct _CoordFormatSetup
283 gchar *short_field_1;
285 gchar *short_field_2;
287 gboolean field_2_in_use;
292 SPEED_LOCATION_BOTTOM_LEFT,
293 SPEED_LOCATION_BOTTOM_RIGHT,
294 SPEED_LOCATION_TOP_RIGHT,
295 SPEED_LOCATION_TOP_LEFT,
296 SPEED_LOCATION_ENUM_COUNT
302 MAP_UPDATE_OVERWRITE,
305 MAP_UPDATE_ENUM_COUNT
316 /** A general definition of a point in the Maemo Mapper unit system. */
317 typedef struct _Point Point;
325 /** A WayPoint, which is a Point with a description. */
326 typedef struct _WayPoint WayPoint;
332 /** A Path is a set of PathPoints and WayPoints. */
333 typedef struct _Path Path;
335 Point *head; /* points to first element in array; NULL if empty. */
336 Point *tail; /* points to last element in array. */
337 Point *cap; /* points after last slot in array. */
338 WayPoint *whead; /* points to first element in array; NULL if empty. */
339 WayPoint *wtail; /* points to last element in array. */
340 WayPoint *wcap; /* points after last slot in array. */
343 /** Data to describe a POI. */
344 typedef struct _PoiInfo PoiInfo;
355 /** Data regarding a map repository. */
356 typedef struct _RepoData RepoData;
363 gint view_zoom_steps;
364 gboolean double_size;
371 gboolean layer_enabled;
372 gboolean layer_was_enabled; /* needed for ability to temporarily toggle layers on and off */
373 gint layer_refresh_interval;
374 gint layer_refresh_countdown;
377 sqlite3_stmt *stmt_map_select;
378 sqlite3_stmt *stmt_map_exists;
379 sqlite3_stmt *stmt_map_update;
380 sqlite3_stmt *stmt_map_insert;
381 sqlite3_stmt *stmt_map_delete;
382 sqlite3_stmt *stmt_dup_select;
383 sqlite3_stmt *stmt_dup_exists;
384 sqlite3_stmt *stmt_dup_insert;
385 sqlite3_stmt *stmt_dup_increm;
386 sqlite3_stmt *stmt_dup_decrem;
387 sqlite3_stmt *stmt_dup_delete;
388 sqlite3_stmt *stmt_trans_begin;
389 sqlite3_stmt *stmt_trans_commit;
390 sqlite3_stmt *stmt_trans_rollback;
394 GtkWidget *menu_item;
397 /** GPS Data and Satellite **/
398 typedef struct _GpsData GpsData;
404 gfloat speed; /* in knots */
405 gfloat maxspeed; /* in knots */
415 typedef struct _GpsSatelliteData GpsSatelliteData;
416 struct _GpsSatelliteData {
423 /** Data used for rendering the entire screen. */
424 typedef struct _MapRenderTask MapRenderTask;
425 struct _MapRenderTask
431 gint screen_width_pixels;
432 gint screen_height_pixels;
439 /** Data used for rendering the entire screen. */
440 typedef struct _MapOffsetArgs MapOffsetArgs;
441 struct _MapOffsetArgs
443 gfloat old_center_offset_devx;
444 gfloat old_center_offset_devy;
445 gfloat new_center_offset_devx;
446 gfloat new_center_offset_devy;
448 gfloat percent_complete;
451 typedef struct _ThreadLatch ThreadLatch;
455 gboolean is_done_adding_tasks;
462 /** Data used during the asynchronous progress update phase of automatic map
464 typedef struct _MapUpdateTask MapUpdateTask;
465 struct _MapUpdateTask
470 ThreadLatch *refresh_latch;
480 /** Data used during the asynchronous automatic route downloading operation. */
481 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
482 struct _AutoRouteDownloadData {
484 gboolean in_progress;
487 gboolean avoid_highways;
490 /** Data to describe the GPS connection. */
491 typedef struct _GpsRcvrInfo GpsRcvrInfo;
492 struct _GpsRcvrInfo {
500 typedef struct _BrowseInfo BrowseInfo;
509 // --------------------------------------------------------------------------------------
510 // Start of APRS Types - Code taken from Xastir code 25 March 2008 by Rob Williams
511 // Modification made to fit in with Maemo mapper
512 // --------------------------------------------------------------------------------------
514 typedef struct _TWriteBuffer TWriteBuffer;
517 int write_in_pos; /* current write buffer input pos */
518 int write_out_pos; /* current write buffer output pos */
519 GMutex* write_lock; /* Lock for writing the port data */
520 char device_write_buffer[MAX_DEVICE_BUFFER];/* write buffer for this port */
538 // We should probably be using APRS_DF in extract_bearing_NRQ()
539 // and extract_omnidf() functions. We aren't currently.
540 /* Define APRS Types */
545 APRS_DOWN, // Not used anymore
572 /* Define Record Types */
573 #define NORMAL_APRS 'N'
574 #define MOBILE_APRS 'M'
576 #define DOWN_APRS 'Q'
577 #define NORMAL_GPS_RMC 'C'
578 #define NORMAL_GPS_GGA 'A'
579 #define NORMAL_GPS_GLL 'L'
581 /* define RECORD ACTIVES */
582 #define RECORD_ACTIVE 'A'
583 #define RECORD_NOTACTIVE 'N'
584 #define RECORD_CLOSED 'C'
586 /* define data from info type */
587 #define DATA_VIA_LOCAL 'L'
588 #define DATA_VIA_TNC 'T'
589 #define DATA_VIA_NET 'I'
590 #define DATA_VIA_FILE 'F'
593 /* define Heard info type */
595 #define NOT_VIA_TNC 'N'
597 /* define Message types */
598 #define MESSAGE_MESSAGE 'M'
599 #define MESSAGE_BULLETIN 'B'
600 #define MESSAGE_NWS 'W'
603 // trail flag definitions
604 #define MAX_CALLSIGN 9
608 #define MAX_ALTITUDE 10 //-32808.4 to 300000.0? feet
609 #define MAX_SPEED 9 /* ?? 3 in knots */
610 #define MAX_COURSE 7 /* ?? */
611 #define MAX_POWERGAIN 7
612 #define MAX_STATION_TIME 10 /* 6+1 */
614 #define MAX_DISTANCE 10
615 #define MAX_WXSTATION 50
617 #define MAX_MULTIPOINTS 35
619 #define MAX_DEVICE_BUFFER 4096
621 /* define max size of info field */
622 #define MAX_INFO_FIELD_SIZE 256
624 // Number of times to send killed objects/items before ceasing to
626 #define MAX_KILLED_OBJECT_RETRANSMIT 20
628 // Check entire station list at this rate for objects/items that
629 // might need to be transmitted via the decaying algorithm. This is
630 // the start rate, which gets doubled on each transmit.
631 #define OBJECT_CHECK_RATE 20
634 #define MAX_MESSAGE_LENGTH 100
635 #define MAX_MESSAGE_ORDER 10
638 #define CHECKMALLOC(m) if (!m) { fprintf(stderr, "***** Malloc Failed *****\n"); exit(0); }
641 #define STATION_REMOVE_CYCLE 300 /* check station remove in seconds (every 5 minutes) */
642 #define MESSAGE_REMOVE_CYCLE 600 /* check message remove in seconds (every 10 minutes) */
643 #define IN_VIEW_MIN 600l /* margin for off-screen stations, with possible trails on screen, in minutes */
644 #define TRAIL_POINT_MARGIN 30l /* margin for off-screen trails points, for segment to be drawn, in minutes */
645 #define TRAIL_MAX_SPEED 900 /* max. acceptible speed for drawing trails, in mph */
646 #define MY_TRAIL_COLOR 0x16 /* trail color index reserved for my station */
647 #define TRAIL_ECHO_TIME 30 /* check for delayed echos during last 30 minutes */
648 /* MY_TRAIL_DIFF_COLOR changed to user configurable my_trail_diff_color */
655 int mobiles_in_motion;
661 // station flag definitions. We have 16 bits available here as
662 // "flag" in "DataRow" is defined as a short.
664 #define ST_OBJECT 0x01 // station is an object
665 #define ST_ITEM 0x02 // station is an item
666 #define ST_ACTIVE 0x04 // station is active (deleted objects are
668 #define ST_MOVING 0x08 // station is moving
669 #define ST_DIRECT 0x10 // heard direct (not via digis)
670 #define ST_VIATNC 0x20 // station heard via TNC
671 #define ST_3RD_PT 0x40 // third party traffic (not used yet)
672 #define ST_MSGCAP 0x80 // message capable (not used yet)
673 #define ST_STATUS 0x100 // got real status message
674 #define ST_INVIEW 0x200 // station is in current screen view
675 #define ST_MYSTATION 0x400 // station is owned by my call-SSID
676 #define ST_MYOBJITEM 0x800 // object/item owned by me
679 #define TR_LOCAL 0x01 // heard direct (not via digis)
680 #define TR_NEWTRK 0x02 // start new track
683 enum AprsAreaObjectTypes {
684 AREA_OPEN_CIRCLE = 0x0,
685 AREA_LINE_LEFT = 0x1,
686 AREA_OPEN_ELLIPSE = 0x2,
687 AREA_OPEN_TRIANGLE = 0x3,
689 AREA_FILLED_CIRCLE = 0x5,
690 AREA_LINE_RIGHT = 0x6,
691 AREA_FILLED_ELLIPSE = 0x7,
692 AREA_FILLED_TRIANGLE = 0x8,
693 AREA_FILLED_BOX = 0x9,
700 enum AprsAreaObjectColors {
706 AREA_VIOLET_HI = 0x5,
707 AREA_YELLOW_HI = 0x6,
714 AREA_VIOLET_LO = 0xD,
715 AREA_YELLOW_LO = 0xE,
723 unsigned sqrt_lat_off : 8;
724 unsigned sqrt_lon_off : 8;
725 unsigned corridor_width : 16;
731 char special_overlay;
732 AprsAreaObject area_object;
735 // Struct for holding track data. Keeps a dynamically allocated
736 // doubly-linked list of track points. The first record should have its
737 // "prev" pointer set to NULL and the last record should have its "next"
738 // pointer set to NULL. If no track storage exists then the pointers to
739 // these structs in the DataRow struct should be NULL.
740 typedef struct _AprsTrackRow{
741 long trail_long_pos; // coordinate of trail point
742 long trail_lat_pos; // coordinate of trail point
743 time_t sec; // date/time of position
744 long speed; // in 0.1 km/h undefined: -1
745 int course; // in degrees undefined: -1
746 long altitude; // in 0.1 m undefined: -99999
747 char flag; // several flags, see below
748 struct _AprsTrackRow *prev; // pointer to previous record in list
749 struct _AprsTrackRow *next; // pointer to next record in list
754 // Struct for holding current weather data.
755 // This struct is pointed to by the DataRow structure.
756 // An empty string indicates undefined data.
757 typedef struct { // strlen
759 int wx_storm; // Set to one if severe storm
760 char wx_time[MAX_TIME];
761 char wx_course[4]; // in ° 3
762 char wx_speed[4]; // in mph 3
763 time_t wx_speed_sec_time;
764 char wx_gust[4]; // in mph 3
765 char wx_hurricane_radius[4]; //nautical miles 3
766 char wx_trop_storm_radius[4]; //nautical miles 3
767 char wx_whole_gale_radius[4]; // nautical miles 3
768 char wx_temp[5]; // in °F 3
769 char wx_rain[10]; // in hundredths inch/h 3
770 char wx_rain_total[10]; // in hundredths inch
771 char wx_snow[6]; // in inches/24h 3
772 char wx_prec_24[10]; // in hundredths inch/day 3
773 char wx_prec_00[10]; // in hundredths inch 3
774 char wx_hum[5]; // in % 3
775 char wx_baro[10]; // in hPa 6
776 char wx_fuel_temp[5]; // in °F 3
777 char wx_fuel_moisture[5];// in % 2
779 char wx_station[MAX_WXSTATION];
783 // Struct for holding comment/status data. Will keep a dynamically
784 // allocated list of text. Every different comment field will be
785 // stored in a separate line.
786 typedef struct _AprsCommentRow{
787 char *text_ptr; // Ptr to the comment text
788 time_t sec_heard; // Latest timestamp for this comment/status
789 struct _AprsCommentRow *next; // Ptr to next record or NULL
795 // Struct for holding multipoint data.
796 typedef struct _AprsMultipointRow{
797 long multipoints[MAX_MULTIPOINTS][2];
800 typedef struct _AprsDisplayData
802 gchar *call_sign; // call sign or name index or object/item
807 gchar *coord_lat_lon;
814 typedef struct _AprsDataRow {
816 struct _AprsDataRow *n_next; // pointer to next element in name ordered list
817 struct _AprsDataRow *n_prev; // pointer to previous element in name ordered
819 struct _AprsDataRow *t_newer; // pointer to next element in time ordered
821 struct _AprsDataRow *t_older; // pointer to previous element in time ordered
825 char call_sign[MAX_CALLSIGN+1]; // call sign or name index or object/item
827 char *tactical_call_sign; // Tactical callsign. NULL if not assigned
828 APRS_Symbol aprs_symbol;
829 long coord_lon; // Xastir coordinates 1/100 sec, 0 = 180°W
830 long coord_lat; // Xastir coordinates 1/100 sec, 0 = 90°N
832 int time_sn; // serial number for making time index unique
833 time_t sec_heard; // time last heard, used also for time index
834 time_t heard_via_tnc_last_time;
835 time_t direct_heard; // KC2ELS - time last heard direct
837 // Change into time_t structs? It'd save us a bunch of space.
838 char packet_time[MAX_TIME];
839 char pos_time[MAX_TIME];
841 short flag; // several flags, see below
842 char pos_amb; // Position ambiguity, 0 = none,
845 unsigned int error_ellipse_radius; // Degrades precision for this
846 // station, from 0 to 65535 cm or
847 // 655.35 meters. Assigned when we
848 // decode each type of packet.
849 // Default is 6.0 meters (600 cm)
850 // unless we know the GPS position
851 // is augmented, or is degraded by
852 // less precision in the packet.
854 unsigned int lat_precision; // In 100ths of a second latitude
855 unsigned int lon_precision; // In 100ths of a second longitude
857 int trail_color; // trail color (when assigned)
859 //char data_via; // L local, T TNC, I internet, F file
861 // Change to char's to save space?
862 int heard_via_tnc_port; // Current this will always be 0, but keep for future
863 TAprsPort last_port_heard; // Current this will always be 0, but keep for future
864 unsigned int num_packets;
865 char *node_path_ptr; // Pointer to path string
866 char altitude[MAX_ALTITUDE]; // in meters (feet gives better resolution ??)
867 char speed[MAX_SPEED+1]; // in knots (same as nautical miles/hour)
868 char course[MAX_COURSE+1];
869 char bearing[MAX_COURSE+1];
870 char NRQ[MAX_COURSE+1];
871 char power_gain[MAX_POWERGAIN+1]; // Holds the phgd values
872 char signal_gain[MAX_POWERGAIN+1]; // Holds the shgd values (for DF'ing)
874 AprsWeatherRow *weather_data; // Pointer to weather data or NULL
876 AprsCommentRow *status_data; // Ptr to status records or NULL
877 AprsCommentRow *comment_data; // Ptr to comment records or NULL
879 // Below two pointers are NULL if only one position has been received
880 AprsTrackRow *oldest_trackpoint; // Pointer to oldest track point in
881 // doubly-linked list
882 AprsTrackRow *newest_trackpoint; // Pointer to newest track point in
883 // doubly-linked list
885 // When the station is an object, it can include coordinates
886 // of related points. Currently these are being used to draw
887 // outlines of NWS severe weather watches and warnings, and
888 // storm regions. The coordinates are stored here in Xastir
889 // coordinate form. Element [x][0] is the latitude, and
890 // element [x][1] is the longitude. --KG4NBB
892 // Is there anything preventing a multipoint string from being
893 // in other types of packets, in the comment field? --WE7U
896 char type; // from '0' to '9'
897 char style; // from 'a' to 'z'
898 AprsMultipointRow *multipoint_data;
901 ///////////////////////////////////////////////////////////////////////
902 // Optional stuff for Objects/Items only (I think, needs to be
903 // checked). These could be moved into an ObjectRow structure, with
904 // only a NULL pointer here if not an object/item.
905 ///////////////////////////////////////////////////////////////////////
907 char origin[MAX_CALLSIGN+1]; // call sign originating an object
908 short object_retransmit; // Number of times to retransmit object.
910 // Used currently to stop sending killed
912 time_t last_transmit_time; // Time we last transmitted an object/item.
913 // Used to implement decaying transmit time
915 short transmit_time_increment; // Seconds to add to transmit next time
916 // around. Used to implement decaying
917 // transmit time algorithm
918 // time_t last_modified_time; // Seconds since the object/item
919 // was last modified. We'll
920 // eventually use this for
922 char signpost[5+1]; // Holds signpost data
924 char sats_visible[MAX_SAT];
925 char probability_min[10+1]; // Holds prob_min (miles)
926 char probability_max[10+1]; // Holds prob_max (miles)
947 typedef struct _AprsStationList{
948 struct _AprsStationList *next; // pointer to next record in list
949 AprsDataRow *station;
955 // --------------------------------------------------------------------------------------
956 // End of APRS Types - Code taken from Xastir code 25 March 2008 by Rob Williams M1BGT
957 // Modification made to fit in with Maemo mapper
958 // --------------------------------------------------------------------------------------
959 #endif // INCLUDE_APRS
962 #endif /* ifndef MAEMO_MAPPER_TYPES_H */