how to find bounding county for given long/lat?

Ravi ravikapoor101 at GMAIL.COM
Tue Dec 12 01:58:22 EST 2006


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
> 



More information about the mapserver-users mailing list