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

Stephen Woodbridge woodbri at swoodbridge.com
Fri Apr 5 17:07:32 PST 2002


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