<html>
<head>
<title></title>
<meta name="GENERATOR" content="MSHTML 8.00.6001.18854"></meta>
</head>
<body>
<div align="left">Hallo </div>
<div align="left"> </div>
<div align="left">look at </div>
<div align="left"> </div>
<div align="left">ST_CoveredBy, ST_Covered, ST_Contain and ST_ContainProperly</div>
<div align="left">in doc</div>
<div align="left"><a href="http://www.postgis.org/documentation/manual-1.4/">http://www.postgis.org/documentation/manual-1.4/</a></div>
<div align="left"><br />
They all handle this questions in slightly different ways.</div>
<div align="left">I think all of them will use any potential index, but look in doc to be sure.</div>
<div align="left"> </div>
<div align="left"> </div>
<div align="left">Hope that helps</div>
<div align="left">Nicklas</div>
<div align="left"> </div>
<div align="left"><br />
2010-01-18 Nicolas Gillet - MARKET-IP wrote:<br />
<br />
></div>
<p>Hello,</p>
<p> </p>
<p> </p>
<p> </p>
<p>I am looking for some help in optimizing a query.</p>
<p> </p>
<p> </p>
<p> </p>
<p>I have a table with bounding boxes and sometimes I need to find if a new given polygon can be fully covered by existing bounding boxes of my table.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Right now I can find it out by summing the areas of intersections between my polygon and those in my table and comparing this computed area with my polygon area.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Heres the query :</p>
<p> </p>
<p> </p>
<p> </p>
<p>SELECT ST_area(ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) ) -</p>
<p> </p>
<p>(SELECT SUM(st_area(st_intersection(the_geom, ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) ) ))</p>
<p> </p>
<p> FROM tests WHERE the_geom && ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) )</p>
<p> </p>
<p> </p>
<p> </p>
<p>=> if query returns 0 then my polygon can be fully covered if != 0 then it cant.</p>
<p> </p>
<p> </p>
<p> </p>
<p>But I was wondering if there couldnt be an easier way to do this.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Thank you.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Nicolas.</p>
<p> </p>
</body>
</html>