Skip to main content

Class: FacilityLoader

Defined in: src/sdk/navigation/FacilityLoader.ts:181

A class that handles loading facility data from the simulator.

Constructors​

Constructor​

new FacilityLoader(facilityRepo, onInitialized): FacilityLoader

Defined in: src/sdk/navigation/FacilityLoader.ts:214

Creates an instance of the FacilityLoader.

Parameters​

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

Returns​

FacilityLoader

Properties​

onInitialized()​

readonly onInitialized: () => void

Defined in: src/sdk/navigation/FacilityLoader.ts:216

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

Returns​

void

Methods​

awaitInitialization()​

awaitInitialization(): Promise<void>

Defined in: src/sdk/navigation/FacilityLoader.ts:250

Waits until this facility loader is initialized.

Returns​

Promise<void>

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


findNearestFacilitiesByIdent()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:584

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

Type Parameters​

Type Parameter
T extends FacilitySearchTypeLatLon

Parameters​

ParameterTypeDefault 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.


getAirway()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:376

Gets airway data from the sim.

Parameters​

ParameterTypeDescription
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


getFacility()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:267

Retrieves a facility.

Type Parameters​

Type Parameter
T extends FacilityType

Parameters​

ParameterTypeDescription
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.


getMetar()​

Call Signature​

getMetar(airport): Promise<undefined | Metar>

Defined in: src/sdk/navigation/FacilityLoader.ts:484

Gets a METAR for an airport.

Parameters​
ParameterTypeDescription
airportAirportFacilityAn airport.
Returns​

Promise<undefined | Metar>

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

Call Signature​

getMetar(ident): Promise<undefined | Metar>

Defined in: src/sdk/navigation/FacilityLoader.ts:490

Gets a METAR for an airport.

Parameters​
ParameterTypeDescription
identstringAn airport ident.
Returns​

Promise<undefined | Metar>

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


searchByIdent()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:546

Searches for ICAOs by their ident portion only.

Parameters​

ParameterTypeDefault 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.


searchMetar()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:508

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

Parameters​

ParameterTypeDescription
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.


startNearestSearchSession()​

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

Defined in: src/sdk/navigation/FacilityLoader.ts:411

Starts a nearest facilities search session.

Type Parameters​

Type Parameter
T extends FacilitySearchType

Parameters​

ParameterTypeDescription
typeTThe type of facilities for which to search.

Returns​

Promise<SessionTypeMap[T]>

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


getDatabaseCycles()​

static getDatabaseCycles(): FacilityDatabaseCycles

Defined in: src/sdk/navigation/FacilityLoader.ts:677

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.