gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
63 lines • 2.68 kB
TypeScript
import type { FeatureIterator } from '../../readers/index.js';
import type { Writer } from '../index.js';
import type { Projection, VectorFeatures } from '../../geometry/index.js';
/** User defined options on how to store the features */
export interface ToJSONOptions {
/** S2 or WG */
projection?: Projection;
/** add a bounding box */
buildBBox?: boolean;
/** to store as a FeatureCollection / Feature where the m-value is dropped and [x, y, z] instead of { x, y, z } for each Point */
geojson?: boolean;
/** handle each feature */
onFeature?: (feature: VectorFeatures) => VectorFeatures | undefined;
}
/**
* Given a writer and an array of iterators, write the input features to the writer as a JSON object
*
* Usage:
* ```ts
* import { toJSON, JSONReader } from 'gis-tools-ts';
* import { FileReader, FileWriter } from 'gis-tools-ts/file';
* // or use mmap reader if using bun
* // import { MMapReader } from 'gis-tools-ts/mmap';
*
* const fileReader = new FileReader(`${__dirname}/fixtures/points.geojson`);
* const jsonReader = new JSONReader(fileReader);
* const bufWriter = new FileWriter(`${__dirname}/fixtures/points2.geojson`);
*
* // store to singular output
* await toJSON(bufWriter, [jsonReader], { projection: 'WG', buildBBox: true });
* ```
* @param writer - the writer to append strings to
* @param iterators - the collection of iterators to write
* @param opts - user defined options [optional]
*/
export declare function toJSON(writer: Writer, iterators: FeatureIterator[], opts?: ToJSONOptions): Promise<void>;
/**
* Given a writer and an array of iterators, write the input features to the writer as JSON-LD
*
* Usage:
* ```ts
* import { toJSONLD, JSONReader } from 'gis-tools-ts';
* import { FileReader, FileWriter } from 'gis-tools-ts/file';
* // or use mmap reader if using bun
* // import { MMapReader } from 'gis-tools-ts/mmap';
*
* const fileReader = new FileReader(`${__dirname}/fixtures/points.geojson`);
* const jsonReader = new JSONReader(fileReader);
* const bufWriter = new FileWriter(`${__dirname}/fixtures/points.geojsonld`);
* const onFeature = (feature) => {
* feature.metadata = { id: feature.id };
* return feature;
* }
*
* // store to singular output
* await toJSONLD(bufWriter, [jsonReader], { projection: 'S2', buildBBox: true, onFeature });
* ```
* @param writer - the writer to apppend strings to
* @param iterators - the collection of iterators to write
* @param opts - user defined options [optional]
*/
export declare function toJSONLD(writer: Writer, iterators: FeatureIterator[], opts?: ToJSONOptions): Promise<void>;
//# sourceMappingURL=index.d.ts.map