Hi,<br><br>I am having some troubles using DWithin when the passed-in distance is 0. My query should return all geometries that are within or within a given distance of a rectangle. DWithin works fine as long as the distance not equals 0. If so, no geometries are returned. If I choose a very small distance it works somehow.<br>
<br>select AsText(the_geom) from points where ST_DWithin(the_geom, ST_GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0);<br> astext <br>--------<br>(0 rows)<br><br>select AsText(the_geom) from points where ST_DWithin(the_geom, ST_GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0.000000000000000000000000000000000000000000000000000001);<br>
            astext             <br>-------------------------------<br> POINT(56.25 32.34375)<br> POINT(-45 47.8125)<br> POINT(-26.71875 -54.140625)<br> POINT(116.3671875 61.171875)<br> POINT(131.8359375 -21.796875)<br>(5 rows)<br>
<br><br>I am using version 1.3.3, so according to the manual [1] and this workshop [2], ST_DWithin is just translated into a combination of ST_Expand, && and ST_Distance. But if I make a query that looks like the definition of ST_DWithin, the points are returned.<br>
<br>select AsText(the_geom) from points <br>where <br>  the_geom && ST_Expand(GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326), 0) <br>AND <br>  GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326) && ST_Expand(the_geom, 0) <br>
AND <br>  ST_Distance(the_geom, GeomFromText('POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))', 4326)) <= 0;<br>            astext             <br>-------------------------------<br> POINT(56.25 32.34375)<br>
 POINT(-45 47.8125)<br> POINT(-26.71875 -54.140625)<br> POINT(116.3671875 61.171875)<br> POINT(131.8359375 -21.796875)<br>(5 rows)<br><br><br>Is this behaviour intented? <br><br>Thank you,<br>Tobias<br><br><br>[1]: <a href="http://www.postgis.org/documentation/manual-1.5/ST_DWithin.html">http://www.postgis.org/documentation/manual-1.5/ST_DWithin.html</a><br>
[2]: <a href="http://workshops.opengeo.org/postgis-spatialdbtips/click-analyze.html">http://workshops.opengeo.org/postgis-spatialdbtips/click-analyze.html</a><br>