[postgis-users] point in polygon using operator &&
David Blasby
dblasby at refractions.net
Tue May 20 12:05:21 PDT 2003
Rosangela Silva wrote:
> SELECT continent_name
>
> FROM continent
>
> WHERE the_geom && GeometryFromText('BOX3D(-45.69439 -23.5642,
> -45.69439 -23.5642)'::box3d,-1);
>
Use this:
SELECT continent_name
FROM continent
WHERE the_geom && GeometryFromText('BOX3D(-45.69439 -23.5642, -45.69439
-23.5642)'::box3d,-1);
AND distance(the_geom,GeometryFromText('POINT(-45.69439
-23.5642)',-1)) ==0;
The && uses the index and only works on the bounding box.
The distance function is much more accurate and works on the actual
geometries. NOTE: for points that are really-really-close to the edge
of your polygon, the distance function may be slightly off . It might
give 0 if the point is just outside the polygon, and it might give a
very small number if the point is just inside the polygon.
This problem will be solved very soon when GEOS is integrated into
postgis and you'll be able to use relate on the two geometries.
dave
More information about the postgis-users
mailing list