N402KC Posted March 7, 2010 Report Posted March 7, 2010 Hi, 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.
Paul Henty Posted March 7, 2010 Report Posted March 7, 2010 Hi, 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? Paul
superdudes Posted March 8, 2010 Report Posted March 8, 2010 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
N402KC Posted March 8, 2010 Author Report Posted March 8, 2010 http://i48.tinypic.com/j8yvfc.png Those are a preview of what i get with that exact code.
Paul Henty Posted March 8, 2010 Report Posted March 8, 2010 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. Paul
N402KC Posted March 9, 2010 Author Report Posted March 9, 2010 Thanks A Ton. I just noticed the Decimal Format. Now once i submit the info to google maps, it points right on target. BOOYAH, Thanks!
Rickkap Posted September 14, 2010 Report Posted September 14, 2010 Paul Please could you show me an example of how to convert to decimal in VB. I am just starting out and still very new to the language but willing to learn Rgds Rick
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now