- 1 Navigation Databases
- 1.1 About the Navigation Functions
- 1.2 About the Navigation Database
- 1.3 NavAid References
- 1.4 NavAid Information
- 1.5 NavAid Database Organization
- 1.6 About the Flight Management Computer
- 1.7 Using the Navigation Database
- 1.8 Searching the Navigation Database
The navigation database functions give access to X-Plane's built in navigation database as well as X-Plane's flight management computer (FMC). We must use the navigation database to access the data that is used to program the FMC.%%%
X-Plane comes with an extensive navigation database. The navigation database is managed by Robin Peel and packaged with X-Plane as a series of text files. The navigation database features detailed information about radio beacons, navigation equipment, fixes, and airports. The internal database that X-Plane maintains is almost identical to the database as published by Robin; see the FAQs that come with X-Plane's navigation database (in the Resources/earth nav data/ folder) for more information. X-Plane's navigation database is stored in RAM while X-Plane executes. Here are a few good reasons to take advantage of it:
- Access to the FMC. The FMC must be programmed using X-Plane's navigation database.
- Consistency with the sim. Plugins using their own nav databases might produce odd results due to discrepancies in navaid information. All of X-Plane's instruments are based on its internal database.
- Resource conservation. Since X-Plane's database is already loaded into RAM it makes more sense to use this data than to load in the own copies of it.
- Ease of use. The database is provided with every copy of X-Plane and an API to it is provided for plugins.
For our purposes, the term navaid will refer to airports, fixes, and radio beacons interchangeably.
We access the navigation database via a _navaid reference_ . A navaid reference is an opaque value that serves as a key to one navaid in the database. Navaids include fixes, airports and radio beacons of various kinds. We receive a navaid reference from the database query functions and then use the reference to obtain information about the navaid or program the FMC. Navaids have types; each navaid is of only one type. The types are defined as distinct bits, so we can add the types together to form sets of types for searching purposes. There are three primary ways we receive a navaid reference:
- We can iterate through the entire database, receiving a reference to each navaid in turn.
- We can search the database for specific navaids (for example, the closest airport to a given lat/lon).
- We can access the navaid reference for various stages in the FMC.
Navaid references are not persistent between flight sim runs. If we want to save a navaid, save the ICAO code or some other persistent aspect of the navaid (its type and ID are a good unique combination) and then use that information to find the navaid again in the next run.
We can request various kinds of information about a navaid from the database given a navaid reference. One routine gives we access to as many or as few fields as we wish to access. If information is not present for a given type of navaid (for example, there is no frequency associated with a fix) then no information is returned.
The database is organized into continuous runs of the same kind of navaid. We can get a reference to the first and last navaid of a given type and then iterate among all navaids of this type. Within a type section there is no gauranteed order of navaids.
About the Flight Management Computer
X-Plane's Flight Management Computer (FMC) is an in-cockpit instrument that can fly the plane (via the autopilot) on complex routes. The FMC is not present in all planes but the data inside it is present even in planes that do not feature an FMC. (This data is not useful in these planes since the user has no way to activate the FMC, etc.) The FMC features a flight plan made of a series of segments. Each segment consists of some kind of location specification (an airport, VOR, NDB, fix, or latitude/longitude point) as well as an altitude to fly when approaching that segment. The flight plan is currently limited to one hundred segments. The FMC has a current segment, which specifies the navaid it is flying to, and the shown segment, which is the segment presented to the user in the cockpit. The FMC will automatically advance to the next current segment when it reaches the destination of the current segment. If the shown segment is the current segment, then when the next destination is reached the currently shown segment advances too. We can program the FMC's route, set which segment is current, and change the shown segment. When we program the FMC, we specify the destination of a segment either as a lat/lon coordinate pair or as a navaid reference.
This section explains how to search the navigation database.
Use the XPLMFindNavAid function to locate a specific navaid easily. This example locates the nearest airport to the plane's location.
< Example: finding the nearest airport. >
Searching the Whole Database
We can search the entire navigation database by iterating through it. This example searches the whole database and dumps each navaid to a file.
< Example: dumping the nav database. >
We can also search just a section of the navigation database. This example searches through only the VORs.
< Example: dumping the VORs to a file. >
Use the XPLMGetNavAidInfo function to get information about a navaid. This routine prints detailed information about the nearest VOR.
< Example : dumping a lot of info about the nearest VOR. >
Programming the Flight Management Computer
Reading the flight plan
We can read the flight plan and receive a series of nav aids in response.
< Example code: reading and printing the flight plan. >
Programming a FlightPlan
To clear the flight plan, clear every entry.
< Example code: clearing the flight plan. >
Then find the navaids we need from the database and program each one in.
< example code: programing the FMC. >
Controlling the FMC Display
We can also change the actual display or which entry the FMC is going to.
< Example code: Fly to the second navaid, show it too. >
For more info, see the XPLMNavigation reference.