Archived

This topic is now archived and is closed to further replies.

mgh

Adding/removing flightplan waypoints in C/C++

Recommended Posts

Hi!I'm trying to create a simple gauge that can modify (add/remove) flightplan. I started to test the SDK.FlightMap.c provided by FS2004 Panels SDK, but the implemented method (which one uses the GPS_INFO structure described in gsp_info.h) works only partially. It adds a new WP to the flightplan, but cannot fill in the WP's name regardless it's given or not. Also if I try to add/remove a WP with this method, it will clear the szName field (WP name) in all WPs.Could anyone help me what I do wrong?Here is the corresponding code section (the full source code can be found in FS2004 Panes SDK: SDK.FlightMap.c)UINT32 i = gpsrequest->lWpCounts++;gpsrequest->pWpData.dwSize = sizeof (GPS_WP_INFO);{ FLOAT64 fX = lX / SCALE_MAP_FACTOR; FLOAT64 fY = lY / SCALE_MAP_FACTOR; FLOAT64 fSin = sin (gpsinfo->dGroundHeading); FLOAT64 fCos = cos (gpsinfo->dGroundHeading); FLOAT64 fLOMeters = fX * fCos + fY * fSin; FLOAT64 fLAMeters = fX * fSin - fY * fCos; FLOAT64 fLatRad = LAT_METERS48_TO_RADIANS (gpsinfo->vPosition.lat); FLOAT64 fDeltaLonDeg = METERS_TO_LON_DEG_AT_LAT_RAD (fLOMeters, fLatRad ); ANGL48 anglDiff = DEGREES_TO_ANGL48 (fDeltaLonDeg); LATLONALT v; v.lon = ADD_ANGL48_ANGL48 (gpsinfo->vPosition.lon, anglDiff); v.lat = ADD_SIF48_SIF48 (gpsinfo->vPosition.lat, FLOAT64_TO_SIF48 (fLAMeters)); v.alt = FLOAT64_TO_SIF48 (gpsrequest->pWpData[i-1].dAltitude); gpsrequest->pWpData.vPosition = v;}gpsrequest->pWpData.dHeading = gpsrequest->pWpData[i-1].dHeading;gpsrequest->pWpData.dSpeed = gpsrequest->pWpData[i-1].dSpeed;gpsrequest->pWpData.dAltitude = gpsrequest->pWpData[i-1].dAltitude;strcpy (gpsrequest->pWpData.szName, "???");Thanks in advance,BSi

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I'm not an expert on this particular point, but typically shouldn't your line gpsrequest->pWpData.dHeading = gpsrequest->pWpData.dHeading;be something like:gpsrequest->pWpData.dHeading = gpsrequest->pWpData[i-1].dHeading;As in the SDK, or has the use of square brackets () changed it?EDIT: Yes it has!

Share this post


Link to post
Share on other sites

Has anybody ever found a solution to the "blank waypoint" issue described above? I'm running into exactly the same issue.

Share this post


Link to post
Share on other sites

I jump on this old topic to know if anyone found a solution to this problem of GPS flight plan edition.I made some tests and I discovered that the line:

gpsrequest->pWpData[i].dwSize = sizeof (GPS_WP_INFO);

is uselss. Changing this value to 0 had no impact on my tests.On the other hand, this line is important:

gpsrequest->dwSize = sizeof (GPS_INFO);

It seems that it indicates the amount of data that needs to be updated. With this line, the flight plan is correctly updated but the waypoint names are blanked.For testing, I tried this:

gpsrequest->dwSize = sizeof (GPS_INFO) - sizeof(char*);

to ignore the last part of the GPS_INFO structure, which is:

GPS_WP_INFO* pWpData;

It works... In this case, the names are not blanked, but the flight plan is not modified :( Does any of you know how to keep the waypoint names?If someone is good enough to disassemble the gps_export.dll, it may help. Sorry but I don't have the necessary knowledge to do this...Or maybe we should come to the conclusion that it definitely does not work this way and forget the code sample provided in the SDK...Thanks for any help !!Eric

Share this post


Link to post
Share on other sites

No, it doesn't work. It has never worked, ever since it was first introduced.You can not make any changes to the export DLL to make it work as it's actually a flaw elsewhere in FS.

Share this post


Link to post
Share on other sites

Unfortunately, I believe you're right.I really don't understand how the ACES could release a code that never worked...Eric

Share this post


Link to post
Share on other sites

You're also limited to 32 waypoints via that interface, despite the fact FS no longer has that limitation. It's code from FS2002 I believe.

Share this post


Link to post
Share on other sites

I wrote my own flightplan builder/parser/modifier for an INS system. Although the INS system doesn't contain waypoint names (only lat/lon co-ords), the flightplan worked perfectly when the aircraft was switched to 'Nav1 drives GPS'. Given that, you should be able to do the same but also be able to add in the bits I didn't need (waypoint names, waypoint types etc). -Dai

Share this post


Link to post
Share on other sites