GithubHelp home page GithubHelp logo

placemark / betterknown Goto Github PK

View Code? Open in Web Editor NEW
38.0 3.0 2.0 140 KB

modern parser & stringifier for WKT, EWKT, and GeoJSON

Home Page: https://placemark.github.io/betterknown/

License: Other

TypeScript 98.40% JavaScript 1.60%
geojson wkt

betterknown's Introduction

betterknown

betterknown development is supported by ๐ŸŒŽ placemark.io

I wrote wellknown, a WKT parser and stringifier, eons ago. It's still sort of popular but nobody maintained it after I left Mapbox.

There's wkx, which is stricter and honestly has a better parser, plus supports WKB, but it's also abandoned and has some drawbacks - no TypeScript, somewhat idiosyncratic code, and the bundle size is larger than it needs to be because it brings in browserify shims.

This project aims to be the combination of the two projects. Lightweight like wellknown, strict and correct like wkx, plus with the 2022 energy of supporting TypeScript from day one.

  • 100% TypeScript
  • No dependencies - tiny bundle
  • Parse WKT to GeoJSON, stringify GeoJSON to WKT
  • Optional reprojection of EWKT to GeoJSON's required WGS84 coordinate system

Example

import { wktToGeoJSON, geoJSONToWkt } from "betterknown";
import proj4 from "proj4";

// Converting & reprojecting an EWKT string
wktToGeoJSON(`SRID=3857;POINT(-400004.3 60000.1)`, {
  proj: proj4,
});

// Converting GeoJSON to WKT
geoJSONToWkt({
  type: 'Point',
  coordinates: [1, 2]
});

betterknown's People

Contributors

aliothor avatar tmcw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

torrunt aliothor

betterknown's Issues

Detect and handle heterogenous coordinates

GeoJSON that can exist:

{
  "type": "LineString",
  "coordinates": [[0, 1, 2], [2, 3]]
}

Should this be a LINESTRING or LINESTRING Z in WKT? Probably just a LINESTRING. This should be detected and handled explicitly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.