我想使用postgresql找出一个点是否在圆圈内。 对于多边形内的点,我使用了以下查询。我也需要一些等效的圆圈查询。
SELECT a
FROM a_table
WHERE
ST_within(a::geometry,ST_GeomFromText('Polygon((50 -80.98 , 20.99 -90.99 , 90.98 -99.99 , 50 -80.98))'));
对于圈子,我尝试了以下查询:
SELECT a
FROM a_table
WHERE
ST_within(a::geometry,ST_GeomFromText('POINT(10 20)',10));
和
SELECT a
FROM a_table
WHERE
ST_within(a::geometry,ST_GeomFromText('circle((10 20),10)'));
但是这两个都给出了这样的错误:
ERROR: parse error - invalid geometry
SQL state: XX000
Hint: "714" <-- parse error at position 4 within geometry
和
ERROR: parse error - invalid geometry
SQL state: XX000
Hint: "ci" <-- parse error at position 2 within geometry
答案 0 :(得分:3)
select a
from a_table
where a <@ circle '((10, 20),10))';
select point '(1,1)' <@ circle '((0,0), 1)';
?column?
----------
f
select point '(1,1)' <@ circle '((0,0), 1.5)';
?column?
----------
t