Jump to content
The simFlight Network Forums

Longitude and Latitude Issue (Visual Basic)

Recommended Posts


As i am integrating the LON/LAT Feature, I have it so its returning in the correct format, But the actual numbers are off a bit.

Here is the code;

Dim latitude As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560)

Dim longitude As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568)

Dim Long1 As Double

Long1 = longitude.Value * 360 / (65536D * 65536D * 65536D * 65536D)

Me.Label28.Text = Long1.ToString("#,##0.000000")

Dim Lat1 As Double

Lat1 = latitude.Value * 90 / (10001750D * 65536D * 65536D)

Me.Label29.Text = Lat1.ToString("#,##0.000000")

Please let me know if I am doing anything wrong.

Link to comment
Share on other sites


Here is the code;

... snip ...

Please let me know if I am doing anything wrong.

Your code is correct.

But the actual numbers are off a bit.

Can you give an example? i.e. What are you expecting for the Lon and Lat? What are you getting from FSUIPC?


Link to comment
Share on other sites

Heres my code which seems to always be spot on....

Dim dwResult As Long
Dim latitude As Double
Dim longtitude As Double
Dim FakeLat As Currency
Dim FakeLon As Currency

Call FSUIPC_Read(&H560, 8, VarPtr(FakeLat), dwResult)
Call FSUIPC_Read(&H568, 8, VarPtr(FakeLon), dwResult)

Call FSUIPC_Process(dwResult)

latitude = FakeLat * 10000#
latitude = latitude * 90# / (10001750# * 65536# * 65536#)
longtitude = FakeLon * 10000#
longtitude = longtitude * 360# / (65536# * 65536# * 65536# * 65536#)

Lati.Caption = latitude
Longt.Caption = longtitude

Link to comment
Share on other sites

Those are a preview of what i get with that exact code.

The data you're getting from FSUIPC is 100% correct.

The two values represent the same lon/latitude, they are just in a different format.

The data from FSUIPC is decimal degrees, the display in FS is in Degrees and Minutes. Just as 1 hour and 15 minutes isn't 1.15 hours - it's 1.25 (1 and a quarter hours), so 47 degrees and 25.89 minutes isn't 47.2589 - it's 47.431507.

To convert your decimal degrees into the degrees and minutes you need to take the decimal portion (in the case of your latitude 0.431507) and multiply by 60. (60 minutes in a degree).

If you do that you'll get 25.89 which is what FS is showing.


Link to comment
Share on other sites

  • 6 months later...

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.