thanks armin.<br><br>it seems that what you suggested is the only way to get the correct extents for non-standard layers. i suppose one could add an if statement to check the layer type i.e. use the canned getExtent if we are dealing with shapefiles, otherwise if it is postgis, then use your code and if it is anything else that is non-standard ... well ... tough luck.<br>
<br><div class="gmail_quote">On Wed, Apr 23, 2008 at 11:07 AM, Armin Burger &lt;<a href="mailto:armin.burger@gmx.net">armin.burger@gmx.net</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Alim<br>
<br>
The extent returned for a layer seems to be working only for &#39;standard&#39; layers (e.g. based on shapefiles), but neither for Postgis nor raster layers, god knows why.... I use the code below for zooming to the extent of a Postgis layer:<br>

<br>
$data = trim($layer-&gt;data);<br>
$dataList1 = preg_split(&quot;/\s/&quot;, $data);<br>
$dataList2 = preg_split(&quot;/using/i&quot;, $data);<br>
$geomFld = array_shift($dataList1);<br>
$sql = &quot;select xmin(extent) as minx, ymin(extent) as miny, xmax(extent)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;as maxx, ymax(extent) as maxy<br>
 &nbsp; &nbsp; &nbsp; &nbsp;from (SELECT extent($geomFld) &quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;. substr($dataList2[0], strlen($geomFld)) . &quot;) as bar&quot;;<br>
<br>
// load DLL on Win if required<br>
if (PHP_OS == &quot;WINNT&quot; || PHP_OS == &quot;WIN32&quot;) {<br>
 &nbsp; &nbsp;if (! extension_loaded(&#39;pgsql&#39;)) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;dl(&#39;php_pgsql.dll&#39;);<br>
 &nbsp; &nbsp;}<br>
}<br>
<br>
$connString = $layer-&gt;connection;<br>
if (!($connection = pg_Connect($connString))){<br>
 &nbsp; error_log (&quot;Could not connect to database&quot;);<br>
 &nbsp; error_log (&quot;PG Connection error: &quot; . pg_last_error($connection));<br>
 &nbsp; exit();<br>
}<br>
<br>
$qresult = pg_query ($connection, $sql);<br>
if (!$qresult) error_log(&quot;PG Query error for : $query&quot; . pg_result_error($qresult));<br>
<br>
$pgE = pg_fetch_object($qresult);<br>
$layerExt = ms_newRectObj();<br>
$layerExt-&gt;setextent($pgE-&gt;minx, $pgE-&gt;miny, $pgE-&gt;maxx, $pgE-&gt;maxy);<br>
<br>
<br>
There might be easier solutions but this worked for me.<br>
<br>
armin<div><div></div><div class="Wj3C7c"><br>
<br>
On 22/04/2008 23:52, alim karim wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
hello all.<br>
<br>
i have a PostGIS layer (without its extents specified) in a mapfile.<br>
<br>
i am trying to use getExtent on this layer, but the coordinates i get back ([&quot;minx&quot;:-25000000,&quot;miny&quot;:-25000000,&quot;maxx&quot;:25000000,&quot;maxy&quot;:25000000]) are not the correct extents([1180204.375000, 809428.750000,1222443.000000, 857276.187500)]).<br>

<br>
is there a way to get the proper extents of a layer even though they might not be specified in the mapfile?<br>
<br>
<br>
<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
</blockquote>
</blockquote></div><br>