[postgis-users] Calculate maximum bounding extent of selectedfeatures
Aaron Racicot
aaronr at ecotrust.org
Tue Feb 14 12:44:08 PST 2006
Hi there Jennifer,
I think you can use the extent() postgis function, which is an aggregate
function, to gather the bounding box info from a set of geometries. Can
you try something like:
$szSQLBbox = 'extent(the_geom) from ('.$szTableSQL.')';
>From there you will have to parse the output from the SQL, but with PHP
that should be easy. Let me know if you need help there.
In my own database I was able to do the following:
shelf_closure_db=# select extent(the_geom) from cablk3km;
extent
------------------------------------
BOX(-483395 -630789,272939 455479)
(1 row)
shelf_closure_db=#
Hope this gets you going!
Aaron
+----------------------------------------+
| Aaron Racicot | aaronr at ecotrust.org |
| GIS Programmer | 503.467.0759 |
+----------------------------------------+
| e c o t r u s t |
| Jean Vollum Natural Capital Center |
| 721 NW Ninth Avenue |
| Suite 200 |
| Portland, OR 97209 |
| www.ecotrust.org |
+----------------------------------------+
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Jennifer Shanks
Sent: Tuesday, February 14, 2006 11:49 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Calculate maximum bounding extent of
selectedfeatures
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
_______________________________________________
postgis-users mailing list postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list