hasura/graphql-engine
在 GitHub 查看docs: document support for st_within or st_dwithin for polygons
Open
#3,015 创建于 2019年10月4日
a/data/postgresc/docshelp wanted
描述
I need to get the following query in PostgreSQL
SELECT count(*)
FROM geo_locations
WHERE ST_DWithin(coordinates, 'POLYGON((58.44773280389084 -19.335937500000004, 56.17002298293205 -14.765625000000002, 55.7765730186677 4.218750000000001, 54.36775852406841 9.492187500000002, 52.26815737376817 9.843750000000002, 45.089035564831036 3.5156250000000004, 42.293564192170095 8.085937500000002, 40.979898069620155 7.382812500000001, 41.244772343082076 3.5156250000000004, 52.482780222078226 -14.765625000000002, 57.89149735271034 -20.390625000000004, 60.75915950226991 -21.796875000000004, 58.44773280389084 -19.335937500000004))', 100)
or
SELECT count(*)
FROM geo_locations
WHERE ST_DWithin(coordinates, ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[58.44773280389084,-19.335937500000004],[56.17002298293205,-14.765625000000002],[55.7765730186677,4.218750000000001],[54.36775852406841,9.492187500000002],[52.26815737376817,9.843750000000002],[45.089035564831036,3.5156250000000004],[42.293564192170095,8.085937500000002],[40.979898069620155,7.382812500000001],[41.244772343082076,3.5156250000000004],[52.482780222078226,-14.765625000000002],[57.89149735271034,-20.390625000000004],[60.75915950226991,-21.796875000000004],[58.44773280389084,-19.335937500000004]]]}'), 100)
I'm trying to do it with
query ($polygon: st_d_within_input) {
geo_locations(where: {coordinates: {_cast: {geometry: {_st_d_within: $polygon}}}}) {
search_key
}
}
but it fails with
{
"errors": [
{
"extensions": {
"path": "$.variableValues.polygon",
"code": "validation-failed"
},
"message": "field distance of type Float! is required, but not found"
}
]
}