Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parsing Well Known Text (WKT) Geometry #1075

Open
banesullivan opened this issue Mar 5, 2021 · 2 comments
Open

Add support for parsing Well Known Text (WKT) Geometry #1075

banesullivan opened this issue Mar 5, 2021 · 2 comments

Comments

@banesullivan
Copy link

banesullivan commented Mar 5, 2021

WKT projection strings are supported in https://github.com/proj4js/wkt-parser but geometry are not.

This (seemingly no longer maintained) project has support for converting WKT geometry to GeoJSON: https://github.com/mapbox/wellknown.

I see a few potential ways to use this existing tool to support WKT in GeoJS:

  1. Since mapbox/wellknown appears to be an old project and has a permissive license, we could adopt some of the code to create our own WKT reader directly in GeoJS.
  2. We could fork the project, update it, and use this maintained version as a dependency for a new WKT reader in GeoJS.
  3. We could fork the project, update it, and use it in downstream apps to convert WKT to GeoJSON as needed and then read that with the existing geojsonReader in GeoJS (not affecting the GeoJS code base at all)

Thoughts on a path forward for supporting WKT? I understand introducing a new dependency is something to approach with caution.


Example data:

SRID=4326;POLYGON ((-128.5300591082298 51.77034988853305, -65.39464888719978 51.77034988853305, -65.39464888719978 22.47939186951065, -128.5300591082298 22.47939186951065, -128.5300591082298 51.77034988853305))
@manthey
Copy link
Contributor

manthey commented Mar 5, 2021

I don't know the merits of the different wkt libraries, but a quick look also shows https://github.com/Esri/terraformer-wkt-parser. That project has been more active recently and appears to have more use.

I think the right way to do this is probably to create a wktReader analog to the geojsonReader. We also want to make sure there are convenience functions exposed for converting between the two so that using them with, for instance, annotations would be something like geojson_to_wkt(annotationLayer.geojson()) or annotationLayer.geojson(wkt_to_geojson(wkt)) (or whatever the functions are called).

@aashish24
Copy link
Member

terraformer could be another good one, I have looked into it as well. Having some capabilities in geojs to read wkt would be nice even if it call a third party library to do the job so perhaps option 2 or 3 might be optimal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants