wkt-parser-helper
Installation
Using npm npm i wkt-parser-helper
Using yarn yarn add wkt-parser-helper
Usage
In CommonJS env
const { parseFromWK } = require('wkt-parser-helper');
const geojson = parseFromWK(
'POLYGON((-3.706512451171875 40.420074462890625,-3.70513916015625 40.420074462890625,-3.70513916015625 40.42144775390625,-3.706512451171875 40.42144775390625,-3.706512451171875 40.420074462890625))'
);
Using imports
import { convertToWK } from 'wkt-parser-helper';
const myFeature: Feature = {
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[-3.706512451171875, 40.420074462890625],
[-3.70513916015625, 40.420074462890625],
[-3.70513916015625, 40.42144775390625],
[-3.706512451171875, 40.42144775390625],
[-3.706512451171875, 40.420074462890625],
],
],
},
};
const myFeatureAsWKT = convertToWK(myFeature, 'wkt');
Table of contents
Type aliases
Functions
Type aliases
WKType
Ƭ WKType: wkt | wkb
Defined in: index.ts:4
Functions
convertFeatureCollection
▸ convertFeatureCollection(featureCollection
: FeatureCollection): string
Converts a GeoJSON FeatureCollection to WKT GeometryCollection
export
Parameters:
Name | Type | Description |
---|
featureCollection | FeatureCollection | The FeatureCollection to convert to WKT |
Returns: string
The GeoJSON converted to well known representation
Defined in: index.ts:38
convertFeatureToWK
▸ convertFeatureToWK(geojson
: Feature, type?
: WKType): string | Buffer
Converts GeoJSON Feature to WKT or WKB
export
Parameters:
Name | Type | Default value | Description |
---|
geojson | Feature | - | Feature object to convert |
type | WKType | 'wkt' | - |
Returns: string | Buffer
The GeoJSON converted to well known representation
Defined in: index.ts:28
convertGeometryToWK
▸ convertGeometryToWK(geojson
: Geometry, type?
: WKType): string | Buffer
Converts GeoJSON Geometry to WKT or WKB
export
Parameters:
Name | Type | Default value | Description |
---|
geojson | Geometry | - | Geometry object to convert |
type | WKType | 'wkt' | - |
Returns: string | Buffer
The GeoJSON converted to well known representation
Defined in: index.ts:14
convertToWK
▸ convertToWK(geojson
: GeoJSON, type?
: WKType): string | Buffer
Shorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT or WKB
export
Parameters:
Name | Type | Default value | Description |
---|
geojson | GeoJSON | - | The GeoJSON to convert |
type | WKType | 'wkt' | - |
Returns: string | Buffer
The GeoJSON as WKT or WKB
Defined in: index.ts:56
parseFromWK
▸ parseFromWK(item
: string | Buffer, asFeature?
: boolean, properties?
: GeoJsonProperties): Feature | Geometry
Parse a WKT or WKB into a GeoJSON Feature or Geometry
export
Parameters:
Name | Type | Default value | Description |
---|
item | string | Buffer | - | The WK to convert to GeoJSON |
asFeature | boolean | false | - |
properties | GeoJsonProperties | - | - |
Returns: Feature | Geometry
The WK as GeoJSON
Defined in: index.ts:76