{*************************************************************** * Project : GPS Analog Meter and Time Routines * App Name : 517_animation7.TXT, 491_analogmeter.TXT, #locs=149 * Purpose : Demonstrates bitblock component2 * Date : #sign>Administrator: PC08: 24/10/2014 06:36:29 PM * History : convert analogmeter to maXbox Aug 2014 * : add time routines and tickcount to LED : animates a sprite, if XP then ProcessMessagesOFF; ****************************************************************} //TODO: transfer the FmtStrArray to : //E:\maxbox3\mXGit39988\maxbox3\source\REST\GPS.pas UNIT NavUtils; INTERFACE type TPos = (tLat, tLon); TShowFmt = (sfNautical, sfStatute, sfMetric); const OneEighty = 180*3600; // Sec of arc ThreeSixty = 360*3600; // function CoordinateStr2(Idx: Integer; PosInSec: Double; PosLn: TPos): string; function UserUnits(Val: Double; sUnit: Char; ShowFmt: TShowFmt): string; function MagCourse(TC, MV: Double): Double; IMPLEMENTATION //uses //SysUtils; {Formats Position in sec into lat or lon string per Idx selection} //const // FmtStrArray: array[tLat..tLon, 0..3] of string = type Tint = array[0..3] of byte; var FmtStrArray : array[0..1] of Tint; //TODO: transfer the FmtStrArray to : //todo //array[tLat..tLon, 0..3] of string = (*{ Lat } (('%s %d %.2d %.2d', '%s %d %.2d.%4:.2d', '%s %5:.4f', // D M S D M.m D.d '%1:.2d%2:.2d.%4:.2d,%0:s'), // Waypoint per NMEA { Lon } ('%s %d %.2d %.2d', '%s %d %.2d.%4:.2d', '%s %5:.4f', '%1:.3d%2:.2d.%4:.2d,%0:s'));*) function CoordinateStr2(Idx: Integer; PosInSec: Double; PosLn: TPos): string; var Pos, Deg, Min, Sec, Dec: Integer; Dd: Double; C: Char; begin if (PosInSec > OneEighty) then PosInSec := PosInSec - ThreeSixty; case PosLn of tLat: if (PosInSec <= 0) then C := 'S' else C := 'N'; tLon: if (PosInSec <= 0) then C := 'W' else C := 'E'; end; {case} PosInSec := Abs(PosInSec); Dd := PosInSec/3600; // DDD.ddd.. Pos := Round(PosInSec); Deg := (Pos div 3600); // DDD Min := (Pos mod 3600) div 60; // MM Sec := (Pos mod 60) mod 60; // SS Dec := Round(1.667*Sec); // mm //Result := Format(FmtStrArray[ord(PosLN)][Idx], [C, Deg, Min, Sec, Dec, Dd]); end; {Magnetic course fom true course TC and magnetic variation MV} function MagCourse(TC, MV: Double): Double; begin Result := TC-MV; if (Result >= 360) then Result := Result-360; if (Result < 0) then Result := Result+360; end; function UserUnits(Val: Double; sUnit: Char; ShowFmt: TShowFmt): string; begin try if (UpperCase(sUnit) = 'M') then case ShowFmt of sfNautical: Result := Format('%.0f ft', [3.28*Val]); sfStatute : Result := Format('%.0f ft', [3.28*Val]); sfMetric : Result := Format('%.0f M', [Val]); end; if (UpperCase(sUnit) = 'K') then case ShowFmt of sfNautical: Result := Format('%.1f', [Val]); sfStatute : Result := Format('%.1f', [1.150779*Val]); sfMetric : Result := Format('%.1f', [1.852000*Val]); end; except Result := '--'; end; end; begin // function CoordinateStr2(Idx: Integer; PosInSec: Double; PosLn: TPos): string; writeln(CoordinateStr(2, 50.34, tlat)); //getgeocode {with TComSelectForm.create(self) do begin //parent:= aFrm; Show; //Coordinatestr end;} maxform1.GPSSatview1click(self); with TGPS.create(self) do begin ShowSetupDialog; if connected then open; writeln('GPS connected: '+botostr(connected)) //SetBounds(0,0,200,200) end; writeln('Coord is: '+GetGeoCode('xml',ExePath+'map2cologne.xml','cathedral cologne',true)); end. // NavUtils (*ref: TCustomGPS = class (TComponent) private // COM Port components FCOMPort: TComPort; FCOMDataPacket: TComDataPacket; // State of the TGPS component FConnected: Boolean; // COM Port parameters FPort: TPort; FBaudRate: TBaudRate; FDataBits: TDataBits; FStopBits: TStopBits; FParity: TComParity; FFlowControl: TComFlowControl; // GPS informations FSatellites: TSatellites; FGPSDatas: TGPSDatas; // Componants links FLinks: TList; FHasLink: Boolean; // Notifications FOnSatellitesChange: TGPSSatEvent; FOnGPSDatasChange: TGPSDatasEvent; FOnAfterOpen: TNotifyEvent; FOnAfterClose: TNotifyEvent; procedure CallOnSatellitesChange(); procedure CallOnGPSDatasChange(); procedure SetConnected(const Value: Boolean); procedure SetPort(const Value: TPort); procedure SetBaudRate(const Value: TBaudRate); procedure SetDataBits(const Value: TDataBits); procedure SetStopBits(const Value: TStopBits); procedure SetParity(const Value: TComParity); procedure SetFlowControl(const Value: TComFlowControl); // Packets interpreting procedure PacketRecv(Sender: TObject; const Str: String); // COM Port connection procedure COMPortAfterConnect(Sender: TObject); procedure COMPortAfterDisconnect(Sender: TObject); // Componants links function HasLink(): Boolean; protected procedure DoOnSatellitesChange(NbSat, NbSatUse: Shortint; Sats: TSatellites); dynamic; procedure DoOnGPSDatasChange(GPSDatas: TGPSDatas); dynamic; procedure DoAfterClose(); dynamic; procedure DoAfterOpen(); dynamic; public constructor Create(AOwner: TComponent); override; destructor Destroy(); override; procedure Open(); procedure Close(); procedure ShowSetupDialog(); // Componants links procedure RegisterLink(AGPSLink: TGPSLink); procedure UnRegisterLink(AGPSLink: TGPSLink); // GPS informations property Satellites: TSatellites read FSatellites; property GPSDatas: TGPSDatas read FGPSDatas; published // State of the TGPS component property Connected: Boolean read FConnected write SetConnected default False; // COM Port parameters property Port: TPort read FPort write SetPort; property BaudRate: TBaudRate read FBaudRate write SetBaudRate; property DataBits: TDataBits read FDataBits write SetDataBits; property StopBits: TStopBits read FStopBits write SetStopBits; property Parity: TComParity read FParity write SetParity; property FlowControl: TComFlowControl read FFlowControl write SetFlowControl; // Notifications property OnSatellitesChange: TGPSSatEvent read FOnSatellitesChange write FOnSatellitesChange; property OnGPSDatasChange: TGPSDatasEvent read FOnGPSDatasChange write FOnGPSDatasChange; property OnAfterOpen: TNotifyEvent read FOnAfterOpen write FOnAfterOpen; property OnAfterClose: TNotifyEvent read FOnAfterClose write FOnAfterClose; end; http://useruploadedfiles.programmersheaven.com/48584/NMEA.pas Program SpammersAreParasites; var l1,l2: Srting; begin l1:='70'; l2:='0'; Bxo:=l1 + l2; Bxo:=(Bxo) (* l1:=97; l2:=9 Bxo:=(l1 + l2); *) end. ? Value of Bxo: *) doc: cathedral cologne result Coord is: latitude: '50.94133705' longitude: '6.95812076100766' >>> 50°56'28.8"N 6°57'29.2"E http://maps.google.com/maps?q=+50.94133705,+6.95812076100766 >>> https://www.google.com/maps/place/50%C2%B056%2728.8%22N+6%C2%B057%2729.2%22E/@50.9413371,6.9581208,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0 church cologne: result Coord is: latitude: '50.9636172' longitude: '7.0031056'