00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #define PI 3.14159265358979323846
00045 static const UInt32 OnePower31 = (1UL << 31);
00046 static const UInt32 OnePower31Pi = (1UL << 31) / PI;
00047
00048
00049 #define GPSUDBG_INFOS 128 // informational
00050 #define GPSUDBG_CALLS 32 // procedures calls/exits
00051 #define GPSUDBG_UNEXP 8 // unexpected things
00052
00053 #define BadCoordinate -1000.
00054 #define OBJECTVERSION 2
00055
00056
00057 #define NextObject(o) ( (char *)o + SizeOfObject(o) )
00058
00059 #ifndef GPSLDBG_INFOS // si gpslib pas deja inclus
00060 typedef void LogProc (char *p);
00061 typedef LogProc *LogProcPtr;
00062 #endif
00063
00064
00065 extern UInt16 SizeOfObject (Object * p) UTIL_SECTION;
00066 extern UInt16 ObjectsInRec (MemHandle RecH) UTIL_SECTION;
00067 extern UInt16 OffsetOfObjectInRec (MemHandle RecH, UInt16 n) UTIL_SECTION;
00068 extern UInt16 G100ToCustom (Raw_D100_Wpt_Type * p100, Custom_Wpt_Type * pcust) UTIL_SECTION;
00069 extern UInt16 G102ToCustom (Raw_D102_Wpt_Type * p102, Custom_Wpt_Type * pcust) UTIL_SECTION;
00070 extern UInt16 G103ToCustom (Raw_D103_Wpt_Type * p103, Custom_Wpt_Type * pcust) UTIL_SECTION;
00071 extern UInt16 G104ToCustom (Raw_D104_Wpt_Type * p104, Custom_Wpt_Type * pcust) UTIL_SECTION;
00072 extern UInt16 G105ToCustom (Raw_D105_Wpt_Type * p105, Custom_Wpt_Type * pcust) UTIL_SECTION;
00073 extern UInt16 G107ToCustom (Raw_D107_Wpt_Type * p107, Custom_Wpt_Type * pcust) UTIL_SECTION;
00074 extern UInt16 G108ToCustom (Raw_D108_Wpt_Type * p108, Custom_Wpt_Type * pcust) UTIL_SECTION;
00075 extern UInt16 G109ToCustom (Raw_D109_Wpt_Type * p109, Custom_Wpt_Type * pcust) UTIL_SECTION;
00076 extern UInt16 CustomToG100 (Custom_Wpt_Type * pcust, Raw_D100_Wpt_Type * p100) UTIL_SECTION;
00077 extern UInt16 CustomToG102 (Custom_Wpt_Type * pcust, Raw_D102_Wpt_Type * p102) UTIL_SECTION;
00078 extern UInt16 CustomToG103 (Custom_Wpt_Type * pcust, Raw_D103_Wpt_Type * p103) UTIL_SECTION;
00079 extern UInt16 CustomToG104 (Custom_Wpt_Type * pcust, Raw_D104_Wpt_Type * p104) UTIL_SECTION;
00080 extern UInt16 CustomToG105 (Custom_Wpt_Type * pcust, Raw_D105_Wpt_Type * p105) UTIL_SECTION;
00081 extern UInt16 CustomToG107 (Custom_Wpt_Type * pcust, Raw_D107_Wpt_Type * p107) UTIL_SECTION;
00082 extern UInt16 CustomToB108 (Custom_Wpt_Type * pcust, B108_Wpt_Type * p108, Boolean merge) UTIL_SECTION;
00083 extern UInt16 CustomToB109 (Custom_Wpt_Type * pcust, B109_Wpt_Type * p109, Boolean merge) UTIL_SECTION;
00084 extern LocalFormatID PtrToCustomWpt (Object * recp, Custom_Wpt_Type * pcust) UTIL_SECTION;
00085 extern LocalFormatID HandleToCustomWpt (ObjectHandle RecH, Custom_Wpt_Type * pcust) UTIL_SECTION;
00086 extern LocalFormatID IndexToCustomWpt (UInt16 index, DmOpenRef DB, Custom_Wpt_Type * pcust) UTIL_SECTION;
00087 extern Err CustomToAnyWpt (Custom_Wpt_Type * pcust, LocalFormatID format, ObjectPtr newp,
00088 Boolean merge) UTIL_SECTION;
00089 extern Object *AnyToAnyWpt (Object * from, Object * to, LocalFormatID toformat) UTIL_SECTION;
00090 extern UInt16 WptsInRteDB (MemHandle RecH) UTIL_SECTION;
00091 extern LocalFormatID PtrToCustomRteHdr (Object * recp, Custom_Rte_Hdr_Type * pcust) UTIL_SECTION;
00092 extern LocalFormatID HandleToCustomRteHdr (MemHandle RecH, Custom_Rte_Hdr_Type * pcust) UTIL_SECTION;
00093 extern Object *CustomToRteHdrObj (Custom_Rte_Hdr_Type * pcust, Object * o, LocalFormatID toformat) UTIL_SECTION;
00094 extern Object *AnyToAnyRteHdr (Object * from, Object * to, LocalFormatID toformat) UTIL_SECTION;
00095 extern UInt16 TrkptsInTrkDB (MemHandle rech) UTIL_SECTION;
00096
00097
00098
00099
00100 extern void CustomToRawD301TrkPt (Custom_Trk_Point_Type * from, Raw_D301_Trk_Point_Type * to) UTIL_SECTION;
00101 extern void CompactToRawD301TrkPt (Compact_Trk_Point_Type * from, Raw_D301_Trk_Point_Type * to) UTIL_SECTION;
00102 extern void CustomToRawD300TrkPt (Custom_Trk_Point_Type * from, Raw_D300_Trk_Point_Type * to) UTIL_SECTION;
00103 extern void CompactToRawD300TrkPt (Compact_Trk_Point_Type * from, Raw_D300_Trk_Point_Type * to) UTIL_SECTION;
00104 extern UInt16 AnyRawToAnyTrkPt (LocalFormatID in_format, LocalFormatID out_format,
00105 GarminObject * from, TrkPts * to) UTIL_SECTION;
00106 extern void CustomTrkHdrToD310 (Object * trkhdr, D310_Trk_Hdr_Type * d310) UTIL_SECTION;
00107 extern Symbol_Type smblToSymbolType (byte smbl) UTIL_SECTION;
00108 extern byte SymbolTypeTosmbl (Symbol_Type smbl) UTIL_SECTION;
00109 extern UInt16 symb_gid2lid (Symbol_Type gid) UTIL_SECTION;
00110 extern Symbol_Type symb_lid2gid (UInt16 lid) UTIL_SECTION;
00111
00112
00113
00114
00115 extern void *GetObjPtr (UInt16 objindex) UTIL_SECTION;
00116 extern void HideObject (UInt16 objID) UTIL_SECTION;
00117 extern void ShowObject (UInt16 objID) UTIL_SECTION;
00118 extern Int16 RecIdToPosition (DmOpenRef DB, UInt16 category, UInt32 recid, UInt16 * indexp) UTIL_SECTION;
00119 extern UInt32 GetRecordID (DmOpenRef DB, UInt16 index) UTIL_SECTION;
00120 extern char *DegreToDM (double coord, Boolean longitude, Boolean nmea) UTIL_SECTION;
00121 extern char *DegreToDMS (double coord, Boolean longitude) UTIL_SECTION;
00122 extern char *DegreToD (double coord, Boolean longitude) UTIL_SECTION;
00123 extern char *DegreToChars (double coord, Boolean longitude, DisplayFormat DispMode) UTIL_SECTION;
00124 extern double ReadCoord (char *string, Boolean * longitude) UTIL_SECTION;
00125 extern void SemiToDegre (Semicircle_Type * p, double *latitude, double *longitude) UTIL_SECTION;
00126 extern void DegreToSemi (double latitude, double longitude, Semicircle_Type * p) UTIL_SECTION;
00127 extern void DistBearToSemi (double dist, UInt16 bearing, Semicircle_Type * p) UTIL_SECTION;
00128 extern char *StrNCopySafe (char *dstp, char *srcp, UInt16 dstsize) UTIL_SECTION;
00129 extern void StrNCatSafe (char *dstp, char *srcp, UInt16 dstsize, UInt16 srcsize) UTIL_SECTION;
00130 extern double StrToD (char *p, char **endp) UTIL_SECTION;
00131 extern void StrNToField (char *str, UInt16 length, UInt16 fieldid) UTIL_SECTION;
00132 extern void Canonicalize (char *p, UInt16 l) UTIL_SECTION;
00133 extern double Distance (long lat1, long lon1, long lat2, long lon2, DistanceUnit unit) UTIL_SECTION;
00134 extern double PDistance (long lat1, long lon1, long lat2, long lon2) UTIL_SECTION;
00135 extern UInt16 Bearing (long slat1, long slon1, long slat2, long slon2) UTIL_SECTION;
00136 extern char *DToA (double x, UInt16 digits, UInt16 precision) UTIL_SECTION;
00137 extern void DrawCharsInWidth (char *string, Int16 x, Int16 y, UInt16 w, Boolean RightAligned) UTIL_SECTION;
00138
00139 extern Int16 DistComp (long lat1, long lon1, long lat2, long lon2, long reflat, long reflon) UTIL_SECTION;
00140 extern void SetMathLibRef (UInt16 ref) UTIL_SECTION;
00141 extern void GpsutilSetDebugLevel (UInt16 debuglevel, LogProcPtr logprocp) UTIL_SECTION;
00142 extern Boolean WptHit (Custom_Wpt_Type * wptp, Semicircle_Type * position) UTIL_SECTION;
00143 extern void SetControlValue (UInt16 objID, short value) UTIL_SECTION;
00144 extern short GetControlValue (UInt16 objID) UTIL_SECTION;
00145 extern void GetObjectBounds (UInt16 objID, RectanglePtr rp) UTIL_SECTION;