Incorrect LAT and LONG returns from simconnect

AlexAnt
Posts: 1
Joined: Mon Jan 01, 2018 9:35 am

Incorrect LAT and LONG returns from simconnect

Postby AlexAnt » Mon May 11, 2020 11:26 am

Good day, everyone.

I'm trying to get my aircraft coordinates using C#, but i receive incorrect data.
Did anyone faces this problem? I have no idea how to fix it.

Simulator: Prepar3d 4.5.14.34698
SimConnect version: 4.5.0.0.

Here is the code:

Code: Select all

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct AircrafCoordinatesStruct { public double latitude; public double longitude; public double altitude; }; enum DEFINITIONS { AircrafCoordinatesStruct }; enum DATA_REQUESTS { REQUEST_COORDS }; void requestCoordinates() { Prepar.AddToDataDefinition(DEFINITIONS.AircrafCoordinatesStruct, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); Prepar.AddToDataDefinition(DEFINITIONS.AircrafCoordinatesStruct, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); Prepar.AddToDataDefinition(DEFINITIONS.AircrafCoordinatesStruct, "Plane Altitude", "feets", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); Prepar.RegisterDataDefineStruct<AircrafCoordinatesStruct>(DEFINITIONS.AircrafCoordinatesStruct); Prepar.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_COORDS, DEFINITIONS.AircrafCoordinatesStruct, 0, SIMCONNECT_SIMOBJECT_TYPE.USER); } void simconnect_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data) { switch ((DATA_REQUESTS)data.dwRequestID) { case DATA_REQUESTS.REQUEST_COORDS: AircrafCoordinatesStruct cs = (AircrafCoordinatesStruct)data.dwData[0]; var lat = cs.latitude; var lon = cs.longitude; break; default: break; } }
So, placing my craft (PMDG737NGXu) on the stand at UUWV(Moscow-Vnukovo airport) and trying to get position.
SimConnect returns:
Aircraft position:
Lat: 55.60
Long: 37.28

When i call RequestFacilitiesList it returns nearest aisports, with correct corrdinates:
Icao: UUWV
Latitude: 54,2392
Longitude: 37,600
Altitude: 219,456

It's a significant difference between coords. But map in Prepar3d shows correct coordinates, like FMC in my 737.

Does anyone knows a solution?

Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 9 guests