[postgis-users] Problem with the overlap operator && (?)

Paul Ramsey pramsey at refractions.net
Tue Nov 14 21:07:41 PST 2006

Greg is right, the issue is that Overlaps() tests geometry overlap  
while && tests bounding box overlap, and the two are only the same if  
both objects are boxes. :)

But "why test bounding box overlaps???" you ask.  Because that is an  
indexable relationship, while the strict test is not.  So you use the  
two in combination.  The && operator returns a superset of the  
eventual result, which you winnow using an exact function.

The core trick of fast spatial database operations is to use the  
bounding box relation to return a superset and then filter than  
superset with an exact test.


On 14-Nov-06, at 8:40 PM, Gregory S. Williamson wrote:

> Rob,
> Without examples of the data involved, it's hard to say for sure,  
> but offhand perhaps the && operator, which uses bounding boxes  
> only, does find that the 2nd object's BB overlaps the first  
> object's BB, but the stricter (and slower, non-index using,  
> "overlaps" function) is correctly seeing that they do not really  
> overlap. Think of a "C" shape with a much smaller circle in the  
> open area in the middle ... or a shape that has a long diagonal, so  
> the bounding box embraces a large are compared to the actual area  
> of the shape.
> If you can reduce this to a simple case and show the geometries I  
> am sure that smarter heads than mine could chime in.
> Greg Williamson
> GlobeXplorer LLC
> -----Original Message-----
> From:	postgis-users-bounces at postgis.refractions.net on behalf of  
> Rob Tester
> Sent:	Tue 11/14/2006 8:21 PM
> To:	postgis-users at postgis.refractions.net
> Cc:	
> Subject:	[postgis-users] Problem with the overlap operator && (?)
> I recently (with my install of 1.1.5) have run into something that is
> puzzling me about the overlaps operator. I have two tables that I am
> comparing the geometry objects using the following SQL:
> select overlaps 
> (a.wkb_geometry,b.wkb_geometry),a.primaryKey,b.primaryKey
> from az_cr9 a,az_kz b where a.primaryKey=2203 and  
> b.primaryKey=293546 and
> a.wkb_geometry&&b.wkb_geometry
> This returns one row:
> f;2203;293546
> My question is how does the overlaps operator return TRUE and the  
> overlaps
> function return FALSE. In fact the two geometries in question do  
> not close
> to each other. Is this operator broken?
> This query returns no rows as expected:
> select
> overlaps 
> (a.wkb_geometry,b.wkb_geometry),a.cr_id,b.ogc_fid,b.blockgroupid,
> b.blockid
> from az_carrierroute9 a,az_kz_calculated_test b where  
> a.ogc_fid=2203 and
> b.ogc_fid=293546 and overlaps(a.wkb_geometry,b.wkb_geometry)
> Any help on this?
> Rob
> -------------------------------------------------------
> Click link below if it is SPAM gsw at globexplorer.com
> "https://mailscanner.globexplorer.com/dspam/dspam.cgi? 
> signatureID=455a9686171332117817174&user=gsw at globexplorer.com&retrain= 
> spam&template=history&history_page=1"
> !DSPAM:455a9686171332117817174!
> -------------------------------------------------------
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

More information about the postgis-users mailing list