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.

LATLONALT conversions

Featured Replies

  • Commercial Member

I've never claimed to be good with the maths and I think I've proved it again <sigh>... I've been trying to use the __inline functions from the SDK.FlightMap.cpp to return my current lat, lon and alt. However, a print to string command returns just the 'f', showing that the data is incorrect.if (gpsinfo && gpsinfo->dwSize >= sizeof (GPS_INFO))wsprintf(pelement->string, "%10.0f", SIF48_TO_FLOAT64(gpsinfo->vPosition.lat));if (gpsinfo && gpsinfo->dwSize >= sizeof (GPS_INFO))wsprintf(pelement->string, "%10.0f", ANGL48_TO_FLOAT64(gpsinfo->vPosition.lon));Would someone please be kind enough to put me out of my misery and tell me what I should be doing?-Dai

  • Commercial Member

Aside from the fact it's not a typical lat/lon value... why are you trying to do this?The current lat/lon is already available in far greater accuracy from FS itself. The GPS data doesn't update as accurately nor quickly.

if (gpsinfo){  if (gpsinfo->dwSize==sizeof (GPS_INFO))  {	wsprintf(pelement->string, "%10.0f", SIF48_TO_FLOAT64(gpsinfo->vPosition.lat));  }}

Don't lump your logic checks into one line. Relying on a boolean 'short-circuit' to avoid any type of crashes is a really bad idea. The way you had it written... if gpsinfo was null, you could potentially get a access violation by testing the dwSize field of a null pointer. (experience talking here...)C/C++ lets you do a lot of things, code-wise... however, just because you can doesn't mean you should. :(Is pelement->string a widechar string? I don't think it is... which means you should be using the sprintf() function.

Ed Wilson

Mindstar Aviation
My Playland - I69

  • Author
  • Commercial Member

I only posted the line that was the source of the trouble; there is an 'else' trap following it in case the block size is NULL or the struct is not initialised but yes, I agree with your general comment on putting all your eggs in one basket.Whay am I trying to do this? I'm trying to build an early INS system and they weren't as accurate or as quick in updating the aircraft position as they could be. As it happens, the gps_info.h file contains (as a subset) all of the information that this particular INS system is able to use/display. I'll try sprintf and see if that makes a difference.-Dai

  • Commercial Member

The value in LATLONALT is already available from the GPS without the use of gps_info.h.I will caution you that use of the gps_info interface can cause problems. FS does not always return the pointer to it, under certain conditions. If the aircraft is reloaded... if you fly the aircraft, select "End Flight" and then create a new flight... it will return a NULL pointer.So... there is a strong risk with using that data.

Ed Wilson

Mindstar Aviation
My Playland - I69

  • Moderator

Dai,Why not simply fetch the current lat/lon from the GPS directly?execute_calculator_code("(A:GPS POSITION LAT, Radians)",&gps_lat,NULL,NULL);execute_calculator_code("(A:GPS POSITION LON, Radians)",&gps_lon,NULL,NULL);

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.