[mapserver-users] question on CLASSITEM

Steve Lime steve.lime at dnr.state.mn.us
Thu May 30 13:28:48 EDT 2002


The rules for expressions are like this:

1) EXPESSIONSs are matched in order of definition in the map file, the
first match returns that CLASS

This means that expressions don't have to be mutually exclusive.

2) a CLASS with out an EXPRESSION becomes the default CLASS, regardless
of the value of CLASSITEM

This is nice in that you don't have to define expressions to cover all
cases, speeds things up too. If you really
do want to exclude features then each class must have an expression.

Makes perfect sense to me, but then again I'm a bit close to it. Seems
that if you want nothing to match a 
class then don't define it.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Lowell Filak" <lfilak at medinaco.org> 05/30/02 07:28AM >>>
You could include a regular expression in your mapfile for the class
that you know will always match nothing and then use mapscript to
overwrite the expression when you really want a search done. No.?
Lowell F.

The following message was sent by Puneet Kishor
<pkishor at GeoAnalytics.com> on Wed, 29 May 2002 17:17:00 -0500.

> Steve,
> 
> What you say makes sense, except this is not what is happening. I
apologize
> because I did not give all the details for the sake of brevity,
however, the
> scenario is thus...
> 
> The layer is turned on (in certain cases) no matter what. Then, if
$expr is
> something then the mapscript code executes and matches the $expr. If
$expr
> is "" then the mapscript code doesn't even execute. The layer
highlights all
> the features nonetheless.
> 
> In other words, assuming the layer is on, if I have CLASSITEM "blah"
and I
> provide an expression then the feature(s) are matched. If I don't
provide an
> expression then everything is matched. Intuitively (for me at least),
it is
> this last behavior that doesn't seem right... what I would rather
that if I
> don't provide an expression then nothing should match, the layer
should turn
> on (or off... that is irrelevant), but nothing should show.
> 
> Guess that is not the way the behavior is programmed, so I have to
code
> around that.
> 
> 
> Puneet.
> 
> 
> 
> > -----Original Message-----
> > From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com] 
> > Sent: Wednesday, May 29, 2002 5:04 PM
> > To: Puneet Kishor
> > Cc: mapserver-users at lists.gis.umn.edu 
> > Subject: Re: [mapserver-users] question on CLASSITEM
> > 
> > 
> > Puneet,
> > 
> > I think that your problem is that you are comparing based on a
regular
> > expression match because you are uing "/$expr/" which is really
asking
> > if $expr is in the the string so /a/ would match "bbbabbb" 
> > AND following
> > that logic // a null pattern will match any string. If you 
> > want to match
> > "" eq "a" to fail, then don't use a regular expression.
> > 
> > -Steve
> > 
> > Puneet Kishor wrote:
> > > 
> > > mapfile (only relevant lines shown) --
> > > 
> > > LAYER
> > >         NAME "layer_highlight"
> > >         STATUS off
> > >         CLASSITEM "blah"
> > >         CLASS
> > >                 ...classdef...
> > >         END
> > >         TEMPLATE "foo"
> > > END
> > > 
> > > mapscript (only relevant lines shown) given $expr for "blah" --
> > > 
> > > $layerObj = $mapObj->getlayerbyname("layer_highlight");
> > > $classObj = $layerObj->getClass(0);
> > > $classObj->setexpression("/$expr/");
> > > $layerObj->set("status", 1);
> > > 
> > > this turns on "layer_highlight" and highlights the features 
> > that match
> > > CLASSITEM "blah" to "$expr".
> > > 
> > > The problem is thus -- if $expr exists then features are 
> > correctly matched
> > > in the layer. However, if $expr == "", then all the 
> > features end up getting
> > > matched... what I want is that if $expr == "" then the 
> > layer should turn on,
> > > however, no feature should show up since no feature is matched.
> > > 
> > > Any ideas?
> > > 
> > > pk/
> > 




More information about the mapserver-users mailing list