GPS4Palm

Source Code Documentation


Data.h File Reference

#include "Garmin.h"
#include "common.h"

Include dependency graph for Data.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  packed_waypoint_t
struct  route_t

Defines

#define DATA_SECTION   __attribute__ ((section ("database")))

Typedefs

typedef D104_Wpt_Type waypoint_t
typedef D201_Rte_Hdr_Type route_header_t
typedef D300_Trk_Point_Type trk_point_t
typedef D310_Trk_Hdr_Type trk_header_t

Functions

Int16 CompareStringFunc (const Char *str1, const Char *str2, Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, MemHandle appInfoH) DATA_SECTION
 Compare Strings.
Int16 CompareWayptIdent (waypoint_t *rec1, packed_waypoint_t *rec2, Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, MemHandle appInfoH) DATA_SECTION
 Compare Waypoint Identifiers.
Int16 CompareRteNmbr (route_t *rec1, route_t *rec2, Int16 i, SortRecordInfoPtr s1, SortRecordInfoPtr s2, MemHandle appInfoH) DATA_SECTION
 Compare Route Numbers.
void PackWaypoint (waypoint_t *waypoint, UInt16 index) DATA_SECTION
 Pack Waypoint and store it in Database.
void UnpackWaypoint (waypoint_t *waypoint, const packed_waypoint_t *packed_waypoint) DATA_SECTION
 Unpack waypoint retrieved from database.
void PackRouteHdr (route_t *route, UInt16 index) DATA_SECTION
 Store Route Header in Database.
void PackRouteWpt (UInt32 wpt_rec_id, UInt16 index) DATA_SECTION
 Store Route Waypoint in Database (append).
void InsertRouteWpt (UInt16 rec, UInt32 wpt_rec_id, UInt16 wpt_index) DATA_SECTION
 Store Route Waypoint in Database (insert after selection).
void DelRouteWpt (UInt16 rec, UInt16 wpt_index) DATA_SECTION
 Delete Route Waypoint from Database.
void MoveRouteWpt (UInt16 rec, UInt16 wpt_index, Boolean up) DATA_SECTION
 Move Route Waypoint in Database.
void StoreTrkHdr (trk_header_t *trkhdr, UInt16 index) DATA_SECTION
 Store track header in database.
void StoreTrkPoint (trk_point_t *trkpoint, UInt16 index) DATA_SECTION
 Store track point in database.
void TrackDBName (Char *dbname, UInt32 trackID) DATA_SECTION
 Generate Track Point Data Base Name.
void TrackIdent (Char *ident) DATA_SECTION
 Generate Track Identifier from current Time and Date.
void DeleteTracks (void) DATA_SECTION
 Delete all track point databases.
Boolean Position2Geodb (GPSType gps_data) DATA_SECTION
 Add Position to Memo for Import to GeoDB.
Boolean UpdateActWpt (double lat, double lon, Boolean init) DATA_SECTION
 Update active (route) waypoint according to distance to current and next waypoint.
Boolean TrackWriteLog (Boolean new_trk) DATA_SECTION
 Write Track Point to Track Log Data Base.
Boolean TrackIntervalCheck (Boolean init, Boolean *new_trk) DATA_SECTION
 check if track log interval reached
Boolean CheckApproach (double lat, double lon) DATA_SECTION
 check if active waypoint is within proximity distance
void NotifyApproach (void) DATA_SECTION
 generate notification if Active Waypoint is within proximity distance
Err OpenOrCreateDB (DmOpenRef *dbP, UInt32 type, UInt32 creator, UInt16 mode, UInt16 cardNo, char *name, Boolean *created) DATA_SECTION
 Open a database.
void InitializeWaypoints (void) DATA_SECTION
 Creates a Waypoint Database.

Variables

DmOpenRef gWaypointDB
 Waypoint Database Reference.
DmOpenRef gRouteDB
 Route Database Reference.
DmOpenRef gTrackHdrDB
 Track Header Database Reference.
DmOpenRef gTrackDB
 Track Database Reference.


Define Documentation

#define DATA_SECTION   __attribute__ ((section ("database")))
 

Definition at line 92 of file Data.h.


Typedef Documentation

typedef D201_Rte_Hdr_Type route_header_t
 

Definition at line 136 of file Data.h.

typedef D310_Trk_Hdr_Type trk_header_t
 

Definition at line 140 of file Data.h.

typedef D300_Trk_Point_Type trk_point_t
 

Definition at line 138 of file Data.h.

typedef D104_Wpt_Type waypoint_t
 

Definition at line 119 of file Data.h.


Function Documentation

Boolean CheckApproach double  lat,
double  lon
 

check if active waypoint is within proximity distance

If no proximity distance is stored in the waypoint data base (i.e. the proximity distance is zero), a default value is used.

Parameters:
lat current latitude
lon current longitude
Returns:
  • true if active waypoint is within proximity distance
  • false if active waypoint is not within proximity distance

Definition at line 1205 of file Data.c.

References PrefsType::act_wpt, APPROACH_DST, calcR(), D104_Wpt_Type::dst, gc_dist_sphere(), gPrefs, gWaypointDB, Semicircle_Type::lat, Semicircle_Type::lon, D104_Wpt_Type::posn, semi2deg(), UnpackWaypoint(), and ActWayptType::waypointID.

Referenced by NotifyApproach().

Int16 CompareRteNmbr route_t rec1,
route_t rec2,
Int16  i,
SortRecordInfoPtr  s1,
SortRecordInfoPtr  s2,
MemHandle  appInfoH
 

Compare Route Numbers.

Note:
see DmComparF() in PalmOS Reference for parameters
Returns:
  • -1 if nmbr1 < nmbr2
  • 1 if nmbr1 > nmbr2
  • 0 if nmbr1 = nmbr2

Definition at line 233 of file Data.c.

References route_t::nmbr.

Int16 CompareStringFunc const Char *  str1,
const Char *  str2,
Int16  i,
SortRecordInfoPtr  s1,
SortRecordInfoPtr  s2,
MemHandle  appInfoH
 

Compare Strings.

PARAMETERS: see DmComparF() in PalmOS Reference

Returns:
  • -1 if str1 < str2
  • 1 if str1 > str2
  • 0 if str1 = str2

Definition at line 180 of file Data.c.

Referenced by Position2Geodb().

Int16 CompareWayptIdent waypoint_t rec1,
packed_waypoint_t rec2,
Int16  i,
SortRecordInfoPtr  s1,
SortRecordInfoPtr  s2,
MemHandle  appInfoH
 

Compare Waypoint Identifiers.

Note:
The identifiers are not necessarily null-terminated, therefore StrCompare() cannot be used.
PARAMETERS: see DmComparF() in PalmOS Reference

Returns:
  • -1 if ident1 < ident2
  • 1 if ident1 > ident2
  • 0 if ident1 = ident2

Definition at line 201 of file Data.c.

References packed_waypoint_t::ident, and D104_Wpt_Type::ident.

Referenced by InitializeWaypoints(), store_rte(), and store_wpt().

void DeleteTracks void   ) 
 

Delete all track point databases.

Definition at line 779 of file Data.c.

References kCreatorId, and kTrkDBType.

void DelRouteWpt UInt16  rec,
UInt16  wpt_index
 

Delete Route Waypoint from Database.

Parameters:
rec route record index
wpt_index waypoint array index

Definition at line 481 of file Data.c.

References route_t::cmnt, gRouteDB, route_t::items, route_t::nmbr, and route_t::wpt_rec_id.

Referenced by RouteEditFormHandleEvent().

void InitializeWaypoints void   ) 
 

Creates a Waypoint Database.

The Database contains the capitals of all states of the European Community (as of 03/2004). The waypoints were taken from http://wayhoo.com, which in turn uses GNS (http://gnswww.nima.mil/geonames/GNS/index.jsp).

Quoted from Wayhoo: Note: GNS coordinates have a low degree of precision, latitude and longitude.

The Waypoint Identifiers (i.e. short names) are comprised of the ISO Country Code and the IATA (International Air Transport Association) Location ID. (see http://www.iata.org/codes/index.htm)

This is just an example after all.

Definition at line 1359 of file Data.c.

References CompareWayptIdent(), DEG2SEMI, Die(), dspl_smbl_only, gWaypointDB, h, PackWaypoint(), and sym_lrg_cty.

void InsertRouteWpt UInt16  rec,
UInt32  wpt_rec_id,
UInt16  wpt_index
 

Store Route Waypoint in Database (insert after selection).

Parameters:
rec route record index
wpt_rec_id waypoint record ID
wpt_index waypoint array index

Definition at line 417 of file Data.c.

References route_t::cmnt, gRouteDB, route_t::items, route_t::nmbr, and route_t::wpt_rec_id.

Referenced by RouteEditFormHandleEvent().

void MoveRouteWpt UInt16  rec,
UInt16  wpt_index,
Boolean  up
 

Move Route Waypoint in Database.

Parameters:
rec route record index
wpt_index waypoint array index
up direction: true - up / false - down

Definition at line 545 of file Data.c.

References route_t::cmnt, gRouteDB, route_t::items, route_t::nmbr, and route_t::wpt_rec_id.

Referenced by RouteEditFormHandleEvent().

void NotifyApproach void   ) 
 

generate notification if Active Waypoint is within proximity distance

Depending on the user settings, audible and/or visible notification is triggered. In audible only mode, just one alarm sound is played. Otherwise an alert form is opened and has to be acknowledged by the user. After achnowledgement, the notification will not be repeated for this waypoint.

Definition at line 1261 of file Data.c.

References PrefsType::act_wpt, PrefsType::approach_alert, PrefsType::approach_sound, ApproachForm, CheckApproach(), gGPSData, gPrefs, GPSType::lat, GPSType::lon, ActWayptType::valid, GPSType::valid, and ActWayptType::waypointID.

Referenced by MainFormHandleEvent(), MapFormHandleEvent(), NavigationFormHandleEvent(), and SkyviewFormHandleEvent().

Err OpenOrCreateDB DmOpenRef *  dbP,
UInt32  type,
UInt32  creator,
UInt16  mode,
UInt16  cardNo,
char *  name,
Boolean *  created
 

Open a database.

If it doesn't exist, create it.

Parameters:
dbP Database reference ptr
type Type of the database
creator Creator of the database
mode Open mode
cardNo Card number
name Database name
created Flag: new database has been created (return value)
Returns:
Error code of DmOpenDatabaseByTypeCreator() or DmCreateDatabase(), respectively. created -- Flag: new database has been created (returned by reference)

Definition at line 1314 of file Data.c.

void PackRouteHdr route_t route,
UInt16  index
 

Store Route Header in Database.

Parameters:
route ptr to route structure
index route record index

Definition at line 320 of file Data.c.

References route_t::cmnt, Die(), gRouteDB, route_t::items, route_t::nmbr, and route_t::wpt_rec_id.

void PackRouteWpt UInt32  wpt_rec_id,
UInt16  index
 

Store Route Waypoint in Database (append).

Parameters:
wpt_rec_id waypoint record ID
index route record index

Definition at line 367 of file Data.c.

References route_t::cmnt, Die(), gRouteDB, route_t::items, route_t::nmbr, and route_t::wpt_rec_id.

Referenced by store_rte().

void PackWaypoint waypoint_t waypoint,
UInt16  index
 

Pack Waypoint and store it in Database.

Parameters:
waypoint ptr to waypoint structure
index waypoint record index

Definition at line 258 of file Data.c.

References D104_Wpt_Type::cmnt, Die(), D104_Wpt_Type::dspl, D104_Wpt_Type::dst, gWaypointDB, D104_Wpt_Type::ident, Semicircle_Type::lat, Semicircle_Type::lon, D104_Wpt_Type::posn, D104_Wpt_Type::smbl, and StrLen.

Referenced by InitializeWaypoints(), store_rte(), and store_wpt().

Boolean Position2Geodb GPSType  gps_data  ) 
 

Add Position to Memo for Import to GeoDB.

Parameters:
gps_data GPS Data (Time of Fix, Position, ...)
Returns:
True if GPS data is valid.
Note:
GeoDB expects the following format in the Memo:
< memo_name >
< location_name >,< latitude >,< N|S >,< longitude >,< E|W >, < elevation >,< gmt_offset >,< E|W >,< daylight_time >

Example:

AA Adana,37:0.6,N,35:16.8,E,,2,E,0

+ (GPS4Palm only knows the position)

Definition at line 826 of file Data.c.

References CompareStringFunc(), deg_to_geodb_str(), GPSType::lat, GPSType::lon, StrLen, and GPSType::valid.

Referenced by MainFormHandleEvent(), MapFormHandleEvent(), NavigationFormHandleEvent(), and SkyviewFormHandleEvent().

void StoreTrkHdr trk_header_t trkhdr,
UInt16  index
 

Store track header in database.

Parameters:
trkhdr ptr to track header structure
index track header record index

Definition at line 614 of file Data.c.

References D310_Trk_Hdr_Type::color, Die(), D310_Trk_Hdr_Type::dspl, gTrackHdrDB, and D310_Trk_Hdr_Type::trk_ident.

Referenced by store_trk(), and TrackFormHandleEvent().

void StoreTrkPoint trk_point_t trkpoint,
UInt16  index
 

Store track point in database.

Parameters:
trkpoint ptr to track point structure
index track point record index

Definition at line 659 of file Data.c.

References Die(), gTrackDB, D300_Trk_Point_Type::new_trk, D300_Trk_Point_Type::posn, and D300_Trk_Point_Type::time.

Referenced by store_trk(), and TrackWriteLog().

void TrackDBName Char *  dbname,
UInt32  trackID
 

Generate Track Point Data Base Name.

Parameters:
dbname pointer to destination string buffer
trackID track header unique record ID

Definition at line 705 of file Data.c.

References kTrkDBName, nibble2hex(), and StrLen.

Referenced by get_next_trk(), NumTrkPackets(), store_trk(), TrackFormHandleEvent(), and TrackWriteLog().

void TrackIdent Char *  ident  ) 
 

Generate Track Identifier from current Time and Date.

Parameters:
ident pointer to destination string buffer

Definition at line 725 of file Data.c.

References StrCopy, StrLen, and TrackStr.

Referenced by store_trk().

Boolean TrackIntervalCheck Boolean  init,
Boolean *  new_trk
 

check if track log interval reached

Checks if a new track point has to be logged depending on the selected track log mode (time or distance) and interval. A new track segment is started upon initialization or after loosing and regaining coverage.

Parameters:
init init track interval accumulation and start new track segment
new_trk new track segment (returned by reference)
Returns:
  • true if track point log interval passed
  • false if track point log interval not yet passed

Definition at line 1126 of file Data.c.

References calcR(), gc_dist_sphere(), gGPSData, gPrefs, TrkPrefsType::ival, GPSType::lat, GPSType::lon, TrkPrefsType::mode, PrefsType::trk_log, and GPSType::valid.

Referenced by MainFormHandleEvent(), MapFormHandleEvent(), NavigationFormHandleEvent(), SkyviewFormHandleEvent(), and TrackFormHandleEvent().

Boolean TrackWriteLog Boolean  new_trk  ) 
 

Write Track Point to Track Log Data Base.

Parameters:
new_trk new track or track segment
Returns:
- true if successful
  • false if data base is full and wrapping is disabled

Definition at line 1029 of file Data.c.

References PrefsType::act_trk, deg2semi(), Die(), gGPSData, gPrefs, gTrackDB, GPSType::lat, Semicircle_Type::lat, ActTrackType::log_state, GPSType::lon, Semicircle_Type::lon, D300_Trk_Point_Type::new_trk, Palm2GarminTimeDiff, D300_Trk_Point_Type::posn, StoreTrkPoint(), GPSType::time, D300_Trk_Point_Type::time, TrackDBName(), TrackFullAlert, ActTrackType::trackID, PrefsType::trk_log, ActTrackType::valid, and TrkPrefsType::wrap.

Referenced by MainFormHandleEvent(), MapFormHandleEvent(), NavigationFormHandleEvent(), and SkyviewFormHandleEvent().

void UnpackWaypoint waypoint_t waypoint,
const packed_waypoint_t packed_waypoint
 

Unpack waypoint retrieved from database.

Note:
The packed_waypoint must remain locked while the waypoint is in use.
Parameters:
waypoint ptr to unpacked waypoint structure
packed_waypoint ptr to packed waypoint structure

Definition at line 594 of file Data.c.

References packed_waypoint_t::cmnt, D104_Wpt_Type::cmnt, packed_waypoint_t::dspl, D104_Wpt_Type::dspl, packed_waypoint_t::dst, D104_Wpt_Type::dst, packed_waypoint_t::ident, D104_Wpt_Type::ident, Semicircle_Type::lat, Semicircle_Type::lon, packed_waypoint_t::posn, D104_Wpt_Type::posn, packed_waypoint_t::smbl, D104_Wpt_Type::smbl, StrCopy, and D104_Wpt_Type::unused.

Referenced by ApproachFormHandleEvent(), CheckApproach(), get_next_rte(), get_next_wpt(), NavigationFormHandleEvent(), UpdateActWpt(), WaypointFormHandleEvent(), and WayptEditFormHandleEvent().

Boolean UpdateActWpt double  lat,
double  lon,
Boolean  init
 

Update active (route) waypoint according to distance to current and next waypoint.

The current implementation switches to the next route waypoint even if the current waypoint is just "passed by", i.e. the distance to the current waypoint is increasing while the distance to the next waypoint is decreasing.

A different implementation could require the current waypoint to be "visited" with the proximity information stored in the waypoint record as the criterion.

Parameters:
lat current latitude
lon current longitude
init initialize function (after changing route)
Returns:
  • true if next waypoint has been select as active waypoint
  • false if current waypoint is still active waypoint
Note:
After changing the active route, the finction must be called with init=true (lat/lon may be invalid). This marks the distance values stored previously invalid. The next call which must occur with a valid position updates the stored distance values. Any subsequent call will then provide a correct waypoint selection.

Definition at line 911 of file Data.c.

References PrefsType::act_rte, PrefsType::act_wpt, gc_dist_sphere(), gPrefs, gRouteDB, gWaypointDB, route_t::items, Semicircle_Type::lat, Semicircle_Type::lon, D104_Wpt_Type::posn, ActRouteType::routeID, semi2deg(), UnpackWaypoint(), ActWayptType::waypointID, ActRouteType::wpt_index, and route_t::wpt_rec_id.

Referenced by MainFormHandleEvent(), MapFormHandleEvent(), NavigationFormHandleEvent(), RouteFormHandleEvent(), and SkyviewFormHandleEvent().


Variable Documentation

DmOpenRef gRouteDB
 

Route Database Reference.

Definition at line 108 of file Data.c.

DmOpenRef gTrackDB
 

Track Database Reference.

Definition at line 110 of file Data.c.

Referenced by StoreTrkPoint(), TrackFormHandleEvent(), and TrackWriteLog().

DmOpenRef gTrackHdrDB
 

Track Header Database Reference.

Definition at line 109 of file Data.c.

Referenced by get_next_trk(), NumTrkPackets(), store_trk(), StoreTrkHdr(), trackDrawTable(), and TrackFormHandleEvent().

DmOpenRef gWaypointDB
 

Waypoint Database Reference.

Definition at line 107 of file Data.c.


Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke