[Mapserver-users] PostGIS Spatial Query - Completely Within

Benjamin Wragg bwragg at tpg.com.au
Fri May 30 04:10:27 EDT 2003


This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C326D2.900D3C40
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi All,
 
I'm currently writing an application with PHP/MapScript which needs two
different types of spatial querying. I currently have one of them going
fine. I select a polygon like a country and search for all other
polygons in another layer that intersect or fall within the country
selected. I use the following sql in my where clause:
 
country.the_geom && otherpolygon.the_geom AND distance(country.the_geom,
otherpolygon.the_geom)=0
 
What I need to do now is alter this query slightly and only find
polygons that are completely within the country selected. So if I
selected the US as the country and in the otherpolygons layer there are
two polygons one covering Texas and one covering the entire earth eg
(180,90,-180,-90) I would only get Texas back. I've look throught the
PostGIS docs and can't find any functions that seem to fit. Is there any
PostGIS functions that I can use to accomplish this?
 
Thanks,
 
Benjamin Wragg

------=_NextPart_000_0001_01C326D2.900D3C40
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial size=3D2>Hi=20
All,</FONT></SPAN></DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial size=3D2>I'm =
currently=20
writing an application with PHP/MapScript which needs two different =
types of=20
spatial querying. I currently have one of them going fine. I select a =
polygon=20
like a country and search for all other polygons in another layer that =
intersect=20
or fall within the country selected. I use the following sql in my where =

clause:</FONT></SPAN></DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial =
size=3D2>country.the_geom=20
&amp;&amp; otherpolygon.the_geom AND distance(country.the_geom,=20
otherpolygon.the_geom)=3D0</FONT></SPAN></DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial size=3D2>What I =
need to do=20
now is alter this query slightly and only find polygons that are =
completely=20
within the country selected. So if I selected the US as the country and =
in the=20
otherpolygons layer there are two polygons one covering Texas and one =
covering=20
the entire earth eg (180,90,-180,-90) I would only get Texas back. I've =
look=20
throught the PostGIS docs and can't find any functions that seem to fit. =
Is=20
there any PostGIS functions that I can use to accomplish=20
this?</FONT></SPAN></DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial =
size=3D2></FONT></SPAN><SPAN=20
class=3D375393207-30052003><FONT face=3DArial =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial=20
size=3D2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D375393207-30052003><FONT face=3DArial =
size=3D2>Benjamin=20
Wragg</FONT></SPAN></DIV></BODY></HTML>

------=_NextPart_000_0001_01C326D2.900D3C40--




More information about the mapserver-users mailing list