UNPKG

wkt-parser-helper

Version:

Module to help parse GeoJSONs to WKT and back

66 lines (65 loc) 2.78 kB
import type { Feature, FeatureCollection, GeoJSON, GeoJsonProperties, Geometry } from 'geojson'; export declare const EMPTY_GEOMETRY_COLLECTION_WKT = "GEOMETRYCOLLECTION EMPTY"; /** * Converts GeoJSON Geometry to WKT * * @param {Geometry} geojson Geometry object to convert * @return {string} The GeoJSON converted to well known text representation */ export declare function geometryToWkt(geojson: Geometry): string; /** * Converts GeoJSON Feature to WKT * * @param {Feature} geojson Feature object to convert * @return {string} The GeoJSON converted to well known text representation */ export declare function featureToWkt(geojson: Feature): string; /** * Converts a GeoJSON FeatureCollection to WKT GeometryCollection * @param {FeatureCollection} featureCollection The FeatureCollection to convert to WKT * @return {string} The GeoJSON converted to well known representation */ export declare function featureCollectionToWkt(featureCollection: FeatureCollection): string; /** * Shorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT * * @param {GeoJSON} geojson The GeoJSON to convert * @return {string} The GeoJSON as WKT */ export declare function geojsonToWkt(geojson: GeoJSON): string; /** * Converts a GeoJSON FeatureCollection into an array of objects where each object * contains a WKT string representing the geometry and the properties * from the original GeoJSON feature * * @template P The type of properties in the GeoJSON features * @param {FeatureCollection<Geometry, P>} geojson The GeoJSON FeatureCollection to be converted * @returns {(P & { wkt: string })[]} An array of objects where each object contains a `wkt` string * representing the geometry and all the properties from the original GeoJSON feature */ export declare function featureCollectionToWktList<P>(geojson: FeatureCollection<Geometry, P>): (P & { wkt: string; })[]; /** * Parse a WKT into a GeoJSON Feature or Geometry * * @param {string} item The WKT to convert to GeoJSON * @param {boolean} [asFeature=false] Wrap the converted geometry into a Feature * @param {GeoJsonProperties} [properties={}] Metadata to embed the Feature with * @return {(Feature | Geometry)} The WKT as GeoJSON */ export declare function wktToGeojson(item: string, asFeature?: boolean, properties?: GeoJsonProperties): Feature | Geometry; /** * Parse a 3D GeoJSON into a 2D GeoJSON * * @param {GeoJSON} geojson The 3D GeoJSON to convert to 2D * @return {GeoJSON} The GeoJSON as 2D */ export declare function geojson3dTo2d(geojson: GeoJSON): GeoJSON; /** * Parse a Z WKT into a 2D WKT * * @param {string} wkt The Z WKT to convert to 2D WKT * @return {string} The Z WKT as 2D WKT */ export declare function wkt3dTo2d(wkt: string): string;