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 Charts API:

FunctionDescription
fsChartsGetIndexGets the chart index for a given airport from the given provider (LIDO/FAA).
fsChartsGetPagesGets the list of pages for a given chart.
fsChartsGetPageImageGets the image of a given chart page.
fsChartsFreeChartIndexFrees the given chart index structure.
fsChartsFreeChartPagesFrees the given chart pages structure.

Enums/Structs

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

Enum / Struct NameDescriptionType
FsChartIndexA chart index for an airport.Struct
FsChartIndexCategoryA set of charts belonging to one category, part of a chart index.Struct
FsChartMetadataMetadata regarding a chart, part of a chart category.Struct
FsChartPagesA collection of chart pages.Struct
FsChartProcedureIdentifierA procedure identifier, linking a chart to a procedure at its airport.Struct
FsChartProcedureIdentifierTypeA chart procedure identifier type.Enum
FsChartRelationshipA relationship between two charts.Struct
FsChartRelationshipTypeA chart relationship type.Enum
FsChartPageAn individual page of a chart.Struct
FsChartAreaAn area on a chart, possibly geo-referenced.Struct
FsChartRectangleA rectangle on a chart, either in pixel coordinates or in longitude/latitude coordinates.Struct
FsChartGeoReferenceLambertConformalConicProjectionA Lambert Conformal Conic projection for a chart area.Struct
FsChartPageUrlA URL for a chart page image.Struct
FsChartErrorA 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
);
ParametersDescription
errorIf the request failed, this parameter will contain the error code. Otherwise, its value is FsChartError_None.
indexThe 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.
userDataThe user data passed in when calling fsChartsGetIndex.

The value of the error parameter should always be checked before trying to use the index.

FsChartsPagesCallback

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

typedef void (*FsChartsPagesCallback)(
    FsChartError error,
    FsChartPages* pages,
    void* userData
);
ParametersDescription
errorIf the request failed, this parameter will contain the error code. Otherwise, its value is FsChartError_None.
pagesThe 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.
userDataThe user data passed in when calling fsChartsGetPages.

The value of the error parameter should always be checked before trying to use the pages.

FsChartsPageImageCallback

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

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

The pageImageId is an image ID which can be used with all of the relevant NanoVG and LLVG functions. It is the caller’s responsibility to delete this image when it’s no longer in use.

The value of the error parameter should always be checked before trying to use the pageImageId.

0/255