Hi Ravi,<br /><br />I think error is in <br />
$returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);<br
/> $resultCache =
$overlayLayer->getResult(returnVal);<br />because the method
queryByPoint returns MS_SUCCESS or MS_FAILURE, not the index of shape.<br
/><br />You must:<br /> $returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);<br
/> $numberOfResults =
$overlayLayer->getNumResults;<br />
$overlayLayer->open();<br /> for
($i=0;$i<$numberOfResults;$i++) {<br />
$resultCache = $overlayLayer->getResult($i);<br />
$shapeObj =
$overlayLayer->getShape($resultCache->tileindex,$resultCache->shapeindex);<br
/> /* some code with $shapeObj<br
/> ...<br
/>
...<br /> */<br /> }<br
/> $overlayLayer->close();<br /><br />let me know<br
/>Pietro<br /><br />PS:<br />Maybe you can help me:<br />how do you get
the map coordinates of a user's click? (not pixel, cartographic
coordinates).<br />thanks
<pre class="literal-block"><br />-- <br />Pietro Giannini<br />Bytewise
srl - Area GIS<br />41°50'38.58"N 12°29'13.39"E</pre>
<br /><br />On Mar, 12 Dicembre 2006 9:42 pm, Ravi wrote:<br />> Hi
guys,<br />> <br />> I am writing a simple mapscript. This is what I
am doing:<br />> <br />> I have a layer where I draw counties. When
a user clicks on map (I have<br />> the coordinates), I want to find
which county it is. So I query the<br />> layer and I get one record
back, so far so good. Then I call getShape<br />> method for the
record. Now suddenly I get the error that the record<br />> number does
not exist. I opened the DBF file and the record IS there.<br />> <br
/>> Your help is appreciated. My script and error are as follows:<br
/>> <br />> <br />>
--------------------------------------------------------------------<br
/>> Fatal error: [MapServer Error]: msDBFGetItemIndex(): Invalid
record<br />> number 226. in C:\ms4w\Apache\htdocs\test.php on line
16<br />>
--------------------------------------------------------------------<br
/>> <?php<br />> dl("php_mapscript_4.10.0.dll");<br
/>> <br />> $map =<br />>
ms_newMapObj("C:/ms4w/apps/us_streets2005se-1/map/us_streets2005se-1.map");<br
/>> <br />> $overlayLayer =
$map->getLayerByName("countiesLayer");<br />> <br />>
$myApt = ms_newPointObj();<br />> $myApt->setXY(-121.997,
37.348);<br />> <br />> $returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);<br
/>> <br />> $resultCache =
$overlayLayer->getResult(returnVal);<br />> <br />>
$overlayLayer->open();<br />>
$overlayLayer->getShape($resultCache->tileindex,<br />>
$resultCache->shapeindex);<br />> // I am getting error on this
previous line, getShape fails.<br />> ?><br />> <HTML><br
/>> <HEAD><br />> <TITLE>Show Weather On
Map</TITLE><br />> </HEAD><br />> <BODY><br />>
mapscript version = <?php echo $resultCache->shapeindex ?><br
/>> </BODY><br />> </HTML><br />> <br /><br /><br />