Jump to content
The simFlight Network Forums

Recommended Posts

Posted
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

Posted

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é

Please sign in to comment

You will be able to leave a comment after signing in



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.