[mapserver-users] question on CLASSITEM

Stephen Woodbridge woodbri at swoodbridge.com
Wed May 29 18:04:21 EDT 2002


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