Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wkt

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wkt

Parse WKT (Well-known text) into geoJSON or stringify geoJSON into WKT

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.9K
increased by7.41%
Maintainers
1
Weekly downloads
 
Created
Source

wkt

NPM version

Install

npm install wkt

Usage

Parse

const wkt = require('wkt');
const { parse } = require('wkt');

//  See return values in output section
wkt.parse('POINT(1 2)');
parse("POINT Z (58.51466818909509 8.629797415591964 61.77237)");
parse("LINESTRING (30 10, 10 30, 40 40)");
parse("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))");
Output from parse()
{ type: 'Point', coordinates: [ 1, 2 ] }
{ type: 'Point', coordinates: [ 58.51466818909509, 8.629797415591964, 61.77237 ] }
{ type: 'LineString', coordinates: [ [ 30, 10 ], [ 10, 30 ], [ 40, 40 ] ] }
{ type: 'Polygon', coordinates: [[[30,10], [40,40], [20,40], [10,20], [30,10]]] }

Stringify

const { stringify } = require('wkt');

const geometry = {
  type: "Point",
  coordinates: [125.6, 10.1, 54.2]
};
const geometry2 = { 
  type: 'LineString',
  coordinates: [ [ 30, 10 ], [ 10, 30 ], [ 40, 40 ] ] 
};

//  See return values in output section
stringify(geometry);
stringify(geometry2);
Output from stringify()
"POINT Z (125.6 10.1 54.2)"
"LINESTRING (30 10, 10 30, 40 40)"

Docs

parse(wkt)

Parse Well-known text string into GeoJSON

stringify(geojson)

Stringifies a GeoJSON geometry object or Feature object into a WKT (Well-known text) string. Throws an error if given a FeatureCollection or unknown input.

Supported types

  • Point + MultiPoint
  • LineString + MultiLineString
  • Polygon + MultiPolygon
  • GeometryCollection
  • WKT's containing "Z"

Keywords

FAQs

Package last updated on 01 Nov 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc