[英]ST_WITHIN function does not exist
Im confused on how to use this function within my query.我对如何在查询中使用此功能感到困惑。 My code that I am using is as follows:
我正在使用的代码如下:
$res = pg_query($conn, 'SELECT "Coordinates" FROM "Shapes" WHERE st_within(point(0,0)::geometry, "Coordinates") ');
When I try run this I get this error:当我尝试运行它时,我收到此错误:
HINT: No function matches the given name and argument types.提示:没有函数匹配给定的名称和参数类型。 You might need to add explicit type casts.
您可能需要添加显式类型转换。
I want Coordinates to a polygon, so this may need to be an array of geometries我想要一个多边形的坐标,所以这可能需要是一个几何数组
ST_Within function takes two geometry parameters like this "ST_Within(geometry A, geometry B)". ST_Within 函数采用两个几何参数,例如“ST_Within(geometry A, geometry B)”。 You should make sure the parameters of "Coordinates" is actually geometry.
您应该确保“坐标”的参数实际上是几何图形。
I did some research and tried some different functions, with this I got different errors, one appeared as such:我做了一些研究并尝试了一些不同的功能,我得到了不同的错误,一个是这样的:
Warning : pg_query_params(): Query failed: ERROR: contains: Operation on mixed SRID geometries (Polygon, 4326) != (Point, 0) in
/var/www/html/watchlist/coordChange.php on line
45
警告:pg_query_params():查询失败:错误:包含:对混合 SRID 几何图形的操作(多边形,4326)!=(点,0)在第
45行的
/var/www/html/watchlist/coordChange.php
Using the following code:使用以下代码:
pg_query($conn, 'SELECT "Coordinates" FROM "Shapes" WHERE st_within( ST_MakePoint(130, -25), "Coordinates"::geometry) ');
From here I searched some more and used another function ST_SetSRID(), like so:从这里我搜索了更多并使用了另一个函数 ST_SetSRID(),如下所示:
pg_query($conn, 'SELECT "Coordinates" FROM "Shapes" WHERE st_within( ST_SetSRID( ST_MakePoint(130, -25), 4326), "Coordinates"::geometry) ');
This then produced the result I want.这然后产生了我想要的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.