Open tomplex opened 5 years ago
What is the usecase that you want to solve with that?
go-shp
is a library for reading the shapefile binary fileformat, converting the read geometries to WKT / WKB is a bit out of scope here. For precedence, are you aware of libraries (in other languages, maybe) that provide native WKT / WKB support for shape files?
I can understand the need to have a lingua franca for geometry data to ease the pain to glue together different libraries. I am just not sure that WKT / WKB would a be a good fit for go-shp
. Maybe the answer would be a subpackage?
Thanks for responding!
The general use case is, I have a shape file that I want to open, read geometry from, and process somehow. I don't want to write my own geometry processing algorithms because there already exist many implementations like those mentioned above, which can read their own geometry objects from wkt / wkb, but often dont implement reading of binary formats like shp or TAB - so we need to turn to libraries like this to do so.
We have "well known" formats for this reason, so that packages can support them - a relatively small interface - and easily interoperate with other packages which deal with geometry. Especially in a strongly typed language like Go, having a different implementation of geometry for every package doesn't help anything if none of them can talk to each other.
As for other languages, in Java / Geotools, you can convert a geometry read from shapefile to wkt using a factory (ugh) or using the toString()
method - which would be a nice fit for Golangs Stringer
interface.
In python, the default for the Fiona/Shapely packages is geojson, which is a good fit for Python because the dict
s are basically valid json as is. You could argue that they work so well together because they're written by the same guy - a valid point - but it's a pleasure to work with geometry in python because all the disparate tools work together easily.
All that said, I'd be very happy to take a shot at it and submit a PR for this package with an implementation that we can iterate on, if you would be receptive to it! I think a subpackage which has conversion functions could be a great solution, and a step in a direction towards easier interoperability.
Thanks for your time! Tom
This would make it a lot easier to use
go-shp
to interface with other libraries which implement geometry operations, like gogeos or orb.