Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GPS variable

Featured Replies

  • Commercial Member

Happy New Year everyone.I'm having a "problem".When trying to develop some gauges for a panel, I went to use the variables GPS_POSITION_LAT and GPS_POSITION_LON.The latitude works fine... however the longitude doesn't. So I created a couple of strings to display the values FS9 returns forPLANE_LONGITUDE -4653815.5GPS_POSITION_LON -847201280.0As you can see, they are not the same.Can anyone tell me:1) Why2) How do I get the correct longitude with GPS_POSITION_LON?Thank you.Ed Wilson

Ed Wilson

Mindstar Aviation
My Playland - I69

Ed,I just tinkered with this a little, and...Plane_Longitude -4653815.5 * 11930464.71111 * 360 / (65536 * 65536 * 65536) = -71.01158905GPS_Position_Lon -847201280.0 * 360 / (65536 * 65536) = -71.01159096EasyGauge messes with the Plane Longitude by dividing it by 11930464.71111 I have the programmers edition; here is the code:FLOAT64 FSAPI callback3( PELEMENT_STRING pelement){float rwert=pelement->source_var[0].var_value.n;rwert=rwert / 11930464.71111;sprintf(pelement->string,"%014.0f PL",rwert);return 0;}Best regards,Doug Dawson

  • 2 months later...
  • Moderator

>EasyGauge messes with the Plane Longitude by dividing it by>11930464.71111 I have the programmers edition; here is the>code:>>FLOAT64 FSAPI callback3( PELEMENT_STRING pelement)>{float rwert=pelement->source_var[0].var_value.n;>rwert=rwert / 11930464.71111;>sprintf(pelement->string,"%014.0f PL",rwert);>return 0;}Now that's just plain bizzare! Why the heck does EG do such a silly thing? I've wasted hours on this problem. Thank God for the "Search" function here at AVSIM.COM! :)BTW, it's far easier to use the macro's in the gaugesFS2002.h file to 'translate' lat and lon into degrees:FS_LATITUDE_DEG ( PLANE_LATITUDEvar.var_value.n ) FS_LONGITUDE_DEG( PLANE_LONGITUDEvar.var_value.n ) ;

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Moderator

BTW, "fixing" the PLANE_LONGITUDE variable in EG is as simple as editing the tokensFS2002.est file.Edit Record 101 to "Special=" and remove the silly "multiplier" they put in there! :)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

That's why I put them in. If you use the new fs9 gaugs.h make sure to copy those macros. I'm not sure, but there might be different factors for PLANE_.. and GPS_... .Arne Bartels

  • Moderator

>That's why I put them in. If you use the new fs9 gaugs.h make>sure to copy those macros. I'm not sure, but there might be>different factors for PLANE_.. and GPS_... .Hi Arne!Actually, Doug was referring to the code generated by EasyGauge. For some reason, "they" put some silly value into the tokenFS2002.est file (which is where they define FS token variables and their parameters that're used when the program "exports" the various .c, .h, .rc and G.c files for the compiler to use.They take the FS variable PLANE_LONGITUDE and divide it by 1930464.71111... :( Why they did that is anyone's guess, but it's dead wrong...I was simply telling Doug to edit the tokenFS2002.est file to remove the wrong value, and also to use the macros so thoughtfully provided... :)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Hey Bill,It is not as silly as it looks. If you look at gps_info.h, which was already included in the 2002 SDK, you will find a function by the name of ANGL48_TO_DEGREES. This function takes a value in the ANGL48 format, multiplies it by 360, and divides it by 65536^2. If you invert 360/65536^2, you get 11930464.7111111.Since EG divides by 11930464.7111111, it is the same as multiplying by 360/65536^2, which is what ANGL48_TO_DEGREES does, so we are back full circle.So EG uses what MS uses also, just written in a float format. MS uses it in integer format since ints are much faster to do mathematical operations with. Floats are processed by the FPU (the math processor), which takes much longer than integers.P.S. Thanks to Oleksiy Frolov for the info on the floating point calculations

  • Moderator

Thanks Fabio, I figured that part out late last night. Unfortunately, it still will provide inconsistent and inaccurate values in many circumstances, especially when one wants to produce the final result as follows:Lat: N38

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • 11 months later...

It seems I working on a related project.In this tread there is a good discussion on the math to convert the Longitude but what about the Latitude?I've tried to rearranging the the functions in the SDK but I can't get the conversion factor worked out. Any help?

  • Moderator

latitude in degrees = PLANE_LATITUDE / 111130.555557Or even easier if you are working in C:lat_deg = FS_LATITUDE_DEG ( PLANE_LATITUDE ) ;To convert the lat_deg variable to dd:mm:ss format, simply keep dividing the fractional remainder by 60, as in the example below:51.42857143 --> 51 deg and 0.42857143*60 min --> 51 deg 25.7142858 min --> 51 deg 25 min and 0.7142858*60 sec --> 51 deg 25 min 42.857148 sec --> 51 deg 25 min 43 sec

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.