[mapserver-users] multiple matches in $classObj->setexpressio n

Puneet Kishor pkishor at GeoAnalytics.com
Mon Apr 8 09:18:15 PDT 2002


good idea. I added a long-ish page at PHPMapScriptMySQLShapeFiles
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptMySQLShapeFiles
(got carried away) under a meta heading of
DevelopingApplicationsWithMapserver at
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?DevelopingApplicationsWithMapse
rver

the note about character fields in logical expressions is bold-italics
(couldn't figure out a way to color the text red or something using wiki).
will add more to it as a complete, step-by-step primer for developing a full
app with session management, user auth, etc., as time permits.

hope this helps someone.

pk/




> -----Original Message-----
> From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
> Sent: Monday, April 08, 2002 6:55 AM
> To: Puneet Kishor
> Cc: Steve Lime; MapServer List (E-mail)
> Subject: Re: [mapserver-users] multiple matches in
> $classObj->setexpression
> 
> 
> 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