<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>AW: AW: [postgis-users] Overlaps query</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Thanks, that works even better. The execution time reduced to 17946 ms.</FONT>
</P>

<P><FONT SIZE=2>Bye,</FONT>
<BR><FONT SIZE=2>Thorsten</FONT>
</P>

<P><FONT SIZE=2>-----Ursprüngliche Nachricht-----</FONT>
<BR><FONT SIZE=2>Von: postgis-users-bounces@postgis.refractions.net</FONT>
<BR><FONT SIZE=2>[<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>]</FONT>
<BR><FONT SIZE=2>Gesendet: Freitag, 25. Mai 2007 10:14</FONT>
<BR><FONT SIZE=2>An: PostGIS Users Discussion</FONT>
<BR><FONT SIZE=2>Betreff: Re: AW: [postgis-users] Overlaps query</FONT>
</P>
<BR>

<P><FONT SIZE=2>Thorsten Kraus wrote:</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Thanks for your answer. I have tried this before.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> SELECT COUNT(a.id) FROM tbl1 a, tbl1 b WHERE a.geom && b.geom and a.id </FONT>
<BR><FONT SIZE=2>> <> b.id</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> But the result differs from my other query. Regarding to the PostGIS </FONT>
<BR><FONT SIZE=2>> doc at <A HREF="http://postgis.refractions.net/docs/ch06.html" TARGET="_blank">http://postgis.refractions.net/docs/ch06.html</A> the && operator </FONT>
<BR><FONT SIZE=2>> does not check the spatial overlap of two geometries, it checks if the </FONT>
<BR><FONT SIZE=2>> bounding boxes of thw geometries overlap. But in my case I need to </FONT>
<BR><FONT SIZE=2>> check if two geometries spatially overlap. Perhaps there is a </FONT>
<BR><FONT SIZE=2>> possibility to make this faster in some way.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>Try combing the two together - Postgis can use the spatial index to find </FONT>
<BR><FONT SIZE=2>the overlapping bounding boxes, then use the overlaps function to do an </FONT>
<BR><FONT SIZE=2>exact check.</FONT>
</P>

<P><FONT SIZE=2>SELECT COUNT(a.id)</FONT>
<BR><FONT SIZE=2>FROM tbl1 a, tbl1 b</FONT>
<BR><FONT SIZE=2>WHERE a.geom && b.geom</FONT>
<BR><FONT SIZE=2>    AND a.id <> b.id</FONT>
<BR><FONT SIZE=2>    AND OVERLAPS(a.geom, b.geom)</FONT>
</P>

<P><FONT SIZE=2>Rob :)</FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>One Track Mind Ltd.</FONT>
<BR><FONT SIZE=2>PO Box 1604, Shortland St, Auckland, New Zealand</FONT>
<BR><FONT SIZE=2>Phone +64-9-966 0433 Mobile +64-21-572 632</FONT>
<BR><FONT SIZE=2>Web <A HREF="http://www.onetrackmind.co.nz" TARGET="_blank">http://www.onetrackmind.co.nz</A> </FONT>
</P>
<BR>

<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>postgis-users mailing list</FONT>
<BR><FONT SIZE=2>postgis-users@postgis.refractions.net</FONT>
<BR><FONT SIZE=2><A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users" TARGET="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</A></FONT>
</P>

</BODY>
</HTML>