Skip to main content

Class: FacilityLoader

A class that handles loading facility data from the simulator.

Constructors

constructor

new FacilityLoader(facilityRepo, onInitialized?): FacilityLoader

Creates an instance of the FacilityLoader.

Parameters

NameTypeDescription
facilityRepoFacilityRepositoryA local facility repository.
onInitialized() => voidA callback to call when the facility loader has completed initialization.

Returns

FacilityLoader

Defined in

src/sdk/navigation/FacilityLoader.ts:214

Properties

onInitialized

Readonly onInitialized: () => void

A callback to call when the facility loader has completed initialization.

Type declaration

▸ (): void

A callback to call when the facility loader has completed initialization.

Returns

void

Defined in

src/sdk/navigation/FacilityLoader.ts:216

Methods

awaitInitialization

awaitInitialization(): Promise<void>

Waits until this facility loader is initialized.

Returns

Promise<void>

A Promise which is fulfilled when this facility loader is initialized.

Defined in

src/sdk/navigation/FacilityLoader.ts:250


findNearestFacilitiesByIdent

findNearestFacilitiesByIdent<T>(filter, ident, lat, lon, maxItems?): Promise<SearchTypeMap[T][]>

Searches for facilities matching a given ident, and returns the matching facilities, with nearest at the beginning of the array.

Type parameters

NameType
Textends FacilitySearchTypeLatLon

Parameters

NameTypeDefault valueDescription
filterTundefinedThe type of facility to filter by. Selecting ALL will search all facility type ICAOs, except for boundary facilities.
identstringundefinedThe exact ident to search for. (ex: DEN, KDEN, ITADO)
latnumberundefinedThe latitude to find facilities nearest to.
lonnumberundefinedThe longitude to find facilities nearest to.
maxItemsnumber40The maximum number of matches to return. Defaults to 40.

Returns

Promise<SearchTypeMap[T][]>

An array of matching facilities, sorted by distance to the given lat/lon, with nearest at the beginning of the array.

Defined in

src/sdk/navigation/FacilityLoader.ts:584


getAirway

getAirway(airwayName, airwayType, icao): Promise<AirwayObject>

Gets airway data from the sim.

Parameters

NameTypeDescription
airwayNamestringThe airway name.
airwayTypenumberThe airway type.
icaostringThe 12 character FS ICAO of at least one intersection in the airway.

Returns

Promise<AirwayObject>

The retrieved airway.

Throws

an error if no airway is returned

Defined in

src/sdk/navigation/FacilityLoader.ts:376


getFacility

getFacility<T>(type, icao): Promise<FacilityTypeMap[T]>

Retrieves a facility.

Type parameters

NameType
Textends FacilityType

Parameters

NameTypeDescription
typeTThe type of facility to retrieve.
icaostringThe ICAO of the facility to retrieve.

Returns

Promise<FacilityTypeMap[T]>

A Promise which will be fulfilled with the requested facility, or rejected if the facility could not be retrieved.

Defined in

src/sdk/navigation/FacilityLoader.ts:267


getMetar

getMetar(airport): Promise<undefined | Metar>

Gets a METAR for an airport.

Parameters

NameTypeDescription
airportAirportFacilityAn airport.

Returns

Promise<undefined | Metar>

The METAR for the airport, or undefined if none could be obtained.

Defined in

src/sdk/navigation/FacilityLoader.ts:484

getMetar(ident): Promise<undefined | Metar>

Gets a METAR for an airport.

Parameters

NameTypeDescription
identstringAn airport ident.

Returns

Promise<undefined | Metar>

The METAR for the airport, or undefined if none could be obtained.

Defined in

src/sdk/navigation/FacilityLoader.ts:490


searchByIdent

searchByIdent(filter, ident, maxItems?): Promise<string[]>

Searches for ICAOs by their ident portion only.

Parameters

NameTypeDefault valueDescription
filterFacilitySearchTypeundefinedThe type of facility to filter by. Selecting ALL will search all facility type ICAOs.
identstringundefinedThe partial or complete ident to search for.
maxItemsnumber40The maximum number of matches to return. Defaults to 40.

Returns

Promise<string[]>

An array of matched ICAOs. Exact matches are sorted before partial matches.

Defined in

src/sdk/navigation/FacilityLoader.ts:546


searchMetar

searchMetar(lat, lon): Promise<undefined | Metar>

Searches for the METAR issued for the closest airport to a given location.

Parameters

NameTypeDescription
latnumberThe latitude of the center of the search, in degrees.
lonnumberThe longitude of the center of the search, in degrees.

Returns

Promise<undefined | Metar>

The METAR issued for the closest airport to the given location, or undefined if none could be found.

Defined in

src/sdk/navigation/FacilityLoader.ts:508


startNearestSearchSession

startNearestSearchSession<T>(type): Promise<SessionTypeMap[T]>

Starts a nearest facilities search session.

Type parameters

NameType
Textends FacilitySearchType

Parameters

NameTypeDescription
typeTThe type of facilities for which to search.

Returns

Promise<SessionTypeMap[T]>

A Promise which will be fulfilled with the new nearest search session.

Defined in

src/sdk/navigation/FacilityLoader.ts:411


getDatabaseCycles

getDatabaseCycles(): FacilityDatabaseCycles

Gets the AIRAC cycles associated with the facility database.

Returns

FacilityDatabaseCycles

an object containing the previous, current, and next cycles. If an error occurs and the MSFS facility cycle cannot be determined, the effective cycle for the current date is used instead.

Defined in

src/sdk/navigation/FacilityLoader.ts:677