UNPKG

@loaders.gl/lerc

Version:

Framework-independent loader for LERC (Limited Error Raster Compression) files

34 lines (33 loc) 948 B
// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import * as Lerc from 'lerc'; // __VERSION__ is injected by babel-plugin-version-inline // @ts-ignore TS2304: Cannot find name '__VERSION__'. const VERSION = typeof "4.3.3" !== 'undefined' ? "4.3.3" : 'latest'; /** * Loader for the LERC raster format */ export const LERCLoader = { dataType: null, batchType: null, id: 'lerc', name: 'LERC', module: 'lerc', version: VERSION, worker: false, extensions: ['lrc', 'lerc', 'lerc2', 'lerc1'], mimeTypes: ['application/octet-stream'], // test: ?, options: { lerc: {} }, parse: async (arrayBuffer, options) => parseLERC(arrayBuffer, options) }; async function parseLERC(arrayBuffer, options) { // Load the WASM library await Lerc.load(); // Perform the decode const pixelBlock = Lerc.decode(arrayBuffer, options?.lerc); return pixelBlock; }