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 ST_DWithin Filter #16

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: ireznik/postgis-action@master
with:
postgresql version: "12-master"
postgresql password: "123"
postgresql user: "postgres"
postgresql db: "test"
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Run tests
run: yarn test
env:
TEST_DATABASE_URL: "postgres://postgres:123@localhost:5432/test"
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Package on npm](https://img.shields.io/npm/v/postgraphile-plugin-connection-filter-postgis.svg)](https://www.npmjs.com/package/postgraphile-plugin-connection-filter-postgis) [![CircleCI](https://circleci.com/gh/graphile-contrib/postgraphile-plugin-connection-filter-postgis.svg?style=svg)](https://circleci.com/gh/graphile-contrib/postgraphile-plugin-connection-filter-postgis)

# postgraphile-plugin-connection-filter-postgis

This plugin exposes additional PostGIS-related fields on the `filter` argument of Connections.

## Usage
Expand All @@ -12,37 +13,38 @@ Requires `postgraphile@^4.5.0` and the following plugins appended prior to this

## Operators

| PostGIS function | Types | GraphQL field name |
| --- | --- | --- |
| ST_3DIntersects | geometry | intersects3D |
| ST_Contains | geometry | contains |
| ST_ContainsProperly | geometry | containsProperly |
| ST_CoveredBy | geometry, geography | coveredBy |
| ST_Covers | geometry, geography | covers |
| ST_Crosses | geometry | crosses |
| ST_Disjoint | geometry | disjoint |
| ST_Equals | geometry | equals |
| ST_Intersects | geometry, geography | intersects |
| ST_OrderingEquals | geometry | orderingEquals |
| ST_Overlaps | geometry | overlaps |
| ST_Touches | geometry | touches |
| ST_Within | geometry | within |

| PostGIS operator | Types | GraphQL field name |
| --- | --- | --- |
| = | geometry, geography | exactlyEquals |
| && | geometry, geography | bboxIntersects2D |
| &&& | geometry | bboxIntersectsND |
| &< | geometry | bboxOverlapsOrLeftOf |
| &<\| | geometry | bboxOverlapsOrBelow |
| &> | geometry | bboxOverlapsOrRightOf |
| \|&> | geometry | bboxOverlapsOrAbove |
| << | geometry | bboxLeftOf |
| <<\| | geometry | bboxBelow |
| >> | geometry | bboxRightOf |
| \|>> | geometry | bboxAbove |
| ~ | geometry | bboxContains |
| ~= | geometry | bboxEquals |
| PostGIS function | Types | GraphQL field name |
| ------------------- | ------------------- | ------------------ |
| ST_3DIntersects | geometry | intersects3D |
| ST_Contains | geometry | contains |
| ST_ContainsProperly | geometry | containsProperly |
| ST_CoveredBy | geometry, geography | coveredBy |
| ST_Covers | geometry, geography | covers |
| ST_Crosses | geometry | crosses |
| ST_Disjoint | geometry | disjoint |
| ST_Equals | geometry | equals |
| ST_Intersects | geometry, geography | intersects |
| ST_OrderingEquals | geometry | orderingEquals |
| ST_Overlaps | geometry | overlaps |
| ST_Touches | geometry | touches |
| ST_Within | geometry | within |
| ST_DWithin |

| PostGIS operator | Types | GraphQL field name |
| ---------------- | ------------------- | ---------------------- |
| = | geometry, geography | exactlyEquals |
| && | geometry, geography | bboxIntersects2D |
| &&& | geometry | bboxIntersectsND |
| &< | geometry | bboxOverlapsOrLeftOf |
| &<\| | geometry | bboxOverlapsOrBelow |
| &> | geometry | bboxOverlapsOrRightOf |
| \|&> | geometry | bboxOverlapsOrAbove |
| << | geometry | bboxLeftOf |
| <<\| | geometry | bboxBelow |
| >> | geometry | bboxRightOf |
| \|>> | geometry | bboxAbove |
| ~ | geometry | bboxContains |
| ~= | geometry | bboxEquals |

## Development

Expand Down
17 changes: 17 additions & 0 deletions __tests__/fixtures/queries/geography.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,118 +7,135 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogGeometry: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogPoint: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogLinestr: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogPoly: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultipoint: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultilinestr: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultipoly: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogGeometrycollection: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogGeometrym: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogPointm: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogLinestrm: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogPolym: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultipointm: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultilinestrm: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogMultipolym: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
geogGeometrycollectionm: {
coveredBy: $point
covers: $point
intersects: $point
exactlyEquals: $point
bboxIntersects2D: $point
dwithin: $point
}
}
) {
Expand Down
19 changes: 18 additions & 1 deletion __tests__/fixtures/queries/geometry.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }, $radius: Float = 250 ) {
allGisDebugs(
filter: {
geom: {
Expand Down Expand Up @@ -28,6 +28,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomGeometry: {
intersects3D: $point
Expand Down Expand Up @@ -56,6 +57,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomPoint: {
intersects3D: $point
Expand Down Expand Up @@ -84,6 +86,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomLinestr: {
intersects3D: $point
Expand Down Expand Up @@ -112,6 +115,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomPoly: {
intersects3D: $point
Expand Down Expand Up @@ -140,6 +144,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultipoint: {
intersects3D: $point
Expand Down Expand Up @@ -168,6 +173,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultilinestr: {
intersects3D: $point
Expand Down Expand Up @@ -196,6 +202,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultipoly: {
intersects3D: $point
Expand Down Expand Up @@ -224,6 +231,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomGeometrycollection: {
intersects3D: $point
Expand Down Expand Up @@ -252,6 +260,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomGeometrym: {
intersects3D: $point
Expand Down Expand Up @@ -280,6 +289,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomPointm: {
intersects3D: $point
Expand Down Expand Up @@ -308,6 +318,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomLinestrm: {
intersects3D: $point
Expand Down Expand Up @@ -336,6 +347,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomPolym: {
intersects3D: $point
Expand Down Expand Up @@ -364,6 +376,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultipointm: {
intersects3D: $point
Expand Down Expand Up @@ -392,6 +405,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultilinestrm: {
intersects3D: $point
Expand Down Expand Up @@ -420,6 +434,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomMultipolym: {
intersects3D: $point
Expand Down Expand Up @@ -448,6 +463,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
geomGeometrycollectionm: {
intersects3D: $point
Expand Down Expand Up @@ -476,6 +492,7 @@ query AllGisDebugs($point: GeoJSON = { type: "Point", coordinates: [30, 10] }) {
bboxAbove: $point
bboxContains: $point
bboxEquals: $point
dwithin: $point, $radius
}
}
) {
Expand Down
Loading