ewestern / geos

This is a Haskell binding to Geos, the open-source geometry library
MIT License
13 stars 9 forks source link

Consider adding PersistentField(Sql) instances and Esqueleto querying #29

Open tysonzero opened 6 years ago

tysonzero commented 6 years ago

I created a small postgis library for persistent here and for esqueleto here. I am now realizing that it seems like it might be better to build off of or just use geos directly.

I was wondering if the instances could be added into geos itself, although I realize the dependency on persistent/esqueleto might make it not worth it.

My primary usage for geos is for Geographies rather than Geometries, and I'm not 100% clear on the amount of compatibility / overlap between the two. But ideally I was hoping that all the types I have in persistent-postgis including their associated db types could be converted over in some form into geos, perhaps involving some type level machinary to allow for easily defining both the geometry and the geography versions of the type. I was similarly hoping for support for some SQL queries like ST_Intersects via esqueleto.

tysonzero commented 6 years ago

In the same vein Aeson instances would be super useful as well. I am happy to add all of this myself, I just am aware that there are tradeoffs and wanted maintainer approval first.

ewestern commented 6 years ago

Sorry for the delay! You know, I had thought earlier about about breaking this up into two libraries: An ogc-geometry-types that had, well, only the ogc geometry types, and another that had everything else. Then, creating and using an ogc-geometry-aeson, etc library alongside geos would be trivial.

Definitely interested in other thoughts about doing something like this.

As it stands, I'd prefer not to add any functionality here that isn't in the underlying library.

tysonzero commented 6 years ago

That would suffer from the usual issues orphan instances have.

With that said the one library I've seen do a decent job of this is data-default, so I would suggest imitating its structure.

geometry-types: Data.Geometry.Geos.Types
geometry-geos: Data.Geometry.Geos.*
geometry-aeson: Data.Geometry.Geos.Instances.Aeson
geometry: Data.Geometry.Geos

Where geometry:Data.Geometry.Geos re-exports basically everything from the other libraries, particularly the types and the instances. Replacing geometry with the name of your choice, ogc-geometry seems reasonable although it's not too clear to me exactly who defines which parts of this whole geometry/geography suite, from geos to postgis to wkt/wkb to geojson.

End users who want it batteries included will thus just use geometry:Data.Geometry.Geos and not have to deal with any orphan-related issues, and people more concerned with the dependencies they are pulling in can be more selective and handle any orphan related issues as they come up.