postgres-error: function st_intersects(geography, geography, integer) does not exist
postgres-error: function st_intersects(geography, geography, integer) does not exist
我有一个带有 postGIS 位置列的 table business_locations
,我尝试获取边界框内的行(函数参数)。
我正在尝试 运行 Hasura 中的这个功能:
CREATE OR REPLACE FUNCTION search_businesses_near_project(lngW integer, latS integer, lngE integer, latN integer)
RETURNS SETOF business_locations AS $$
SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id
FROM business_locations A where ST_Intersects(A.location::geography, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)
$$ LANGUAGE sql STABLE;
返回的错误:
{
"internal": {
"statement": "CREATE OR REPLACE FUNCTION search_businesses_near_project(project_location geography, lngW integer, latS integer, lngE integer, latN integer)\r\nRETURNS SETOF business_locations AS $$\r\n SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id\r\n FROM business_locations A where ST_Intersects(project_location, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)\r\n$$ LANGUAGE sql STABLE;",
"prepared": false,
"error": {
"exec_status": "FatalError",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"message": "function st_intersects(geography, geography, integer) does not exist",
"status_code": "42883",
"description": null
},
"arguments": []
},
"path": "$.args[0].args",
"error": "query execution failed",
"code": "postgres-error"
}
st_intersects
只接受两个参数。省略多余的 SRID:
CREATE OR REPLACE FUNCTION search_businesses_near_project(
lngW integer,
latS integer,
lngE integer,
latN integer
) RETURNS SETOF business_locations AS $$
SELECT *
FROM business_locations A
WHERE st_intersects(
A.location::geography,
ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography
)
$$ LANGUAGE sql STABLE;
我有一个带有 postGIS 位置列的 table business_locations
,我尝试获取边界框内的行(函数参数)。
我正在尝试 运行 Hasura 中的这个功能:
CREATE OR REPLACE FUNCTION search_businesses_near_project(lngW integer, latS integer, lngE integer, latN integer)
RETURNS SETOF business_locations AS $$
SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id
FROM business_locations A where ST_Intersects(A.location::geography, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)
$$ LANGUAGE sql STABLE;
返回的错误:
{
"internal": {
"statement": "CREATE OR REPLACE FUNCTION search_businesses_near_project(project_location geography, lngW integer, latS integer, lngE integer, latN integer)\r\nRETURNS SETOF business_locations AS $$\r\n SELECT A.location, A.route, A.locality, A.administrative_area_level_1, A.administrative_area_level_2, A.country, A.business_id\r\n FROM business_locations A where ST_Intersects(project_location, ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography, 4326)\r\n$$ LANGUAGE sql STABLE;",
"prepared": false,
"error": {
"exec_status": "FatalError",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"message": "function st_intersects(geography, geography, integer) does not exist",
"status_code": "42883",
"description": null
},
"arguments": []
},
"path": "$.args[0].args",
"error": "query execution failed",
"code": "postgres-error"
}
st_intersects
只接受两个参数。省略多余的 SRID:
CREATE OR REPLACE FUNCTION search_businesses_near_project(
lngW integer,
latS integer,
lngE integer,
latN integer
) RETURNS SETOF business_locations AS $$
SELECT *
FROM business_locations A
WHERE st_intersects(
A.location::geography,
ST_MakeEnvelope(lngW, latS, lngE, latN, 4326)::geography
)
$$ LANGUAGE sql STABLE;