Ticket #3630 (closed defect: invalid)
Incomplete shape object from resultsGetShape() for querybypoint on raster layer
| Reported by: | mgleahy | Owned by: | mapserverbugs |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | MapScript-PHP | Version: | 5.6 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Consider the following code, using PHP MapScript?:
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->resultsGetShape($oResult->shapeindex, $oResult->tileindex);
var_dump($oShape->line(0));
}
}
If in the above code example, $oLayer refers to a vector layer of any type (point/line/polygon), the result from $oShape->line(0) will be an instance of the ms_line_obj. However, if $oLayer refers to a raster type of layer, $oShape->line(0) returns false. As a result, anything that is looking for fully-constructed shape object (e.g., $oShape->toWkt()) will run into errors.
Although it's a bit redundant to look for this shape when querying by point on a raster, it means that you will have to always check for the layer type to make sure if it is vector or raster...and in the latter case, reconstruct your own shape object from the original query coordinates.
