Jump to content
The simFlight Network Forums

Latitude and Longitude - Delphi

Recommended Posts


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.



Link to comment
Share on other sites


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

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;
  Result := lat * 90 / (10001750.0 * 65536.0 * 65536.0);

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

  // 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) + '°';

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

This should get you up and running...



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

Link to comment
Share on other sites

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.