# [postgis] [Fwd: Points in circle alrogithm]

Dave Blasby dblasby at refractions.net
Thu Jul 12 14:23:50 PDT 2001

```Doug,

Thanks for the info on point-in-circle info.  I'm forwarding it to the
list because others might be interested in it and it might stir up some
discussion - hope you dont mind.

If the query point it at (Px,Py), and the maximum distance is d, you
could do something like this query;

select * from <table> where inside_circle(<geom col>, Px,Py,d);

Or, using the index;

select * from <table> where point_inside_circle(<geom col>,Px,Py,d) and
<geom col> && 'BOX3D(Px-d,Py-d  ,  Px+d, Py+d)'::BOX3D;

That means only the point_inside_circle(GOEMETRY,double,double,double)
function needs to be written.  Its a fairly simple function; just use

On the other hand, it would be better to have something a bit more
generic.  Ie.

select * from <table> where distance(<geom col>, 'POINT(Px,Py)')<d;

or, if we abstract a bit  and allow the 1st and 2nd argument to be any
type of geometry (instead of just points).

select * from <table> where distance(<geom col>, <test geom>) <d;

And, using the index;

select * from <table> where distance(<geom col>, <test geom>) <d and
<geom col> && expand_bbox(<test geom>,d);

Where expand_bbox(geometry, double) is a very simple function that takes
geometry's bbox and makes it 'bigger' in X and Y.

Here the distance(geometry A, geometry B) will find the minimum distance
between all the sub geometries in A and the sub geometries in B.  There
is an OpenGIS function for this, but I cannot find its name.

Unfortunately, distance(geometry, geometry) is difficult to write (but
extreamly useful).

I'm also trying to cut down the number of function (have few generic
functions instead of lots of specific functions) and stick to
OpenGIS-approved functions.

What do folk think?

dave
VeriSign's FREE Guide "Securing Your Web Site for Business." Get it now!
http://www.verisign.com/cgi-bin/go.cgi?a=n094442340008000
http://us.click.yahoo.com/6lIgYB/IWxCAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->

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/

-------------- next part --------------
An embedded message was scrubbed...
From: Doug Nebert <fgdc2a at attglobal.net>
Subject: Points in circle alrogithm
Date: Thu, 12 Jul 2001 16:42:08 -0400
Size: 2829
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20010712/d1310a6a/attachment.mht>
```