[mapserver-users] mapserver >= 5.6 and querys via php-mapscript

Sven Schroeter schroeter at netgis.de
Thu Jun 10 06:01:49 PDT 2010


Hi,
I'm still fighting with mapserver >= 5.6 and querys via php-mapscript.
My code for e.g. making a queryByRect works fine since I use resultsGetShape 
instead of getShape for version 5.6:

//query
@$datQuery = $query_layer->queryByRect($qRect);

//number of objects
$resnum = $query_layer->getNumResults();
echo "number of objects: ".$resnum."<br>";

 //if query success
if ($datQuery == MS_SUCCESS) {

 //check ms version
  if (ms_GetVersionInt() < 50600){
 $query_layer->open();
  }

  //write table
  echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>';

  for ($j=0; $j<$query_layer->getNumResults(); $j++) {
   $result = $query_layer->getResult($j);

  //check ms version
  if (ms_GetVersionInt() < 50600){
 $shpobj = $query_layer->getShape($result->tileindex,$result->shapeindex);
 }
  else{
 $shpobj = 
$query_layer->resultsGetShape($result->shapeindex,$result->tileindex);
  }

   $si = $result->shapeindex;
   $attr = $shpobj->values;
   echo '<tr><td>'.$si.'</td>';
   foreach($attr as $name=>$wert) {
    echo '<td>'.$wert.'</td>';
   }
   echo '</tr>';
   $shpobj->free();
  }
//check ms version
if (ms_GetVersionInt() < 50600){
 $query_layer->close();
}
echo '</table>';
} // end success

My problem: using ms 5.6 the shapeindex ($result->shapeindex;) is only an 
temporal arrayindex (0-x) and not the "real" shapeindex I get with 
mapserverversions < 5.6.
How can I get the "real" shapindex of my shapes using ms 5.6? I need this 
for pointing on single shapes in another program.

Thanks
Sven





More information about the MapServer-users mailing list