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

Stephen Woodbridge woodbri at swoodbridge.com
Sat Apr 6 11:01:30 EST 2002


Puneet,

Try something like this for the mapfile:

EXPRESSION ('[CI]' =~ /^Puneet/ || length('[CI]') < 3)
or
EXPRESSION ('[CI]' > 3 && '[CI]' < 5)

You can convert this to PHP or Perl

-Steve

Puneet Kishor wrote:
> 
> Thanks Steve for responding.
> 
> As you know, I figured out the regexp solution like you also suggested...
> 
> > $oClass->setexpression("/^foo$|^bar$|^baz$/");
> 
> actually, since I wanted a full string match of many strings, I did the
> following...
> 
> $oClass->setexpression("/(foo)|(bar)|(baz)/");
> 
> it works peachy.
> 
> For now my problem is solved. However, I still can't get logical
> expressions to works, not at all. I can imagine wanting to do inequality
> operations such as...
> 
> $oClass->setexpression("(([CI] < 5) or ([CI] > 7) or ([CI] eq
> \"Puneet\"))");
> 
> but, no success. I have tried a variety of different syntactic
> constructs (including different case combinations as well, even though I
> know that the attributes are all upper-case), starting with the simplest
> possible ([CI] = 5) and failed.
> 
> I _am_ using PHP/Mapscript right now, but also re-writing the entire
> application in Perl/Maspscript.
> 
> Why are my logical expressions failing? Is there something very obvious
> that I am overlooking?
> 
> >
> >>
> >> 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