[Mapserver-users] Drawquery issue

Ryan, Adam ARyan at co.linn.or.us
Wed Jul 21 12:27:49 EDT 2004


Frank

Try removing the first $myLayer->Close() in your SEARCHBYNAME code.

Adam 
 


-----Original Message-----
From: Frank Broniewski [mailto:Frank.Broniewski at mnha.etat.lu] 
Sent: Wednesday, July 21, 2004 8:04 AM
To: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] Drawquery issue


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


_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list