Jump to content
Sign in to follow this  
mgh

Adding/removing flightplan waypoints in C/C++

Recommended Posts

Guest bsi

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

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.


Ed Wilson

Mindstar Aviation
My Playland - I69

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.


Ed Wilson

Mindstar Aviation
My Playland - I69

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...