// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import { parseTileJSON } from "./lib/parse-tilejson.js"; // __VERSION__ is injected by babel-plugin-version-inline // @ts-ignore TS2304: Cannot find name '__VERSION__'. const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest'; /** * Loader for TileJSON metadata */ export const TileJSONLoader = { dataType: null, batchType: null, name: 'TileJSON', id: 'tilejson', module: 'pmtiles', version: VERSION, worker: true, extensions: ['json'], mimeTypes: ['application/json'], text: true, options: { tilejson: { maxValues: undefined } }, parse: async (arrayBuffer, options) => { const jsonString = new TextDecoder().decode(arrayBuffer); const json = JSON.parse(jsonString); const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson }; return parseTileJSON(json, tilejsonOptions); }, parseTextSync: (text, options) => { const json = JSON.parse(text); const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson }; return parseTileJSON(json, tilejsonOptions); } };