UNPKG

gis-tools-ts

Version:

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

63 lines 2.17 kB
import type { FeatureIterator, MValue, Properties, VectorFeature, VectorGeometry, VectorPoint } from '../../index.js'; /** WKT Value can be a point or an array of points */ export type WKTAValue = VectorPoint | WKTAValue[]; /** WKT Array can be an array of points or even nested arrays of points */ export type WKTArray = WKTAValue[]; /** * # WKT Geometry Reader * * ## Description * Parse a collection of WKT geometries from a string * implements the {@link FeatureIterator} interface * * ## Usage * ```ts * import { WKTGeometryReader } from 'gis-tools-ts'; * * const reader = new WKTGeometryReader('POINT(4 6) GEOMETRYCOLLECTION(POINT(1 2), LINESTRING(3 4,5 6))'); * * // read the features * for await (const feature of reader) { * console.log(feature); * } * ``` * * ## Links * - https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry */ export declare class WKTGeometryReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> implements FeatureIterator<M, D, P> { data: VectorFeature<M, D, P>[]; /** @param data - the WKT geometry string to parase */ constructor(data: string); /** * Generator to iterate over each (Geo|S2)JSON object in the file * @yields {VectorFeature} */ [Symbol.asyncIterator](): AsyncGenerator<VectorFeature<M, D, P>>; } /** * # WKT Geometry Parser * * ## Description * Parse individual geometries from a WKT string into a VectorGeometry * * ## Usage * ```ts * import { parseWKTGeometry } from 'gis-tools-ts'; * * const geometry = parseWKTGeometry('POINT (1 2)'); * ``` * * ## Links * - https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry * @param wktStr - WKT string * @returns - VectorGeometry */ export declare function parseWKTGeometry<D extends MValue = MValue>(wktStr: string): VectorGeometry<D> | undefined; /** * Split a WKT string into individual geometries * @param input - WKT string that is a collection of geometries * @returns - Array of individual WKT geometries */ export declare function splitWKTGeometry(input: string): string[]; //# sourceMappingURL=geometry.d.ts.map