[Mapserver-users] PHP/Mapscript: Searching for Attributes

Frank Broniewski Frank.Broniewski at mnha.etat.lu
Thu Jun 10 07:04:34 EDT 2004


Hello all

I'm still trying to find a way to search for attributes of a shapefile
and center on the found locations or items. To be more precise, I will
describe my data. I have a point shapefile with location names. Through
a web interface, I want to enable the user to search for a location by
name.
The entry in my .map file for the point-shp is as followed:

LAYER
    Name "Bezeichnung"
    Data maps/toponyme
    Status ON
    Type Point

    LabelItem "toponyme"
    ClassItem "Nature"

    CLASS
      Name "Communes"
      Expression "Commune"
      Color 255 0 0
      LABEL
        Color 25 25 25
        ShadowColor 225 225 225
        ShadowSize 1 1
        Type TRUETYPE
        Font arial
        Size 10
        AntiAlias TRUE
        Position CC
        Partials FALSE
      END
    END
END

1) First thing is, I didn't enter a TEMPLATE expression, because I don't
know how to enter it with the correct values. As my homepage is created
dynamically like:

$image = $map->draw();
$image_url = $image->saveWebImage();

When you enter a .html file as a parameter to TEMPLATE, how do I deal
with this as I use a .php? Looking at the the gmap - demo, they use a
nonexisting file as TEMPLATE parameter (ttt_query.html). But how can I
use the values provided to the .html file?

2) In my .php file I used the queryByAttribute method to query my layer.
With the kind help of this list I managed to make it perform my query.
But I'm not sure, if I used it correctly for my purpose. The code is as
followed:

  $mySearchLayer = $MapObj->getLayerByName("Toponyme");
  if (
$mySearchLayer->queryByAttributes("TOPONYME","BERTRANGE","MS_SINGLE") ==
"MS_SUCCESS" ) {
    $myErgQuery = $MapObj->drawQuery();
    $QueryImage = $myErgQuery->saveWebImage("MS_PNG",1,1,0);
  } else {
    $fehler = "Nicht gefunden";
    echo $fehler;
  }

It returns me, whatever searchparameter I enter, the whole map without
marked points. The query thing is keeping me busy quite a few days now
and I'm getting more and more confused. I did a search on the
mailing-list archives but the few informations provided there just don't
get me on the right path, as I seem to lack the ability to understand
the methods like querybyattribute right.

Can some kind reader show me in a general manner how I can perform an
attribute query on a shapefile and get some coordinate values returned?

Many thanks in advance

                                                      
Frank Broniewski
Musée National d'Histoire et d'Art
Section Préhistoire / Projet EPC
    Tél: +352 260 281-21
241, Rue de Luxembourg
L-8077 Bertrange





More information about the mapserver-users mailing list