@terraformer/wkt
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/terraformer__wkt package

2.2.0 • Public • Published

@terraformer/wkt

npm travis standard

Tools to convert WKT geometries to GeoJSON geometries and vice versa.

Install

npm install @terraformer/wkt

API Reference

Terraformer

Terraformer.wktToGeoJSON(WKT) ⇒ object

Converts a WKT geometry into a GeoJSON geometry.

Kind: static method of Terraformer
Returns: object - GeoJSON.

import { wktToGeoJSON } from "@terraformer/wkt"

wktToGeoJSON("POINT (-122.6764 45.5165)");

>> { "type": "Point", "coordinates": [ -122.6764, 45.5165 ] }
Param Type Description
WKT string The input WKT geometry.

Terraformer.geojsonToWKT(GeoJSON) ⇒ string

Converts a GeoJSON geometry or GeometryCollection into a WKT string.

Kind: static method of Terraformer
Returns: string - WKT.

import { geojsonToWKT } from "@terraformer/wkt"

const geojsonPoint = {
  "type": "Point",
  "coordinates": [-122.6764, 45.5165]
}

geojsonToWKT(geojsonPoint)

>> "POINT (-122.6764 45.5165)"
Param Type Description
GeoJSON object The input GeoJSON geometry or GeometryCollection.

Usage

Browser (from CDN)

This package is distributed as a UMD module and can also be used in AMD based systems or as a global under the Terraformer namespace.

<script src="https://unpkg.com/@terraformer/wkt"></script>
Terraformer.wktToGeoJSON("POINT (-122.6764 45.5165)");

Node.js

const Terraformer = require('@terraformer/wkt');

Terraformer.geojsonToWKT(/* ... */);
Terraformer.wktToGeoJSON(/* ... */);

ES module in the browser

<script type='module'>
  import { wktToGeoJSON } from 'https://unpkg.com/@terraformer/wkt?module';

  // look ma, no build step!
  wktToGeoJSON(/* ... */);
</script>

Contributing

LICENSE

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @terraformer/wkt

    Weekly Downloads

    11,243

    Version

    2.2.0

    License

    MIT

    Unpacked Size

    92.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • jgravois
    • jerrysievert
    • gavinr
    • patrickarlt