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);
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.