Raster query en Mapserver mediante mapscript

La implementación de WFS de mapserver no permite hacer consultas getFeatureInfo sobre una capa typo raster por lo que es necessario realizar un pequeño wraper en este caso en php.

<?php
$coord = split(',',$_POST["coord"]);

//load mapfile
$map= ms_newMapObj('media/conf_mapserv/mdt.map');

//create point
$qPoint = ms_newPointObj();
$qPoint-&gt;setXY(0.19869,41.02164);

//set layer
$layer = $map-&gt;getLayerByName("set_31_b");

//Pointquery (Single)
@$datQuery = $layer-&gt;queryByPoint($qPoint, MS_SINGLE, 1);

//if success
if ($datQuery == MS_SUCCESS) {
         for ($j=0; $j<$layer-&gt;getNumResults(); $j++) {
            $result = $layer-&gt;getResult($j);
   $layer-&gt;open();
   $shpobj = $layer-&gt;getShape($result-&gt;tileindex,$result-&gt;shapeindex);
   $attr = $shpobj-&gt;values;
   //echo round($attr["value_0"],2);
   $rasterdata = round($attr["value_0"],1);
   print "My Data: ".$rasterdata."";
   $shpobj-&gt;free();
         }
     }
  else{
     print 'no Data';
  }
?>;
Tagged with:
Posted in Programación