@loaders.gl/json
Version:
Framework-independent loader for JSON and streaming JSON formats
28 lines (27 loc) • 920 B
JavaScript
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
// Copyright Foursquare, Inc 20222
import { concatenateArrayBuffersAsync } from '@loaders.gl/loader-utils';
import { encodeTableAsGeojsonInBatches } from "./lib/encoders/geojson-encoder.js";
export const GeoJSONWriter = {
id: 'geojson',
version: 'latest',
module: 'geojson',
name: 'GeoJSON',
extensions: ['geojson'],
mimeTypes: ['application/geo+json'],
text: true,
options: {
geojson: {
featureArray: false,
geometryColumn: null
}
},
async encode(table, options) {
const tableIterator = [table];
const batches = encodeTableAsGeojsonInBatches(tableIterator, options);
return await concatenateArrayBuffersAsync(batches);
},
encodeInBatches: (tableIterator, options) => encodeTableAsGeojsonInBatches(tableIterator, options)
};