Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

io-ts codecs to/from WKT (via GeoJson)

License

Notifications You must be signed in to change notification settings

holvonix-open/wkt-io-ts

Repository files navigation

wkt-io-ts - validates, encodes, and decodes between GeoJSON and WKT strings

License npm Build Status GitHub last commit codecov Dependabot Status DeepScan grade Code Style: Google npm bundle size semantic-release

Quick Start

After yarn add wkt-io-ts fp-ts:

import { GeometryFromWKTString, WKTStringFromGeometry } from 'wkt-io-ts';
import { isRight } from 'fp-ts/lib/Either';

const maybeWkt = 'LINESTRING (29.3 -5, 13 30, 50 32)';
const maybeGJ = GeometryFromWKTString.decode(maybeWkt);
if (!isRight(maybeGJ)) {
  // did not validate as WKT
  throw new Error();
}
// geojson
console.log(maybeGJ.right);

const outWkt = WKTStringFromGeometry.decode(maybeGJ.right);
if (!isRight(outWkt)) {
  // did not validate as GeoJSON
  throw new Error();
}
// wkt
console.log(outWkt.right);

License

Read the LICENSE for details.
The entire NOTICE file serves as the NOTICE that must be included under Section 4d of the License.


# wkt-io-ts

This product contains software originally developed by Holvonix LLC.
Original Repository: https://github.com/holvonix-open/wkt-io-ts

Copyright (c) 2019 Holvonix LLC. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this software except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Dependencies may have their own licenses.