-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
PostGIS Geometry / Geography Filter Support #532
Comments
We would like to add first party support for PostGIS and pgvector as they're the most popular extensions on the platform. pgvector will probably go first because its a lot smaller in scope and that should give us an idea of how best to implement PostGIS Going to leave this open |
Awesome, glad to hear that! Probably more relevant for a separate issue, but what are the current plans (if any) for implementing (Also, thanks for all the hard work that went into making this super cool postgres extension!) |
To help with any future development that may go into supporting PostGIS, I added these lines of SQL to enable sending
|
@olirice: I'm very interested in this. Is this on the official road map yet? I'm curious if it's beyond reasonable complexity for a first-time contributor. |
It depends on how complex the type you want to implement is Here's an example of how citext was special cased so that it would be preresented as you could imagine doing the same thing for pgvector's Types with nested data could be more complex |
Summary
The postgres postgis extension introduces
geometry
andgeography
column types with large set of new query operators. Generally, these column types serialize and deserialize successfully into geojson as per my experimental branch here, where I was exploring the use of postgis in conjunction with pg_graphql. To truly make these column types useful with pg_graphql, however, the various query operators capable of filtering rows based ongeometry
orgeography
must be introduced into the available pg_graphql filter types.Rationale
Without additional filter support for
geometry
andgeography
types, pg_graphql is only minimally useful for any database that needs to store geographic or geometric information.Design
I believe one of two design approaches would suffice to introduce better filters for postgis.
json
andjsonb
.geography
andgeometry
types to pg_graphql. This would allow other pg_graphql app developers to activate the postgis extension with minimal effort.Examples
Postgis supports all of the following sql operators: https://postgis.net/docs/manual-1.5/ch08.html
For filtering, I have found the most common operators to be (from geoalchemy2):
INTERSECTS ("&&")
INTERSECTS_ND ("&&&")
OVERLAPS_OR_TO_LEFT ("&<")
OVERLAPS_OR_TO_RIGHT ("&>")
OVERLAPS_OR_BELOW ("&<|")
TO_LEFT ("<<")
BELOW ("<<|")
TO_RIGHT (">>")
CONTAINED ("@")
OVERLAPS_OR_ABOVE ("|&>")
ABOVE ("|>>")
CONTAINS ("~")
SAME ("~=")
DISTANCE_CENTROID ("<->")
DISTANCE_BOX ("<#>")
Where the item on either side of the comparator can be a
geometry
,geography
, ortext
value that casts to geometry. (One side being the column of the table being filtered, and the other side being the value passed into graphql as the filter value)Drawbacks
Unknown.
Alternatives
None available.
Unresolved Questions
TBD.
The text was updated successfully, but these errors were encountered: