s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
96 lines • 3.2 kB
TypeScript
import type { FeatureIterator, Reader, ReaderInputs } from '..';
import type { Features, JSONCollection, MValue, Properties } from '../../geometry';
/**
* # JSON Buffer Reader
*
* ## Description
* Standard Buffer Reader for (Geo|S2)JSON
* implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { BufferJSONReader } from 's2-tools';
*
* const reader = new BufferJSONReader('{ type: 'FeatureCollection', features: [...] }');
* // OR
* const reader = new BufferJSONReader({ type: 'FeatureCollection', features: [...] });
*
* // 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 {Features}
*/
[Symbol.asyncIterator](): AsyncGenerator<Features<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 's2-tools';
* import { FileReader } from 's2-tools/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> {
reader: Reader;
/** @param input - the input to parse from */
constructor(input: ReaderInputs);
/**
* Generator to iterate over each (Geo|S2)JSON object in the file
* @yields {Features}
*/
[Symbol.asyncIterator](): AsyncGenerator<Features<M, D, P>>;
}
/**
* # JSON Reader
*
* ## Description
* Parse (Geo|S2)JSON. Can handle millions of features.
* Implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { JSONReader } from 's2-tools';
* import { FileReader } from 's2-tools/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<Features<M, D, P>>;
}
//# sourceMappingURL=index.d.ts.map