包详细信息

@terraformer/wkt

terraformer-js95.5kMIT2.2.1

Tools to convert WKT geometries to GeoJSON geometries and vica-versa.

wkt, convert, geo, geojson

自述文件

@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

更新日志

Change log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

Unreleased

[2.2.1]

Added

  • @terraformer/wkt
    • Errors parsing WKT are now surfaced instead of swallowed. (:pray: @mpalmerlee :pray:)

2.2.0

Added

  • @terraformer/wkt
    • Parse WKT Geometry Collection to GeoJSON Geomtery Collection. (:pray: @Zakhmaster :pray:)

2.1.2

Fixed

  • @terraformer/spatial
    • fix intersects for multipolygons
    • start exporting applyConverter

      2.1.1 - 2022-05-31

Fixed

  • ensure Z values of 0 are carried through when converting GeoJSON to ArcGIS Geometries.

2.1.0 - 2021-07-22

Added

  • added support for Z values when converting GeoJSON to ArcGIS Geometries.

2.0.7 - 2020-05-18

Fixed

  • all UMD and ESM files are now transpiled to make them safe to use in older browsers.

2.0.5 - 2020-05-17

Fixed

  • @terraformer/spatial
    • toCircle() now returns polygons of equal area, regardless of their latitude

2.0.0 - 2020-04-15

Changed

  • New Package names:

    • terraformer > @terraformer/spatial.
    • terraformer-arcgis-parser > @terraformer/arcgis.
    • terraformer-wkt-parser > @terraformer/wkt.
  • All packages are now standalone.