[mapserver-users] mapscript querybypoint on tiled raster layers?
Mike Leahy
mgleahy at alumni.uwaterloo.ca
Tue Jul 29 10:21:59 PDT 2008
Hello list,
I'm sure this one has come up before, but I can't seem to figure out
what I need to do. I have some tiled raster layers that I've got in a
mapfile that is being used for generating ka-map tiles. I'm trying to
query the values on these layer using the queryByPoint function in
php_mapscript. I have a generic identify function that returns results
for any of my vector layers, and for non-tiled raster layers - just not
for the tiled raster layers. Is it possible to query tiled raster
layers? If so, can someone spot what I'm doing wrong below?
The tiled-raster layers in the mapfile generally look like this:
LAYER
NAME "Tiled Raster"
GROUP "Tiled Raster"
STATUS ON
TYPE RASTER
TILEINDEX "/data/index.shp"
TILEITEM "LOCATION"
METADATA
"imageformat" "AGG_JPEG"
END
PROJECTION
"init=epsg:4326"
END
END
And here is the function in PHP:
public function Identify($oMap,$layer,$x,$y,$cellSize)
{
$oLayer = $oMap->getLayerByName($layer);
if (in_array($oLayer->type,
array(MS_LAYER_POINT,MS_LAYER_LINE,MS_LAYER_POLYGON)))
{
$oLayer->set("toleranceunits",$oMap->units);
$oLayer->set("tolerance",$cellSize*3);
}
else
{
$oLayer->set("tolerance",0);
}
$oLayer->set("template","dummy.html");
$oQPoint = ms_newPointObj();
$oQPoint->setXY($x,$y);
$aResults = array();
if (@$oLayer->queryByPoint($oQPoint,MS_MULTIPLE,$oLayer->tolerance)
== MS_SUCCESS)
{
$oLayer->open();
$nResults = $oLayer->getNumResults();
for ($i=0;$i<$nResults;$i++)
{
$oResult = $oLayer->getResult($i);
$oShape = $oLayer->getShape($oResult->tileindex,
$oResult->shapeindex);
$aResults[] = array($oResult,$oShape);
}
}
return $aResults;
}
Thanks in advance for any help,
Mike
More information about the MapServer-users
mailing list