Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello,

Things are going wonderful now. I just have a question for a delphi programmer that has successfully got the latitude and longitude to display correctly. The offset table guide to this section is just a little hard to understand. Your help is appreciated.

Thankyou,

Michael.

Posted

Mick,

some excerpts from my code (free to use but no guarantee):

var
Lat_FS, Long_FS: Comp;     // $0560, 8 / $0568, 8 (in FS format)
Latitude, Longitude : Double;

FSUIPC_Read($0560, 8, @Lat_FS, dwResult);                 // Latitude of A/C
FSUIPC_Read($0568, 8, @Long_FS, dwResult);                // Longitude of A/C

function Decode_FS_Latitude_to_Decimal(lat : comp) : Double;
begin
  Result := lat * 90 / (10001750.0 * 65536.0 * 65536.0);
end;

function Decode_FS_Longitude_to_Decimal(lon : comp) : Double;
begin
  Result := lon * 360 / (65536.0 * 65536.0 * 65536.0 * 65536.0);
end;

  // Extract and display current position of aircraft
  Latitude  := Decode_FS_Latitude_to_Decimal(Lat_FS);
  Longitude := Decode_FS_Longitude_to_Decimal(Long_FS);

  if Latitude >= 0 then begin
    Label_Lat.Caption := 'N ' + FormatFloat('0.00', Latitude) + '°';
  end else begin
    Label_Lat.Caption := 'S ' + FormatFloat('0.00', Latitude) + '°';
  end;

  if Longitude >= 0 then begin
    Label_Lon.Caption := 'E ' + FormatFloat('0.00', Longitude) + '°';
  end else begin
    Label_Lon.Caption := 'W ' + FormatFloat('0.00', Longitude) + '°';
  end;

This should get you up and running...

Bye,

CATIII

Edit: 'greater than' changed to 'greater than or equal to'.

Posted

Thank you CATIII,

Exactly what I was looking for. Well Done =)

Regards,

Michael.

PS. I have all the stuff i need now, but the only part that has me a little baffled is the heading equation.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.