CHARTS API

The Charts API offers the ability to fetch built-in LIDO and FAA charts - and their associated metadata - from within the simulator. As this is an asynchronous API, every function accepts a callback which is invoked when the operation completes, whether it was successfully or not. If an operation has failed, an error code will be returned.

 

The chart page images are returned from the API as NanoVG (or LLVG) images which can then be drawn using the applicable NanoVG (or LLVG) functions.

IMPORTANT: Unlike other WASM APIs, due to the complexity of the returned data structures in the charts API, it is the API caller's responsibility to free them once they are no longer in use. The data structures should be freed using the provided functions (namely, fsChartsFreeChartIndex and fsChartsFreeChartPages). Improperly freeing these structures can lead to memory leaks.

 

This API mirrors the JS charts API as closely as possible, making it easy to transition between the two APIs.

 

 

Functions

The following functions are available for the Communication API:

 

Function Description
fsChartsGetIndex Gets the chart index for a given airport from the given provider (LIDO/FAA).
fsChartsGetPages Gets the list of pages for a given chart.
fsChartsGetPageImage Gets the image of a given chart page.
fsChartsFreeChartIndex Frees the given chart index structure.
fsChartsFreeChartPages Frees the given chart pages structure.

 

 

Enums/Structs

The enums and structs available for use with the Chart API are:

 

Function Description Type
FsChartIndex A chart index for an airport. Struct
FsChartIndexCategory A set of charts belonging to one category, part of a chart index. Struct
FsChartMetadata Metadata regarding a chart, part of a chart category. Struct
FsChartPages A collection of chart pages. Struct
FsChartProcedureIdentifier A procedure identifier, linking a chart to a procedure at its airport. Struct
FsChartProcedureIdentifierType A chart procedure identifier type. Enum
FsChartRelationship A relationship between two charts. Struct
FsChartRelationshipType A chart relationship type. Enum
FsChartPage An individual page of a chart. Struct
FsChartArea An area on a chart, possibly geo-referenced. Struct
FsChartRectangle A rectangle on a chart, either in pixel coordinates or in longitude/latitude coordinates. Struct
FsChartGeoReferenceLambertConformalConicProjection A Lambert Conformal Conic projection for a chart area. Struct
FsChartPageUrl A URL for a chart page image. Struct
FsChartError A charts API error code. Enum

 

 

Typedefs

When using the functions listed above, you'll need to also have the following type definitions, as they will be used as return values or to create callbacks by many of the functions. These typedefs are listed below.

 

 

FsChartsIndexCallback

The callback invoked when fsChartsGetIndex completes, whether successfully or not:

typedef void (*FsChartsIndexCallback)(
    FsChartError error,
    FsChartIndex* index,
    void* userData
);
Parameters Description
error If the request failed, this parameter will contain the error code. Otherwise, its value is FsChartError_None.
index The fetched chart index, or NULL if the request didn't succeed. The API caller owns this pointer and is responsible for freeing it using fsChartsFreeChartIndex when no longer in use.
userData The user data passed in when calling fsChartsGetIndex.

 

 

FsChartsPagesCallback

The callback invoked when fsChartsGetPages completes, whether successfully or not:

typedef void (*FsChartsPagesCallback)(
    FsChartError error,
    FsChartPages* pages,
    void* userData
);
Parameters Description
error If the request failed, this parameter will contain the error code. Otherwise, its value is FsChartError_None.
pages The fetched chart page collection, or NULL if the request didn't succeed. The API caller owns this pointer and is responsible for freeing it using fsChartsFreeChartPages when no longer in use.
userData The user data passed in when calling fsChartsGetPages.

 

 

FsChartsPageImageCallback

The callback invoked when fsChartsGetPageImage completes, whether successfully or not:

typedef void (*FsChartsPageImageCallback)(
    FsChartError error,
    int pageImageId,
    void* userData
);
Parameters Description
error If the request failed, this parameter will contain the error code. Otherwise, its value is FsChartError_None.
pageImageId The fetched NanoVG (or LLVG) image ID, or -1 if the request didn't succeed.
userData The user data passed in when calling fsChartsGetPageImage.