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.
var wkx = ; //Parsing a WKT stringvar geometry = wkxGeometry; //Parsing an EWKT stringvar geometry = wkxGeometry; //Parsing a node Buffer containing a WKB objectvar geometry = wkxGeometry; //Parsing a node Buffer containing an EWKB objectvar geometry = wkxGeometry; //Parsing a node Buffer containing a TWKB objectvar geometry = wkxGeometry; //Parsing a GeoJSON objectvar geometry = wkxGeometry; //Serializing a Point geometry to WKTvar wktString = 1 2; //Serializing a Point geometry to WKBvar wkbBuffer = 1 2; //Serializing a Point geometry to EWKTvar ewktString = 1 2 undefined undefined 4326; //Serializing a Point geometry to EWKBvar ewkbBuffer = 1 2 undefined undefined 4326; //Serializing a Point geometry to TWKBvar twkbBuffer = 1 2; //Serializing a Point geometry to GeoJSONvar geoJSONObject = 1 2;
Browser
To use wkx
in a webpage, simply copy a built browser version from dist/
into your project, and use a script
tag
to include it:
If you use browserify for your project, you can simply npm install wkx --save
, and just require wkx
as usual in
your code.
Regardless of which of the preceeding options you choose, using wkx
in the browser will look the same:
var wkx = ; var geometry = wkxGeometry; console;
In addition to the wkx
module, the browser versions also export buffer
, which is useful for parsing WKB:
var Buffer = Buffer;var wkx = ; var wkbBuffer = '0101000000000000000000f03f0000000000000040' 'hex';var geometry = wkxGeometry; console;