[postgis] Point within circle

Dave Blasby dblasby at refractions.net
Wed Jul 18 15:08:34 PDT 2001

Due to Doug's request, I've added a new postgis function;

point_inside_circle(geometry, Px, Py, d)
	- returns true if there is a point in geometry whose distance to
(Px,Py) is < d

For example for the table,

t2=# select * from ttt;
 POINT(10 10)
 POINT(10 0)
(2 rows)

You get these results;

t2=# select point_inside_circle(the_geom,10,10,0.1) from ttt;
(2 rows)

You can also do a more optimized search (see below).  This will first do
an index search to find all the points that are inside the BOX3D (dont
forget to build your GIST index first).  The geometries that pass this
are then put through point_inside_circle(the_geom,0,0,11).

select * from <table> where point_inside_circle(<geom column
name>,0,0,10) and <geom column name> && 'BOX3D(-10 -10,10 10)'::BOX3D;

Obviously, the BOX3D is BOX3D(Px-d   Py-d    ,   Px+d   Py+d)

ps. We're currently getting ready to release PostGIS 0.5.  This function
will be in that release.

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Secure your servers with 128-bit SSL encryption! Grab your copy of
VeriSign's FREE Guide "Securing Your Web Site for Business." Get it now!

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the postgis-users mailing list