Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello !

I know that it's written in the document "FSUIPC for Programmers", but I don't really understand...

How I can convert the values of the coordinates ??

For example...I have the following coordinates of the airport :

Longitude Low: 0 4 4 -10 (32-Bits)

Longitude High: 25 -104 125 -63 (32-Bits)

How I can convert to the value shown in the FS (in this case: W87 * 54.17) ?

Thanx a lot...Paschu

Posted

For example...I have the following coordinates of the airport :

Longitude Low: 0 4 4 -10 (32-Bits)

Longitude High: 25 -104 125 -63 (32-Bits)

To start with, why are you expressing largish 32-bit numbers as a series of 4 separate small numbers. They are not! That makes no sense at all!

Either read them into 32-bit integers then convert them using the formulae given, or, better, if your compiler supports 64-bit numbers (long long or int64 or _int64 or somesuch) then read the whole thing into one of those.

Either way you then need to convert it to floating point (a "double" in C/C++) before doing the multiplations and divisions.

The 64 bit integer for Latitude reppresents the number of metres from the equator. The value for longitude is simply degrees but scaled for maximum precision in 64 bits -- i.e. so that 360 degrees is one more than the 64-bit capacity.

Please use FSInterrogate to see what is happening.

Regards,

Pete

Posted

Thanx Pete,

I think, that will work....but are you sure that I can read out the hole 64-bit-integer-value from the FS2004 ?

I think at first I have to read out the stream (as char) and then to convert it anyway into integer (which is not so easy i think)

Please tell me if I'm right (or totally wrong) !!

Thanx...Paschu

Posted

I think, that will work....but are you sure that I can read out the hole 64-bit-integer-value from the FS2004 ?

Are you using C/C++ or something else? I can't advise on anything other than C.

In C/C++ you can read it directly into the appropriate type of variable -- a long long or _int64 in this case. I know the FSUIPC_Read call takes a Byte pointer, but you just cast that. The length is still 8 (bytes) the address will be given as "(BYTE *) &lat", but the result will be a long long.

I think at first I have to read out the stream (as char) and then to convert it anyway into integer (which is not so easy i think)

Please tell me if I'm right (or totally wrong) !!

Wrong in C/C++. I'd hope wrong in Delphi or VB. But if you are using one of the new-fangled managed languages, then I haven't a clue, but you may be right -- they seem to be very peculiar in this sort of way.

Regards,

Pete

Posted

Wrong in Delphi as well (as long as we are talking at least Delphi 7 with Update 1). Previous versions of Delphi had an Int64 variable however it didn't funktion in all cases (ClientDataSets couldn't handle Int64).

Paschu you can't simply look at each byte seperatly. Please state which development tool you are using as it will help describe the way to do it.

Posted

I'm using Delphi myself however the way to do the math is basically the same. As stated by Peter you should use a 8 byte integer (_In64) into which you simply read 8 byte from address 0x560 (for Latitude). According to the Description you must multiply this value with 90 then divide it by 100011750 (this result should be calculated using a 32 or 64 bit floating value - In Delphi I would use "Single" or "Double").

According to the dokumentation this value is Southern hemisphere if the value is negative or Northern hemisthere if its positive. This value is simply the degreees as a decimal value. If you instead want it as Degrees, Minutes, Seconds then you'll have to do something like (at least in Delphi):

Procedure DecodeLatitude(Latitude: Double; var Deg: SmallInt; var Min: Word; var Sec: Word; var MSec: Word); Overload;

begin

if (Latitude < -90.0) then Latitude := -90.0;

if (Latitude > 90.0) then Latitude := 90.0;

Deg := Trunc(Latitude);

Latitude := Frac(Latitude) * 60;

Min := Trunc(Latitude);

Latitude := Frac(Latitude) * 60;

Sec := Trunc(Latitude);

MSec := Trunc(Frac(Latitude) * 1000);

end;

Posted

Hey pellelil...thanks a lot !

It seems to working, but nevertheless I have another question (I hope it's the last one :lol: )

I read out the the value using _int64...no problem ! After this I calculate the decimal value like recommended by you...but the value I get by calculating seems to be a little bit high !!

It is something like 2.56008e+008 !! :shock:

So I calculated it like recommended in Peter Dowson's "FSUIPC for Programmers", i.e. 8-byte-integer-value*90/(10001750.0 * 65536.0 * 65536.0)...after doing this I got a really small Value like 5,343758 !!

So...I'm not sure which value is the right one and/or if I interpret something wrong !!

Maybe you can help me or givbe me a tip another time !?

Thanx...Paschu

Posted
I read out the the value using _int64...no problem ! After this I calculate the decimal value like recommended by you...but the value I get by calculating seems to be a little bit high !!

It is something like 2.56008e+008 !! :shock:

So I calculated it like recommended in Peter Dowson's "FSUIPC for Programmers", i.e. 8-byte-integer-value*90/(10001750.0 * 65536.0 * 65536.0)...after doing this I got a really small Value like 5,343758 !!

So...I'm not sure which value is the right one and/or if I interpret something wrong !!

Isn't it obvious which one is wrong :wink:

George

Posted

Yes I think so :wink: ....I've never heard about Latitude with dimesnions of e+008 !

But the other one seems a little bit small... :roll: ...but probably it's the right one !!

Posted

So I calculated it like recommended in Peter Dowson's "FSUIPC for Programmers", i.e. 8-byte-integer-value*90/(10001750.0 * 65536.0 * 65536.0)...after doing this I got a really small Value like 5,343758 !!

Is that "really small"? That would be 5.343758 degrees. Without knowing where your aircraft was at the time, who can tell?

So...I'm not sure which value is the right one and/or if I interpret something wrong !!

Why don't you simply compare it with what it is supposed to be? Please look inside the FSUIPC SDK and get FSInterrogate out. Use that to compare all your extracts from FS.

Regards,

Pete

Posted

Jippieehhh !!

Thanx to all who helped me with respect to this thread !!

Now it works and the values make sense !! The last fault i detected was a human one...I just typed in one number to much (100011750 instead of 10001750), that's why the value was a little bit small !!

But now it works and the values are right accordingly to the values in the FS2004 !!

Thanx a LOT !!

Paschu

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.