Navigation Database Access


XPLMNavRef

typedef

XPLMNavRef is an iterator into the navigation database. The navigation database is essentially an array, but it is not necessarily densely populated. The only assumption you can safely make is that like-typed nav-aids are grouped together.

Use XPLMNavRef to refer to a nav-aid.

XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when the iterator must be invalid.

typedef int XPLMNavRef;

XPLMNavType

enum

These enumerations define the different types of navaids. They are each defined with a separate bit so that they may be bit-wise added together to form sets of nav-aid types.

NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the FMS. It will not exist in the database, and cannot be programmed into the FMS. Querying the FMS for navaids will return it. Use XPLMSetFMSEntryLatLon to set a lat/lon waypoint.

Name Value Description
xplm_Nav_Unknown 0
xplm_Nav_Airport 1
xplm_Nav_NDB 2
xplm_Nav_VOR 4
xplm_Nav_ILS 8
xplm_Nav_Localizer 16
xplm_Nav_GlideSlope 32
xplm_Nav_OuterMarker 64
xplm_Nav_MiddleMarker 128
xplm_Nav_InnerMarker 256
xplm_Nav_Fix 512
xplm_Nav_DME 1024
xplm_Nav_LatLon 2048
xplm_Nav_TACAN 4096

XPLM_NAV_NOT_FOUND

define

#define XPLM_NAV_NOT_FOUND -1


XPLMGetFirstNavAid

function

This returns the very first navaid in the database. Use this to traverse the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is empty.

XPLM_API XPLMNavRef XPLMGetFirstNavAid(void);

XPLMGetNextNavAid

function

Given a valid navaid ref, this routine returns the next navaid. It returns XPLM_NAV_NOT_FOUND if the navaid passed in was invalid or if the navaid passed in was the last one in the database. Use this routine to iterate across all like-typed navaids or the entire database.

XPLM_API XPLMNavRef XPLMGetNextNavAid(
                         XPLMNavRef           inNavAidRef
                    );

XPLMFindFirstNavAidOfType

function

This routine returns the ref of the first navaid of the given type in the database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the database. You must pass exactly one navaid type to this routine.

XPLM_API XPLMNavRef XPLMFindFirstNavAidOfType(
                         XPLMNavType          inType
                    );

XPLMFindLastNavAidOfType

function

This routine returns the ref of the last navaid of the given type in the database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the database. You must pass exactly one navaid type to this routine.

XPLM_API XPLMNavRef XPLMFindLastNavAidOfType(
                         XPLMNavType          inType
                    );

XPLMFindNavAid

function

This routine provides a number of searching capabilities for the nav database. XPLMFindNavAid will search through every navaid whose type is within inType (multiple types may be added together) and return any navaids found based on the following rules:

This routine provides a simple way to do a number of useful searches: * Find the nearest navaid on this frequency. * Find the nearest airport. * Find the VOR whose ID is "BOS". * Find the nearest airport whose name contains "Chicago".

XPLM_API XPLMNavRef XPLMFindNavAid(
                         const char *         inNameFragment,    /* Can be NULL */
                         const char *         inIDFragment,    /* Can be NULL */
                         float *              inLat,    /* Can be NULL */
                         float *              inLon,    /* Can be NULL */
                         int *                inFrequency,    /* Can be NULL */
                         XPLMNavType          inType
                    );

XPLMGetNavAidInfo

function

This routine returns information about a navaid. Any non-null field is filled out with information if it is available.

Frequencies are in the nav.dat convention as described in the X-Plane nav database FAQ: NDB frequencies are exact, all others are multiplied by 100.

The buffer for IDs should be at least 6 chars and the buffer for names should be at least 41 chars, but since these values are likely to go up, I recommend passing at least 32 chars for IDs and 256 chars for names when possible.

The outReg parameter tells if the navaid is within the local "region" of loaded DSFs. (This information may not be particularly useful to plugins.) The parameter is a single byte value 1 for true or 0 for false, not a C string.

XPLM_API void       XPLMGetNavAidInfo(
                         XPLMNavRef           inRef,
                         XPLMNavType *        outType,    /* Can be NULL */
                         float *              outLatitude,    /* Can be NULL */
                         float *              outLongitude,    /* Can be NULL */
                         float *              outHeight,    /* Can be NULL */
                         int *                outFrequency,    /* Can be NULL */
                         float *              outHeading,    /* Can be NULL */
                         char *               outID,    /* Can be NULL */
                         char *               outName,    /* Can be NULL */
                         char *               outReg    /* Can be NULL */
                    );