[mapserver-users] Problem with spatial query
Bistrais, Bob
Bob.Bistrais at maine.gov
Mon Feb 9 14:48:41 PST 2009
This message is also posted to the Ka-Map users board, but I'm also
posting here because it pertains to PHP MapScript...
I've been customizing some of the Ka-Map Search code. These are
modifications of the kaSearch .php and .js. I have a tool that allows a
user to enter a parcel number into a text box, and zoom to that parcel
automatically. That part of the process works. I can get the extent of
the selected parcel and the map will zoom to it.
Here's where I'm having trouble- now that I have the extent of the
desired parcel, I would like to automatically run a query a zoning
layer, and return the zoning polygons that the selected parcel
intersects. I tried Query by Point, Rectangle, and Shape, I'm sure the
coordinates area valid, but when I run the tool, it returns zone
polygons from an area far away from where I am querying. It doesn't
even seem to matter what parcel I use for input- it always returns the
same zoning polygons. As a matter of fact, it looks as though it's
returning results for the same poly, over and over again. In any case,
it's definitely far from the selected parcel polygon.
I've pasted some code below. Does anyone have any suggestions?
Thanks,
Bob
This code is part of my kaSearchParcel.php, which selects a parcel and
zooms to it. The code below is the query that tries to return the
intersecting zoning polygons:
$zoneLayer = $oMap->getLayer(3);
//Layer 3 is the zoning data
$oMap->preparequery();
$results = @$oMap->queryByShape($oShape); //$oShape is
the parcel that was selected earlier in the php file
if ($results == MS_SUCCESS){
$r = $zoneLayer->getNumResults();
for ($d=0; $d<$r; $d++) {
$zoneLayer->open();
$result = $zoneLayer->getResult(0);
echo $r . " results found<br>";
$shape = $zoneLayer->getFeature($result->shapeIndex,
$result->tileindex);
foreach ($shape->values as $key => $value) {
echo $key. " = " .$value . "index =" .$result->shapeIndex .
"<br>";
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090209/c20fb02a/attachment.htm>
More information about the MapServer-users
mailing list