Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Latest commit

 

History

History
58 lines (41 loc) · 1.44 KB

README.md

File metadata and controls

58 lines (41 loc) · 1.44 KB

wkx

A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer with support for

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

Examples

The following examples show you how to work with wkx.

import wkx from '@rws-nl/wkx';

//Parsing a WKT string
const geometry = wkx.Geometry.parse('POINT(1 2)');

//Parsing an EWKT string
const geometry = wkx.Geometry.parse('SRID=4326;POINT(1 2)');

//Parsing a node Buffer containing a WKB object
const geometry = wkx.Geometry.parse(wkbBuffer);

//Parsing a node Buffer containing an EWKB object
const geometry = wkx.Geometry.parse(ewkbBuffer);

//Parsing a node Buffer containing a TWKB object
const geometry = wkx.Geometry.parseTwkb(twkbBuffer);

//Parsing a GeoJSON object
const geometry = wkx.Geometry.parseGeoJSON({
	type: 'Point',
	coordinates: [1, 2]
});

//Serializing a Point geometry to WKT
const wktString = new wkx.Point(1, 2).toWkt();

//Serializing a Point geometry to WKB
const wkbBuffer = new wkx.Point(1, 2).toWkb();

//Serializing a Point geometry to EWKT
const ewktString = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkt();

//Serializing a Point geometry to EWKB
const ewkbBuffer = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkb();

//Serializing a Point geometry to TWKB
const twkbBuffer = new wkx.Point(1, 2).toTwkb();

//Serializing a Point geometry to GeoJSON
const geoJSONObject = new wkx.Point(1, 2).toGeoJSON();