chazzie Posted February 24, 2004 Report Posted February 24, 2004 Well, the topic says it all :) I want to take the units provided by FS and convert them into decimal Latitude and Longitude. I'm working in VB6, so if anyone has an idea, please share. Patrik
rickalty Posted February 24, 2004 Report Posted February 24, 2004 This stuff's all in the SDK Patrik. If you look there first you'll save yourself the time of aiting for a reply. Latitude of aircraft in FS units.To convert to Degrees: If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0). Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one double floating point value (say dHi). To do, copy the high part (the 32-bit int at 0564) to one double and the low part (the 32-bit unsigned int at 0560) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn’t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 90.0/10001750.0 to get degrees. Either way, a negative result is South, positive North. Richard
chazzie Posted February 24, 2004 Author Report Posted February 24, 2004 I saw that, however I was uncertain wether it would provide me with decimal values or not. Regards, Patrik
Indagroove Posted February 25, 2004 Report Posted February 25, 2004 This is what I use.... If FSUIPC_Read(&H560, 8, VarPtr(Fake64Bit), dwResult) Then If FSUIPC_Process(dwResult) Then StartLat = Fake64Bit * 10000# StartLat = StartLat * 90# / (10001750# * 65536# * 65536#) modVars.StartLatitude = StartLat End If End If It does return a decimal like -122.23456 or something. Fake64Bit is a Currency Declaration. It fakes VB out to grab floating 64 bit info. If you dont force the doubles (#) you will constantly get overflow errors. Mike
chazzie Posted February 28, 2004 Author Report Posted February 28, 2004 I got the latitude to work, however, I can't seem to get a decent value for the Longitude... I get a value at 12345,000000 something instead of -124,4323 which is the correct one. I just modified the code from Lat... If FSUIPC_Read(&H568, 8, VarPtr(Fake64Bit), dwResult) Then If FSUIPC_Process(dwResult) Then CurLong = Fake64Bit * 10000# CurLong = CurLong * 90# / (10001750# * 65536# * 65536#) End If End If Any Ideas?
chazzie Posted February 28, 2004 Author Report Posted February 28, 2004 Forget it, I had a look in the SDK and saw that I was formatting the data erroneously, it should be 65536# * 65536# * 65536# * 65536# instead of 10001750# * 65536# * 65536#. Also, it should be divided by 360 and not 90. Regards and a lot of thanks for the help! Patrik
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