wkt-parser-helper
Version:
Module to help parse GeoJSONs to WKT and back
56 lines (55 loc) • 2.38 kB
TypeScript
import type { GeoJSON, GeoJsonProperties, Feature, Geometry, FeatureCollection } from 'geojson';
/**
* Converts GeoJSON Geometry to WKT
*
* @export
* @param {Geometry} geojson Geometry object to convert
* @return {string} The GeoJSON converted to well known text representation
*/
export declare function convertGeometryToWK(geojson: Geometry): string;
/**
* Converts GeoJSON Feature to WKT
*
* @export
* @param {Feature} geojson Feature object to convert
* @return {string} The GeoJSON converted to well known text representation
*/
export declare function convertFeatureToWK(geojson: Feature): string;
/**
* Converts a GeoJSON FeatureCollection to WKT GeometryCollection
* @export
* @param {FeatureCollection} featureCollection The FeatureCollection to convert to WKT
* @return {string} The GeoJSON converted to well known representation
*/
export declare function convertFeatureCollection(featureCollection: FeatureCollection): string;
/**
* Shorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT or WKB
*
* @export
* @param {GeoJSON} geojson The GeoJSON to convert
* @return {string} The GeoJSON as WKT
*/
export declare function convertToWK(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 convertFeatureCollectionToWktCollection<P>(geojson: FeatureCollection<Geometry, P>): (P & {
wkt: string;
})[];
/**
* Parse a WKT or WKB into a GeoJSON Feature or Geometry
*
* @export
* @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 parseFromWK(item: string, asFeature?: boolean, properties?: GeoJsonProperties): Feature | Geometry;