[postgis-users] Calculate maximum bounding extent of selected features

Jennifer Shanks jennifer at greeninfo.org
Tue Feb 14 11:48:46 PST 2006


Hello,

I am a new PostGIS and and Mapserver user and could use some guidance.

I'm attempting to customize a query tool written in PHP/Mapscript 
that selects features from a PostGIS database and highlights them on 
the map.  I'd like to also zoom to the maximum bounding extents of 
the selected features.  I can zoom the map object using the below code:

$xmin= "531016";
$ymin= "4164561";
$xmax= "575400";
$ymax= "4199817";

$oMap->setExtent($xmin, $ymin, $xmax, $ymax);

Now, I need to figure out how to get the maximum bounding coordinates 
of the selected feature set from PostGIS.  Below is the SQL that is 
used to select features.  Does anyone know how I can get the bounding 
coordinates?  Would I use an SQL statement?  Are there any examples 
using PHP/Mapscript?  Any suggestions or hints would be much appreciated.

Regards,
Jennifer

// build SQL(s)
     $szTableSQL = 'select * from '.$_REQUEST['result_geom'].
         ' where intersects(the_geom,(select the_geom as my_geom from '.
         $_REQUEST['bound_geom'].' where LOWER('.$_REQUEST['bound_field'].
         ')=LOWER(\''.
         $_REQUEST['bound_value'].'\')))';

     $szSQL = 'the_geom from ('.$szTableSQL.') as foo using unique 
gid using srid=-1';



****************************
Jennifer Shanks
GreenInfo Network
116 New Montgomery, Suite 738
San Francisco, CA 94105
(415) 979-0343 x 306
(415) 979-0371 FAX
**GreenInfo has completely re-done our web site
Go to: www.greeninfo.org






More information about the postgis-users mailing list