[postgis-users] Differences between "&&" and Intersects

Jeremy Nix Jeremy.Nix at sfsltd.com
Tue Mar 21 08:30:08 PST 2006


I'm new to PostGIS (and postgresql for that point), so I apologize if
I'm missing something fundamental.  I've created a GIS table containing
a geometry column.  I've also created a spatial index on this column.
I'm now attempting to query the table based on a point.  I have 2
different queries below.
 
Query 1) (longitude, latitude, and bufferInFeet are inputs)
    geom geometry;
    geom := Buffer(MakePoint(longitude, latitude),
bufferInFeet/364560.0)
    SELECT polyattributes, poly
    FROM polygons
    WHERE poly && geom
 
Query 2) (longitude, latitude, and bufferInFeet are inputs)
    geom geometry;
    geom := Buffer(MakePoint(longitude, latitude),
bufferInFeet/364560.0)
    SELECT polyattributes, poly
    FROM polygons
    WHERE poly && geom AND Intersects(poly, geom)
 
These queries return different results in particular cases that I was
testing.  My question is why.  I assumed that the "&&" operator that is
used with the spatial index performed some sort of intersects function
with the bounding box (geom in this case).  If that is the case, then
these queries would be functionally equivalent.  But, in my tests, I
found that when I used Query 1, more results were returned than when I
used Query 2.  Can somebody tell me why this is?
 
Thanks in advance for any help.
 
________________________________
Jeremy Nix
Senior Application Developer
Southwest Financial Services, Ltd.
http://www.sfsltd.com <http://www.sfsltd.com/> 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060321/6ed20c51/attachment.html>


More information about the postgis-users mailing list