Jump to content
The simFlight Network Forums
Sign in to follow this  
PhoenixRET

Lat and Long

Recommended Posts

What is the proper expression for converting the Lat and Long data after you extract it from FSUIPC ?

I explain it in words in the SDK programmers guide -- the recently elaborated explanation should surely be clear enough? I don't give expressions as how to do it would be different in each language.

Pete

Share this post


Link to post
Share on other sites

int lat;

float latitude,longitude;

int longi;

DWORD DwResult;

FSUIPC_Read(0x564, 4, &lat, &DwResult);

FSUIPC_Read(0x56c, 4, &longi, &DwResult);

FSUIPC_Process(&DwResult);

latitude=(float)((float)lat*90.0/10001750.0);

longitude=(float)((float)longi*(360.0/(65536.0*65536.0)));

if (longitude >180)

longitude=(float)(longitude-360.0);

float DegLat,FracDegLat,MinLat,SecLat;

FracDegLat=modff(fabs(latitude),&DegLat);

SecLat=modff(FracDegLat*60,&MinLat);

SecLat*=60;

SecLat=floorf (SecLat);

float DegLon,FracDegLon,MinLon,SecLon;

FracDegLon=modff(fabs(longitude),&DegLon);

SecLon=modff(FracDegLon*60,&MinLon);

SecLon*=60;

SecLon=floorf (SecLon);

char *message2,*message1;

WORD length;

message1=(char*)calloc (400,1);

message2=message1;

if (latitude>0&&longitude>0)

length=sprintf (message2, "AUTOPOS N%2.0fº %2.0f' %2.0f'' E%2.0fº

%2.0f' %2.0f'' \n", DegLat, MinLat,

SecLat,DegLon, MinLon, SecLon);

if (latitude<0&&longitude>0)

length=sprintf (message2, "AUTOPOS S%2.0fº %2.0f' %2.0f'' E%2.0fº

% 2.0f' %2.0f'' \n", DegLat, MinLat,

SecLat,DegLon, MinLon, SecLon);

if (latitude<0&&longitude<0)

length=sprintf (message2, "AUTOPOS S%2.0fº %2.0f' %2.0f'' W%2.0fº

%2.0f' %2.0f'' \n", DegLat, MinLat,

SecLat,DegLon, MinLon, SecLon);

if (latitude>0&&longitude<0)

length=sprintf (message2, "AUTOPOS N%2.0fº %2.0f' %2.0f'' W%2.0fº

%2.0f' %2.0f'' \n", DegLat, MinLat,

SecLat,DegLon, MinLon, SecLon);

José

Share this post


Link to post
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
Sign in to follow this  

×

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.