[Mapserver-users] Drawquery issue

Frank Broniewski Frank.Broniewski at mnha.etat.lu
Wed Jul 21 11:03:44 EDT 2004


Hello List

I'm using two methods of querying my Map - querybypoint and
querybyattribute. Both use similar code to query the layers, please see
below. My problem is, that the drawquery - method with the querybypoint
does work, while with the querybyattribute doesn't. And I simply can't
figure out why :-)

Here comes my code
---------------------------------------------
SEARCHBYNAME:
  ...
  foreach ($MapLayers as $layer) {
    $myLayer = $MapObj->getLayerByName($layer);
    $myLayer->set("status",1);
    $myLayer->Open();
    $dbheaders = $myLayer->getItems();
    $myLayer->Close();
    foreach ($dbheaders as $spaltenname) {
      if (@$myLayer->queryByAttributes($spaltenname,
$SuchOrt,"MS_MULTIPLE") == MS_SUCCESS) {
        $NumResults = $myLayer->getNumResults();
        $myLayer->Open();
        for ($i=0; $i < $NumResults; $i++) {
          $result = $myLayer->getResult($i);
          $data = $myLayer->getShape($result->tileindex,
$result->shapeindex);
          $erg[] = $layer;
          $erg[] = $data->values;
          $data->free();
        }
        $myLayer->Close();
      }
    }
  }
  return $erg;

SEARCHBYPOINT:
  ...
  foreach ($MapLayers as $layer) {
    $myLayer = $MapObj->getLayerByName($layer);
    $myLayer->set("status",1);
    if (@$myLayer->queryByPoint($myPoint, "MS_MULTIPLE", 0) ==
"MS_SUCCESS") {
      $NumResults = $myLayer->getNumResults();
      $myLayer->Open();
      for ($i=0; $i < $NumResults; $i++) {
        $result = $myLayer->getResult($i);
        $data = $myLayer->getShape($result->tileindex,
$result->shapeindex);
        $erg[] = $layer;
        $erg[] = $data->values;
        $data->free();
      }
      $myLayer->Close();
    }
  }
  return $erg;

As you can see, both get the selected maplayers to work with.
SEARCHBYNAME get the Attributenames from the shapefile via getItems and
queries each Attribute seperately. The rest of the code works quite
similar.
Does anybody have a clue why SEARCHBYNAME doesnt draw the query? Maybe I
have coded some logical error, since I read the attributes( and their
values) from the shapefile for each layer correctly.

Many thanks in advance 

                                                      
Frank Broniewski
Musée National d'Histoire et d'Art
Section Préhistoire / Projet EPC





More information about the mapserver-users mailing list