<br><font size=2 face="sans-serif">List,</font>
<br><font size=2 face="sans-serif">I'm trying to implement a zoom to point
function, where by a user specifies a point (reach) number, clicks on a
submit button, and the map will zoom to the point.</font>
<br><font size=2 face="sans-serif">However, I'm having trouble with a GetShape
statement. Something isn't right. The mapserver stops at this
particular line of code:</font>
<br><font size=2 face="sans-serif"><br>
$oShape = $oReachLayer->getShape($oResult->tileindex,$oResult->shapeindex);</font>
<br>
<br><font size=2 face="sans-serif">Below is my code for this feature. You'll
see that I still have to modify the code for zooming to a point rather
than a polygon, but I haven't got that far yet.</font>
<br><font size=2 face="sans-serif">I've searched the MapServer list and
posted, but with no luck. Using MS 4.2, php 4.3.4.</font>
<br>
<br><font size=2 face="sans-serif">Thanks in advance.</font>
<br>
<br><font size=2 face="sans-serif">Kevin </font>
<br>
<br><font size=2 face="sans-serif"><b>Code:</b></font>
<br>
<br><font size=2 face="sans-serif">if (isset( $http_form_vars["doReachZoom"])
&& ($http_form_vars["doReachZoom"] > "0"
))</font>
<br><font size=2 face="sans-serif">{</font>
<br><font size=2 face="sans-serif"> //echo
"zoom to reach";</font>
<br><font size=2 face="sans-serif"> //
the reach number to query for</font>
<br><font size=2 face="sans-serif"> $szReachNumber
= $http_form_vars["reachnum"];</font>
<br>
<br><font size=2 face="sans-serif"> //
the current extents will be the default if we fail.</font>
<br><font size=2 face="sans-serif"> $oExtents
= $oMapSession->oMap->extent;</font>
<br><font size=2 face="sans-serif"> $oldExtents=$oExtents;</font>
<br>
<br><font size=2 face="sans-serif"> //first
we need a handle on the layer, let's assume that we have</font>
<br><font size=2 face="sans-serif"> //it's
name</font>
<br><font size=2 face="sans-serif"> $oReachLayer
= $oMapSession->oMap->getLayerByName( "Reaches" );</font>
<br>
<br><font size=2 face="sans-serif"> $oReachLayer->queryByAttributes("REACH",
$szReachNumber, MS_SINGLE );</font>
<br><font size=2 face="sans-serif"> //echo
("$szReachNumber");</font>
<br><font size=2 face="sans-serif"> $results
= $oReachLayer->getNumResults();</font>
<br><font size=2 face="sans-serif"> //echo
("-- $results --");</font>
<br><font size=2 face="sans-serif"> //now
check to see if there are any results?</font>
<br><font size=2 face="sans-serif"> if
($oReachLayer->getNumResults() > 0 )</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif">
//echo " results2";</font>
<br><font size=2 face="sans-serif">
//at least one result, assume only one for
this example</font>
<br><font size=2 face="sans-serif">
$oResult = $oReachLayer->getResult(0);</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif">
//oResult is a resultCacheMemberObj</font>
<br><font size=2 face="sans-serif">
$oReachLayer->open($oMapSession->oMap->shapepath);</font>
<br><font size=2 face="sans-serif">
<b>echo " results3"; // THIS
IS ECHOED</b></font>
<br><font size=2 face="sans-serif">
<b>$oShape = $oReachLayer->getShape($oResult->tileindex,$oResult->shapeindex);
// IS THERE A PROBLEM WITH THIS LINE???</b></font>
<br><font size=2 face="sans-serif">
<b>echo " results4"; // THIS
IS NOT ECHOED </b></font>
<br><font size=2 face="sans-serif">
$oExtents = $oShape->bounds;</font>
<br><font size=2 face="sans-serif">
echo " results5";</font>
<br><font size=2 face="sans-serif">
//$oShape->free();</font>
<br>
<br><font size=2 face="sans-serif">
//at this point we might add a buffer to the
extents</font>
<br><font size=2 face="sans-serif">
$nXBuffer = ( $oExtents->maxx - $oExtents->minx
)*0.05;</font>
<br><font size=2 face="sans-serif">
$nYBuffer = ( $oExtents->maxy - $oExtents->miny
)*0.05;</font>
<br><font size=2 face="sans-serif">
$nMinX = $oExtents->minx - $nXBuffer;</font>
<br><font size=2 face="sans-serif">
$nMaxX = $oExtents->maxx + $nXBuffer;</font>
<br><font size=2 face="sans-serif">
$nMinY = $oExtents->miny - $nYBuffer;</font>
<br><font size=2 face="sans-serif">
$nMaxY = $oExtents->maxy + $nYBuffer;</font>
<br><font size=2 face="sans-serif">
$oExtents->setextent( $nMinX, $nMinY, $nMaxX,
$nMaxY );</font>
<br><font size=2 face="sans-serif">echo "oExtents have been set";</font>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif">// else{</font>
<br><font size=2 face="sans-serif">//
echo " no results";}</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif"> //
now use $oMapNavigator to navigate to the parcel</font>
<br><font size=2 face="sans-serif"> //
location. There are two useful options now. We</font>
<br><font size=2 face="sans-serif"> //
can zoom to a rectangle which we have calculated or</font>
<br><font size=2 face="sans-serif"> //
to a point and scale. Let's assume we have calculated</font>
<br><font size=2 face="sans-serif"> //
a rectangle and put a buffer around it if necessary.</font>
<br><font size=2 face="sans-serif"> //$width=$oMapSession->oMap->width;</font>
<br><font size=2 face="sans-serif">// $height=$oMapSession->oMap->height;</font>
<br>
<br><font size=2 face="sans-serif">// $px1=$width/($oldExtents->maxx-$oldExtents->minx)*($oExtents->minx-$oldExtents->minx);</font>
<br><font size=2 face="sans-serif">// $px2=$width/($oldExtents->maxx-$oldExtents->minx)*($oExtents->maxx-$oldExtents->minx);</font>
<br><font size=2 face="sans-serif">// $py1=$height/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->maxy);</font>
<br><font size=2 face="sans-serif">// $py2=$height/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->miny);</font>
<br>
<br><font size=2 face="sans-serif"> //$oMapNavigator->zoomRectangle($px1,
$py2, $px2, $py1);</font>
<br>
<br><font size=2 face="sans-serif"> //
alternately if it's a point and a scale ...</font>
<br><font size=2 face="sans-serif"> $oMapNavigator->zoomScale(
1000, 100, 100 );</font>
<br><font size=2 face="sans-serif">}</font>
<br><font size=2 face="sans-serif">else</font>
<br><font size=2 face="sans-serif">{</font>
<br><font size=2 face="sans-serif">echo "reach is null or negative";</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<p><font size=2 color=blue face="Times New Roman">______________________________</font><font size=5 color=blue face="Times New Roman"><br>
Baird </font><font size=2 color=blue face="Times New Roman"><i><br>
Innovation, Excellence, & Service</i></font><font size=3> </font><font size=2 color=blue face="Times New Roman"><i><br>
Oceans, Lakes & Rivers</i></font><font size=2 face="Times New Roman"><b><br>
Kevin Grootendorst </b><br>
905-845-5385 phone 905-845-0698 fax<br>
627 Lyons Lane, Suite 200<br>
Oakville, Ontario, Canada L6J 5Z7 </font><font size=2 color=blue face="Times New Roman"><u><br>
</u></font><a href=mailto:kgrootendorst@baird.com><font size=2 color=blue face="Times New Roman"><u>mailto:kgrootendorst@baird.com</u></font></a><font size=3>
</font><a href=http://www.baird.com/ target=_blank><font size=2 color=blue face="Times New Roman"><u>http://www.baird.com/</u></font></a><font size=3>
</font><font size=5 color=blue face="Times New Roman"><br>
______________________________</font>