[mapserver-users] question on CLASSITEM

Puneet Kishor pkishor at GeoAnalytics.com
Wed May 29 18:17:00 EDT 2002


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