Search Postgresql Archives

Re: Detecting whether a point is in a box.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HST <helenst@xxxxxxxxx> writes:
> I am trying to write a query to find all points that fall within a
> given box. However, I cannot seem to find the functionality for
> determining whether a point is within a box.

> e.g.  select box '((0,0),(1,1))' @> point '(0.5,0.5)';

> operator does not exist: box @> point

psql's \do shows that we have box @> box and polygon @> point,
but no box @> point.  So one possibility is to change your
box data to polygons.  Another is to manufacture a zero-area
box from the point, using the box(point,point) function, and
use @> with that.  Also, there is a point <@ box, although
I'm not sure you want to use that --- the lack of a commutator
suggests that it probably hasn't got any index support.

Is this just for a one-shot query, or are you hoping to do
indexed searches in a big table?  If the latter, which object
is being stored in the table?  You want to be sure you can
create an index that will support the operator you use.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux