Coherent.js and the EFB flight plan

I’m creating a fantasy plane for the 2024 sim and along with it, all the displays. Pertinent to this question being the navigation display and FMC. For those to be able to show and edit the flight route, I will need, as a bare minimum, the lat, long and altitude for each waypoint, along with any speed or altitude restrictions.

Now, after registering the apropriate listeners and event handlers, I can use the GET_EFB_ROUTE Coherent call which will return the current flightplan from the EFB (for example EFHK-EFIV in the FlightPlanRoute example.log, rename it to .json which it actually is).

The returned route will give me the departure and arrival airport ICAOs and runways and any SID or STAR to use, as well as enroute waypoints. But, neither the airports or enroute waypoints contain lat or long or altitude info and the SID or STAR waypoints are not listed at all, just the name of the procedure.

My questions are as follows:

Is there any easier way to get the waypoints of a SID or STAR other than making two LOAD_AIRPORT_FROM_STRUCT Coherent calls and supplying the route.departureAirport and route.destinationAirport as a parameter? It does get me information for a given facility (Facility example below for EFHK), for example the lat and long. But, even with the waypoint names for the SIDs and STARs, I’m not sure how to get the lat and long from them? There seem to be some polar coordinate stuff in there (theta and rho), but not sure I should use those?

For the enroute waypoints, there is the type and ident for each, but lat and long are 0 and altitude seems to be null. How can I query the latlongalt for these? Do I need to get them one call at a time or is there any way to query multiple at one time?

I plan to get the flight plan at the FMC startup which gives me either the plan from the EFB or an empty plan if there’s not one there yet. After that I was thinking I could modify the JS route object according to what the user does from the FMC and then finally when EFB asks to sync the route, just send the edited object back. Does this make sense or is this there an easier way?

FlightPlanRoute example.log (9.1 KB)

Facility example.log (315.6 KB)

How does the original flightplan get created? If you have any control over that then putting everything into User waypoints is a good way of preserving the contents.

At this time the flightplan will always come from the EFB. Like I said, even if there is no flightplan in the EFB, the GET_EFB_ROUTE will return a mostly empty JS object which can be used as the basis. Not sure what you mean by “User waypoints”?

that’s only really relevant if you’re generating flight plans outside the sim (e.g. as has been traditionally done with planners such as Little Navmap). The core data structure then is in the PLN file which contains the prepared flight plan, and that has departure/arrival airports and intermediate waypoints that may themselves be airports, navaids or simply ad hoc lat/long locations assigned a name to be passed on route. These things are stored/restored slightly differently in and out of the PLN file with the ad-hoc lat/long/name waypoints listed as a “User” type. As time has progressed only those “User”-tagged waypoints have much chance of the original lat/long/altitude/name surviving through the API’s hence for common VFR requirements (like the altitude included was important) that “User”-format waypoint can be useful, even for airports and navaids.

The returned route will give me the departure and arrival airport ICAOs and runways and any SID or STAR to use, as well as enroute waypoints. But, neither the airports or enroute waypoints contain lat or long or altitude info and the SID or STAR waypoints are not listed at all, just the name of the procedure.

That’s because SIDs/STARs/approaches don’t necessarily contain only geographical fixes, but often floating termination legs like altitude legs, holds, intercepts etc. which would are more complex to store than referring to facilities.

As for enroute waypoints, you are meant to load the facilities using the available JS APIs (I recommend you use the official TypeScript avionics framework, with documentation on how to load navdata here) and get their location that way.

Altitude is not something that makes sense in this kind of route object except for step climbs, because outside of performance predictions, the altitude at which a plane will be at a certain waypoint is not something that is defined in advance.

Is there any easier way to get the waypoints of a SID or STAR other than making two LOAD_AIRPORT_FROM_STRUCT Coherent calls and supplying the route.departureAirport and route.destinationAirport as a parameter?

No.

But, even with the waypoint names for the SIDs and STARs, I’m not sure how to get the lat and long from them? There seem to be some polar coordinate stuff in there (theta and rho), but not sure I should use those?

The theta and rho field you mention are representative of ARINC 424 procedure legs, and are specifically meant to encode data for the floating termination legs i mentioned earlier. To get the facility for a leg (if there is one - some legs have no fixed termination, which can be checked with ICAO.isValueEmpty(leg.fixIcaoStruct), you’d use the tutorial I mentioned before and use the fixIcaoStruct property of the leg to get the relevant facility.

For the enroute waypoints, there is the type and ident for each, but lat and long are 0 and altitude seems to be null. How can I query the latlongalt for these? Do I need to get them one call at a time or is there any way to query multiple at one time?

See above, but not that at the moment you will need to get them one at a time. That should not take too long however. Also, lat and lon in the EFB route enroute legs are meant for user-defined waypoints - they are only guaranteed to contain data if hasLatLon is also true, in whch case you use the lat and lon instead of querying a facility.

I plan to get the flight plan at the FMC startup which gives me either the plan from the EFB or an empty plan if there’s not one there yet. After that I was thinking I could modify the JS route object according to what the user does from the FMC and then finally when EFB asks to sync the route, just send the edited object back. Does this make sense or is this there an easier way?

Depending on how you want your FMS to work, that may be limiting.

To note: the avionics framework I mention has pre-built utilities for managing flight plans and creating, displaying and following flight paths generated from their data. This might be useful to you.

2 Likes

it is not recommended to do this as the EFB will then not be able to properly load the relevant facilities to display to the user, and will instead just show lat/lon waypoints.

Lol that’s only true if your use-case is one the EFB has been designed for. We make use of external planners and dedicated nav gauges and it’s very hard work persuading the EFB and other 2024 code not to mess with the data. Tricks including “User” waypoints reduce the likelihood of the sim mangling data before you can pick it up in js gauges or simconnect.

What issues you are having?

Issues with getting flightplans into the EFB are not really relevant to implementing an FMC and ND.

@RJiiFIN You can find a complete FMC and ND in the avionics framework source code: msfs-avionics-mirror/src/workingtitle-instruments-wt21 at main · microsoft/msfs-avionics-mirror · GitHub

Along with the documentation holland786 linked that will at least provide some ideas how to go about it, if not a starting point to adapt from if you are going to use the framework to build your FMC/ND.

@holland786 @tracernz Thank you for the links and replies. I didn’t even realise there are so many kinds of waypoints and whatnot. I think I’ll have to try and focus on getting the interop working for the simpler types (ident, latlon) first and maybe call it good enough at that point and hand wave the non-support as being due to the decade it was built.

I do remember checking out the Avionics framework at one time but it didn’t grow on me then. But I’ll recheck it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.