Reputation: 57
I want to find out whether a point is within the circle or not using postgresql. For point within polygon, I have used following query. i need some equivalent query for circle too.
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))'));
for circle, i tried this below query :
SELECT a
FROM a_table
WHERE
ST_within(a::geometry,ST_GeomFromText('POINT(10 20)',10));
and
SELECT a
FROM a_table
WHERE
ST_within(a::geometry,ST_GeomFromText('circle((10 20),10)'));
but both of these gives errors like this :
ERROR: parse error - invalid geometry
SQL state: XX000
Hint: "714" <-- parse error at position 4 within geometry
and
ERROR: parse error - invalid geometry
SQL state: XX000
Hint: "ci" <-- parse error at position 2 within geometry
Upvotes: 1
Views: 4351
Reputation: 125204
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
Upvotes: 4