I believe you need to use getNumResults() on your layer object, and
then iterate from 0 to getNumResults(), calling getResult() each time.
Note also that queryByPoint() does not return the value that you
think it does--see documentation. You can't use $returnVal the way
you are using it.
Also
$resultCache=$overlayLayer->getResult(returnVal);
will call getResult() every time, because returnVal is not the same
as $returnVal.
At 10:58 PM -0800 12/11/06, Ravi wrote:
Hi Hal,
Thanks for your help. I have made some progress. I am able to search
for a point and find a record number. However somehow the layer is
not able to return me the shape. It gives error
"Fatal error: [MapServer Error]: msDBFGetItemIndex(): Invalid record
number 226. in C:\ms4w\Apache\htdocs\test.php on line 29"
This is odd as it just returned the record number in the search.
Here is my script.
------------------------------------------------------------------------
<?php
dl("php_mapscript_4.10.0.dll");
$map =
ms_newMapObj("C:/ms4w/apps/us_streets2005se-1/map/us_streets2005se-1.map");
$overlayLayer = $map->getLayerByName("countiesLayer");
$myApt = ms_newPointObj();
$myApt->setXY(-120.997, 36.882);
$returnVal=$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);
$resultCache=$overlayLayer->getResult(returnVal);
$overlayLayer->open();
$overlayLayer->getShape($resultCache->tileindex,
$resultCache->shapeindex); // this line gives the error.
?>
------------------------------------------------------------------------
Thanks for help
Ravi
Hal Mueller wrote:
In PHP Mapscript, the queryby... methods on the Layer class
(http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/layerobj
) appear to do what you want--find the shape that matches the
coordinates. From there you can query the shape's attributes, get
its FIPS code, and hit your database.
Hal