Socket
Socket
Sign inDemoInstall

wkt-parser-helper

Package Overview
Dependencies
3
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wkt-parser-helper

Module to help parse GeoJSONs to WKT and back


Version published
Weekly downloads
1.9K
decreased by-5.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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))'
);

// geojson is a Polygon Geometry

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');

// myFeatureAsWKT is 'POLYGON((-3.706512451171875 40.420074462890625,-3.70513916015625 40.420074462890625,-3.70513916015625 40.42144775390625,-3.706512451171875 40.42144775390625,-3.706512451171875 40.420074462890625))'

Table of contents

Type aliases

  • WKType

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:
NameTypeDescription
featureCollectionFeatureCollectionThe 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:
NameTypeDefault valueDescription
geojsonFeature-Feature object to convert
typeWKType'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:
NameTypeDefault valueDescription
geojsonGeometry-Geometry object to convert
typeWKType'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:
NameTypeDefault valueDescription
geojsonGeoJSON-The GeoJSON to convert
typeWKType'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:
NameTypeDefault valueDescription
itemstring | Buffer-The WK to convert to GeoJSON
asFeaturebooleanfalse-
propertiesGeoJsonProperties--

Returns: Feature | Geometry

The WK as GeoJSON

Defined in: index.ts:76

Keywords

FAQs

Last updated on 13 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc