<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Ok, Dave, It's works.</FONT></DIV>
<DIV><FONT face=Arial size=2>Only a comment is change "=" for "==" and
</FONT></DIV>
<DIV><FONT face=Arial size=2>...where the_geom <SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">&&
GeometryFromText('POINT(-45.69439 -23.5642)',-1) that works
too.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></FONT><FONT
face=Arial size=2><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2>Rosāngela</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">Use this:<BR><BR>SELECT
continent_name<BR><BR>FROM continent<BR><BR>WHERE the_geom &&
GeometryFromText('BOX3D(-45.69439 -23.5642, -45.69439
<BR>-23.5642)'::box3d,-1);<BR><BR> AND
distance(the_geom,GeometryFromText('POINT(-45.69439 <BR>-23.5642)',-1))
==0;<BR><BR><BR>The && uses the index and only works on the bounding
box. <BR>The distance function is much more accurate and works on the
actual <BR>geometries. NOTE: for points that are really-really-close to
the edge <BR>of your polygon, the distance function may be slightly off
. It might <BR>give 0 if the point is just outside the polygon, and it
might give a <BR>very small number if the point is just inside the
polygon. <BR><BR><BR>This problem will be solved very soon when GEOS is
integrated into <BR>postgis and you'll be able to use relate on the two
geometries.<BR><BR>dave<BR></DIV>
<DIV style="FONT: 10pt arial"> </DIV>
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=rosangela.silva@zenitpolar.com.br
href="mailto:rosangela.silva@zenitpolar.com.br">Rosangela Silva</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=postgis-users@postgis.refractions.net
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, May 20, 2003 3:53 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> point in polygon using operator
&&</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Hello all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm trying to use the operator && to find
the polygon</FONT></DIV>
<DIV><FONT face=Arial size=2>that contains a point. (Are there other way
to do this in PostGIS?)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>So, I create the select below: </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">SELECT continent_name </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">FROM continent </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">WHERE the_geom &&
GeometryFromText('BOX3D(-45.69439 -23.5642, -45.69439 -23.5642)'::box3d,-1);
<o:p></o:p></P></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>How the point doesn't have a box, I repeat the
same coordinates.</FONT></DIV>
<DIV><FONT face=Arial size=2>The continent is the world continent
table.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The result was: South America,
Oceania.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I became surprise by Oceania and I saw that
Oceania is a multpolygon geometry.</FONT></DIV>
<DIV><FONT face=Arial size=2>When the PostGIS generate the box of Oceania
polygons, the result are the box resultant</FONT></DIV>
<DIV><FONT face=Arial size=2>of all box isolated polygons. By this, my point
is in Oceania too.</FONT></DIV>
<DIV><FONT face=Arial size=2>See the select bellow:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>gisdb=# select continent, box3D(the_geom) from
continent where continent='Oceania';<BR> continent
|
box3d<BR>---------------+--------------------------------------------------------<BR> Oceania
| BOX3D(-180 -52.5780563354492 0,180 28.2215194702148 0)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In another case, but in this case I
didn't understand why, the result get 2 polygons having the</FONT></DIV>
<DIV><FONT face=Arial size=2>same point, but this point ins't in the border of
two polygons (I visually have shure!). </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>gisdb=# SELECT nomemunicp, uf FROM brmuni WHERE
the_geom && GeometryFromText<BR>('BOX3D(-45.69439 -23.5642, -45.69439
-23.5642)'::box3d,-1);<BR> nomemunicp |
uf<BR>-----------------------+----<BR> PARAIBUNA
| SP<BR> CARAGUATATUBA | SP</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2>Rosāngela</FONT></DIV></BLOCKQUOTE></BODY></HTML>