00001 /***************************************************************************** 00002 * 00003 * $RCSfile: Data_8h-source.html,v $ 00004 * 00005 * GPS4Palm Data Base Definitions (Waypoints) 00006 * 00007 * This program is Copyright (C) 03/2003 Matthias Prinke 00008 * <matthias.prinke@surfeu.de> and covered by GNU's GPL. 00009 * In particular, this program is free software and comes WITHOUT 00010 * ANY WARRANTY. 00011 * 00012 * $Author: mp $ 00013 * 00014 * $Date: 2007-10-08 20:40:32 $ 00015 * 00016 * $Revision: 1.7.2.1 $ 00017 * 00018 * $Log: Data_8h-source.html,v $ 00018 * Revision 1.7.2.1 2007-10-08 20:40:32 mp 00018 * updated for gps4palm V0.9.5 beta 00018 * 00019 * Revision 1.19 2005-04-02 17:25:36 mp 00020 * added CompareStringFunc() and Position2Geodb(), removed CompareIDFunc() 00021 * 00022 * Revision 1.18 2005/02/05 17:33:42 mp 00023 * added DeleteTracks() 00024 * 00025 * Revision 1.17 2004/12/08 21:01:31 mp 00026 * added Track data description 00027 * 00028 * Revision 1.16 2004/12/08 20:50:25 mp 00029 * added TrackIntervalCheck() 00030 * 00031 * Revision 1.15 2004/12/07 17:15:33 mp 00032 * added TrackWriteLog() 00033 * 00034 * Revision 1.14 2004/12/04 09:39:18 mp 00035 * added trk_point_t, trk_header_t, StoreTrkHdr(), StoreTrkPoint(), 00036 * TrackDBName(), and TrackIdent() 00037 * 00038 * Revision 1.13 2004/11/25 20:04:28 mp 00039 * added NotifyApproach() 00040 * 00041 * Revision 1.12 2004/11/25 16:58:33 mp 00042 * added CheckApproach() 00043 * 00044 * Revision 1.11 2004/11/20 15:51:59 mp 00045 * added UpdateActWpt() 00046 * 00047 * Revision 1.10 2004/11/16 20:41:55 mp 00048 * modified PackWaypoint(), PackRouteHdr(), and PackRouteWpt() 00049 * 00050 * Revision 1.9 2004/11/16 18:51:35 mp 00051 * modified InsertRouteWpt() 00052 * 00053 * Revision 1.8 2004/11/15 19:51:53 mp 00054 * modified PackRouteHdr() and PackRouteWpt(), added InsertRouteWpt(), 00055 * DelRouteWpt(), and MoveRouteWpt() 00056 * 00057 * Revision 1.7 2004/11/11 18:47:21 mp 00058 * moved functions to 'database' section 00059 * 00060 * Revision 1.6 2004/06/23 17:56:58 mp 00061 * added routes 00062 * 00063 * Revision 1.5 2004/04/27 18:57:03 mp 00064 * removed examples, added route DB support 00065 * 00066 * Revision 1.4 2004/03/12 20:56:58 mp 00067 * added InitializeWaypoints() 00068 * 00069 * Revision 1.3 2004/03/10 17:23:03 mp 00070 * Removed member waypointID from waypoint_t and packed_waypoint_t 00071 * 00072 * Revision 1.2 2004/03/09 19:11:22 mp 00073 * Added #include "Garmin.h". Moved some functions to "database" 00074 * code section. 00075 * 00076 * Revision 1.1 2004/03/07 14:26:39 mp 00077 * initial version 00078 * 00079 ****************************************************************************/ 00080 #ifndef DATA_H 00081 #define DATA_H 00082 00083 /* Garmin Data Types and Data Structures */ 00084 #include "Garmin.h" 00085 00086 /* GPS4Palm Data Types and Data Structures */ 00087 #include "common.h" 00088 00089 /* 00090 * The database functions are in their own segment 00091 */ 00092 #define DATA_SECTION __attribute__ ((section ("database"))) 00093 00094 /* 00095 Databases: 00096 Waypoints: (sorted by identifier) 00097 D104_Wpt_Type: packed 00098 00099 Routes: (sorted by route number) 00100 D201_Rte_Hdr_Type 00101 UInt16 numItems: number of Waypoints on Route 00102 UInt32 Wpt_Rec_Id: PalmOS Database Record ID of Waypoint 00103 [...]: more Wpt_Rec_Id's 00104 00105 Tracks: (not sorted - new items are appended) 00106 Track Header Database: 00107 D310_Trk_Hdr_Type 00108 Track Point Database(s): 00109 D300_Trk_Point_Type 00110 00111 Note: Only track header database exists; it contains one record for each 00112 track. One track point database exists for each track. Its name is 00113 derived from the unique record ID of the associated track header 00114 record. The track point data base can contain 0..dmMaxRecordIndex 00115 records, one for each track point. 00116 00117 */ 00118 00119 typedef D104_Wpt_Type waypoint_t; 00120 00121 /* 00122 * Waypoint DB record 00123 */ 00124 typedef struct { 00125 char ident[6]; /* identifier (string) */ 00126 Semicircle_Type posn; /* position */ 00127 float dst; /* proximity distance (meters) */ 00128 Symbol_Type smbl; /* symbol ID */ 00129 byte dspl; /* display option */ 00130 char cmnt[1]; /* comment, actually may be */ 00131 /* longer than 1, but no more */ 00132 /* than 40 */ 00133 /* (including null terminator) */ 00134 } packed_waypoint_t; 00135 00136 typedef D201_Rte_Hdr_Type route_header_t; 00137 00138 typedef D300_Trk_Point_Type trk_point_t; 00139 00140 typedef D310_Trk_Hdr_Type trk_header_t; 00141 00142 /* 00143 * Route DB record 00144 * 00145 * Note: The first two members are compliant to the D201_Rte_Hdr_Type, 00146 * but additional space for the string delimiter of the comment 00147 * is provided. 00148 * This also provides alignment of the fields "items" and 00149 * "wpt_rec_id" to the proper boundaries. 00150 */ 00151 typedef struct { 00152 G_byte nmbr; /* route number */ 00153 G_char cmnt[21]; /* comment */ 00154 UInt16 items; /* number of waypoints on route */ 00155 UInt32 wpt_rec_id[1]; /* array of waypoint record IDs, */ 00156 /* actually may be longer than 1 */ 00157 } route_t; 00158 00159 00160 extern DmOpenRef gWaypointDB; 00161 extern DmOpenRef gRouteDB; 00162 extern DmOpenRef gTrackHdrDB; 00163 extern DmOpenRef gTrackDB; 00164 00165 00166 Int16 CompareStringFunc(const Char *str1, const Char *str2, 00167 Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, 00168 MemHandle appInfoH) DATA_SECTION; 00169 Int16 CompareWayptIdent(waypoint_t *rec1, packed_waypoint_t *rec2, 00170 Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, 00171 MemHandle appInfoH) DATA_SECTION; 00172 Int16 CompareRteNmbr(route_t *rec1, route_t *rec2, 00173 Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, 00174 MemHandle appInfoH) DATA_SECTION; 00175 00176 void PackWaypoint(waypoint_t *waypoint, UInt16 index) DATA_SECTION; 00177 void UnpackWaypoint(waypoint_t *waypoint, 00178 const packed_waypoint_t *packed_waypoint) DATA_SECTION; 00179 void PackRouteHdr(route_t *route, UInt16 index) DATA_SECTION; 00180 void PackRouteWpt(UInt32 wpt_rec_id, UInt16 index) DATA_SECTION; 00181 void InsertRouteWpt(UInt16 rec, UInt32 wpt_rec_id, 00182 UInt16 wpt_index) DATA_SECTION; 00183 void DelRouteWpt(UInt16 rec, UInt16 wpt_index) DATA_SECTION; 00184 void MoveRouteWpt(UInt16 rec, UInt16 wpt_index, 00185 Boolean up) DATA_SECTION; 00186 void StoreTrkHdr(trk_header_t *trkhdr, UInt16 index) DATA_SECTION; 00187 void StoreTrkPoint(trk_point_t *trkpoint, UInt16 index) DATA_SECTION; 00188 void TrackDBName(Char *dbname, UInt32 trackID) DATA_SECTION; 00189 void TrackIdent(Char *ident) DATA_SECTION; 00190 void DeleteTracks(void) DATA_SECTION; 00191 Boolean Position2Geodb(GPSType gps_data) DATA_SECTION; 00192 Boolean UpdateActWpt(double lat, double lon, 00193 Boolean init) DATA_SECTION; 00194 Boolean TrackWriteLog(Boolean new_trk) DATA_SECTION; 00195 Boolean TrackIntervalCheck(Boolean init, 00196 Boolean *new_trk) DATA_SECTION; 00197 Boolean CheckApproach(double lat, double lon) DATA_SECTION; 00198 void NotifyApproach(void) DATA_SECTION; 00199 00200 Err OpenOrCreateDB(DmOpenRef *dbP, UInt32 type, UInt32 creator, UInt16 mode, 00201 UInt16 cardNo, char *name, Boolean *created) DATA_SECTION; 00202 void InitializeWaypoints(void) DATA_SECTION; 00203 00204 #ifdef DEBUG_BUILD 00205 void CheckDatabases(void) DATA_SECTION; 00206 #endif 00207 #endif