[mapserver-users] multiple matches in $classObj->setexpression

Stephen Woodbridge woodbri at swoodbridge.com
Mon Apr 8 04:55:18 PDT 2002


Puneet,

You could help everyone if you would do a mini howto page on wiki.
It could be just a bunch of examples of various expressions it a short
explaination of what is important about each. I would then be easier to
point other people to it in the future.

Anyway, glad your up and running.
  -Steve

Puneet Kishor wrote:
> 
> thanks to sw and sdl, I now know how to do this (will try it out
> tomorrow at work). one thing though... the documentation makes a very
> cursory mention of this peculiarity without really pointing it out...
> 
> Specifically, I could find only one passing references to attribs in
> shape files at http://mapserver.gis.umn.edu/doc/mapfile-reference.html
> 
> > Logical expressions allow you to build fairly complex tests based on
> > one or more attributes and therefore are only available with
> > shapefiles. Logical expressions are delimited by parentheses
> > "(expression)". Attribute names are delimited by square brackets
> > "[ATTRIBUTE]". These names are case sensitive and must match the items
> > in the shapefile. For example: EXPRESSION ([POPULATION] > 50000 AND
> > '[LANGUAGE]' eq 'FRENCH') ... The following logical operators are
> > supported : =,>,<,<=,>=,=,or,and,lt,gt,ge,le,eq. As you might expect
> > this level of complexity is slower to process.
> 
> see the '[LANGUAGE]' eq 'FRENCH' bit... that escaped me completely, and
> now is noticeable only because I have been educated about it.
> 
> Nonetheless, many thanks,
> 
> pk/
> 
> On Friday, April 5, 2002, at 07:07  PM, Stephen Woodbridge wrote:
> 
> > Puneet,
> >
> > You want to use a regular expression so in your mapfile you would say:
> >
> > CLASSITEM "GIS_KEY"
> > CLASS
> >   EXPRESSION /^foo$|^bar$|^baz$/
> >
> > or in php you would say something like:
> >
> > $oLayer->set("classitem", "GIS_KEY");
> >   ...
> > $oClass->setexpression("/^foo$|^bar$|^baz$/");
> >
> > I haven't tested this but it should be close to this syntax. Give it a
> > try and let us know how it goes.
> >
> > -Steve W.
> >
> > Puneet Kishor wrote:
> >>
> >> with the following in my map file...
> >>
> >> LAYER
> >>   NAME "parcels_highlight"
> >>   TYPE polygon
> >>   DATA parcel
> >>   STATUS off
> >>         CLASSITEM "OWNER"
> >>   CLASS
> >>     OUTLINECOLOR 255 0 0
> >>     COLOR 255 255 0
> >>   END
> >>   TEMPLATE "parcels.php"
> >> END
> >>
> >> The following works fine...
> >>
> >> $str = "foo";
> >> $classObj->setexpression("\"$str\"");
> >> $layerObj->set("status", 1);
> >>
> >> But I want to do the following, which, needless to say, does not
> >> work...
> >>
> >> $str = "([GIS_KEY] in (\"foo\", \"bar\", \"baz\"))";
> >> $classObj->setexpression("\"$str \"");
> >> $layerObj->set("status", 1);
> >>
> >> In fact, I can't even get the following to work...
> >>
> >> $str = "([GIS_KEY] eq \"foo\")"; OR
> >> $str = "([GIS_KEY] == \"foo\")"; OR
> >> $str = "([GIS_KEY] eq 'foo')"; etc.
> >>
> >> What am I missing here? And if the "in" clause is not supported
> >> (doesn't
> >> seem to be per the docs), would I need to do the following...
> >>
> >> $str = "(([GIS_KEY] eq \"foo\") or ([GIS_KEY] eq \"bar\") or
> >> ([GIS_KEY] eq
> >> \"baz\"))";
> >>
> >> Tia,
> >>
> >> pk/



More information about the MapServer-users mailing list