UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

58 lines 2.43 kB
import type { FeatureIterator } from '../../readers'; import type { Writer } from '../../writers'; import type { Projection, VectorFeatures } from '../../geometry'; /** User defined options on how to store the features */ export interface ToJSONOptions { projection?: Projection; buildBBox?: boolean; 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