<html>
<head>
        <title></title>
        
<meta name="GENERATOR" content="MSHTML 8.00.6001.18854"></meta>
</head>

<body>Yes, sorry, I see I missunderstood you in my last answer.
        
<div align="left"> </div>
        
<div align="left">I was confused, because:</div>
        
<div align="left">Is the area-solution working at all. If there is many overlapping bbox-polygons in the table isn't that going to give a too big area. If I'm not still on wrong trac I guess you can easily get negative answers from your query.</div>
        
<div align="left"> </div>
        
<div align="left">and Martin, why is difference better here than CoveredBy or something like that to compare your unioned box with the query-polygon. Is difference a faster solution?</div>
        
<div align="left"> </div>
        
<div align="left">/Nicklas<br />
                <br />
                2010-01-18 Martin Davis wrote:<br />
                <br />
                The way I'd look at doing this is:<br />
                ><br />
                >- find all bounding boxes which intersect the query polygon<br />
                >- union the boxes<br />
                >- compute the difference between the box union and the query poly<br />
                >- If the difference is non-empty, the boxes do not cover the polygon.<br />
                ><br />
                >This should be a bit more accurate than simply using the areas. It could <br />
                >be more performance as well, given the new fast-union functions.<br />
                ><br />
                >Nicolas Gillet - MARKET-IP wrote:<br />
                >><br />
                >> Hello,<br />
                >><br />
                >> I am looking for some help in optimizing a query.<br />
                >><br />
                >> I have a table with bounding boxes and sometimes I need to find if a <br />
                >> new given polygon can be fully covered by existing bounding boxes of <br />
                >> my table.<br />
                >><br />
                >> Right now I can find it out by summing the areas of intersections <br />
                >> between my polygon and those in my table and comparing this computed <br />
                >> area with my polygon area.<br />
                >><br />
                >> Here’s the query :<br />
                >><br />
                >> SELECT ST_area(ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 <br />
                >> 0))', 4326) ) -<br />
                >><br />
                >> (SELECT SUM(st_area(st_intersection(the_geom, <br />
                >> ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) ) ))<br />
                >><br />
                >> FROM tests WHERE the_geom && ST_GeometryFromText('POLYGON((-1 0, -1 1, <br />
                >> 1 1, 1 0, -1 0))', 4326) )<br />
                >><br />
                >> => if query returns 0 then my polygon can be fully covered if != 0 <br />
                >> then it can’t.<br />
                >><br />
                >> But I was wondering if there couldn’t be an easier way to do this.<br />
                >><br />
                >> Thank you.<br />
                >><br />
                >> Nicolas.<br />
                >><br />
                >> ------------------------------------------------------------------------<br />
                >><br />
                >> _______________________________________________<br />
                >> postgis-users mailing list<br />
                >> postgis-users@postgis.refractions.net<br />
                >> http://postgis.refractions.net/mailman/listinfo/postgis-users<br />
                >> <br />
                ><br />
                >-- <br />
                >Martin Davis<br />
                >Senior Technical Architect<br />
                >Refractions Research, Inc.<br />
                >(250) 383-3022<br />
                ><br />
                >_______________________________________________<br />
                >postgis-users mailing list<br />
                >postgis-users@postgis.refractions.net<br />
                >http://postgis.refractions.net/mailman/listinfo/postgis-users<br />
                ><br />
                ></div>
</body>
</html>