gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
135 lines • 4.55 kB
TypeScript
import type { FeatureIterator, Reader, ReaderInputs } from '..';
import type { JSONCollection, MValue, Properties, VectorFeatures } from '../../geometry';
/**
* # JSON Buffer Reader
*
* ## Description
* Standard Buffer Reader for (Geo|S2)JSON
* implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { BufferJSONReader } from 'gis-tools-ts';
*
* const reader = new BufferJSONReader(`{ type: 'FeatureCollection', features: [...] }`);
* // OR
* const reader = new BufferJSONReader({ type: 'FeatureCollection', features: [...] });
* // OR
* const reader = new BufferJSONReader(
* await fetch('example.com/data.json').then(async (res) => await res.text())
* );
*
* // read the features
* for await (const feature of reader) {
* console.log(feature);
* }
* ```
*/
export declare class BufferJSONReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> implements FeatureIterator<M, D, P> {
data: JSONCollection<M, D, P>;
/** @param data - the JSON data to parase */
constructor(data: string | JSONCollection<M, D, P>);
/**
* Generator to iterate over each (Geo|S2)JSON object in the file
* @yields {VectorFeatures}
*/
[Symbol.asyncIterator](): AsyncGenerator<VectorFeatures<M, D, P>>;
}
/**
* # NewLine Delimited JSON Reader
*
* ## Description
* Parse (Geo|S2)JSON from a file that is in a newline-delimited format
* Implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { NewLineDelimitedJSONReader } from 'gis-tools-ts';
* import { FileReader } from 'gis-tools-ts/file';
*
* const reader = new NewLineDelimitedJSONReader(new FileReader('./data.geojsonld'));
*
* // read the features
* for await (const feature of reader) {
* console.log(feature);
* }
* ```
*/
export declare class NewLineDelimitedJSONReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> implements FeatureIterator<M, D, P> {
private seperator;
reader: Reader;
/**
* @param input - the input to parse from
* @param seperator - the newline delimiter. Default is "\n" but can be "\r\n" or "\r"
*/
constructor(input: ReaderInputs, seperator?: string);
/**
* Generator to iterate over each (Geo|S2)JSON object in the file
* @yields {VectorFeatures}
*/
[Symbol.asyncIterator](): AsyncGenerator<VectorFeatures<M, D, P>>;
}
/**
* # Text Sequence JSON Reader
*
* ## Description
* Parse GeoJSON from a file that is in the `geojson-text-sequences` format.
* Implements the {@link FeatureIterator} interface.
*
* ## Usage
* ```ts
* import { SequenceJSONReader } from 'gis-tools-ts';
* import { FileReader } from 'gis-tools-ts/file';
*
* const reader = new SequenceJSONReader(new FileReader('./data.geojsonseq'));
*
* // read the features
* for await (const feature of reader) {
* console.log(feature);
* }
* ```
*
* ## Links
* - https://datatracker.ietf.org/doc/html/rfc7464
* - https://datatracker.ietf.org/doc/html/rfc8142
* - https://github.com/geojson/geojson-text-sequences?tab=readme-ov-file
*/
export declare class SequenceJSONReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> extends NewLineDelimitedJSONReader<M, D, P> implements FeatureIterator<M, D, P> {
/** @param input - the input to parse from */
constructor(input: ReaderInputs);
}
/**
* # JSON Reader
*
* ## Description
* Parse (Geo|S2)JSON. Can handle millions of features.
* Implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { JSONReader } from 'gis-tools-ts';
* import { FileReader } from 'gis-tools-ts/file';
*
* const reader = new JSONReader(new FileReader('./data.geojsonld'));
*
* // read the features
* for await (const feature of reader) {
* console.log(feature);
* }
* ```
*/
export declare class JSONReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> implements FeatureIterator<M, D, P> {
#private;
reader: Reader;
/**
* @param input - the input to parse from
* @param chunkSize - the number of bytes to read at a time from the reader. [Default: 65_536]
*/
constructor(input: ReaderInputs, chunkSize?: number);
/**
* Generator to iterate over each (Geo|S2)JSON object in the reader.
* @yields {Features}
*/
[Symbol.asyncIterator](): AsyncGenerator<VectorFeatures<M, D, P>>;
}
//# sourceMappingURL=index.d.ts.map