mapscript error

Pietro Giannini pgiannini at BYTEWISE.IT
Wed Dec 13 04:35:11 EST 2006



Hi Ravi,

I think error is in 
   
$returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);
    $resultCache =
$overlayLayer->getResult(returnVal);
because the method
queryByPoint returns MS_SUCCESS or MS_FAILURE, not the index of shape.

You must:
    $returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);
    $numberOfResults =
$overlayLayer->getNumResults;
   
$overlayLayer->open();
    for
($i=0;$i<$numberOfResults;$i++) {
       
$resultCache = $overlayLayer->getResult($i);
   
    $shapeObj =
$overlayLayer->getShape($resultCache->tileindex,$resultCache->shapeindex);
        /* some code with $shapeObj
                ...
                
...
        */
    }
    $overlayLayer->close();

let me know
Pietro

PS:
Maybe you can help me:
how do you get
the map coordinates of a user's click? (not pixel, cartographic
coordinates).
thanks

-- 
Pietro Giannini
Bytewise
srl - Area GIS
41°50'38.58"N 12°29'13.39"E


On Mar, 12 Dicembre 2006 9:42 pm, Ravi wrote:
> Hi
guys,
> 
> I am writing a simple mapscript. This is what I
am doing:
> 
> I have a layer where I draw counties. When
a user clicks on map (I have
> the coordinates), I want to find
which county it is. So I query the
> layer and I get one record
back, so far so good. Then I call getShape
> method for the
record. Now suddenly I get the error that the record
> number does
not exist. I opened the DBF file and the record IS there.
> 
> Your help is appreciated. My script and error are as follows:
> 
> 
>
--------------------------------------------------------------------
> Fatal error: [MapServer Error]: msDBFGetItemIndex(): Invalid
record
> number 226. in C:\ms4w\Apache\htdocs\test.php on line
16
>
--------------------------------------------------------------------
> <?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(-121.997,
37.348);
> 
> $returnVal =
$overlayLayer->queryByPoint($myApt,$mapscript->MS_SINGLE,0);
> 
> $resultCache =
$overlayLayer->getResult(returnVal);
> 
>
$overlayLayer->open();
>
$overlayLayer->getShape($resultCache->tileindex,
>
$resultCache->shapeindex);
> // I am getting error on this
previous line, getShape fails.
> ?>
> <HTML>
> <HEAD>
> <TITLE>Show Weather On
Map</TITLE>
> </HEAD>
> <BODY>
>
mapscript version = <?php echo $resultCache->shapeindex ?>
> </BODY>
> </HTML>
> 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20061213/896bbba2/attachment.html


More information about the mapserver-users mailing list