[Mapserver-users] CLASS is like a CASE statement, it will stop after one is selecte d????

Javier Castillejo Montes jcastil1 at tragsa.es
Thu Jul 15 23:52:39 PDT 2004


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C46B01.7DAC04C2
Content-Type: text/plain;
	charset="iso-8859-1"

Hi all 

this is the newbie again

Stephen wrote
 "CLASS is like a CASE statement, it will stop after one is selected"

on an explanation he told me some weeks ago... I tried with this but it
doesn't work for me.
I have one layer with some class on it and  ALL are done. Where have I the
error???

.map:

	LAYER # Provincias polygon layer begins here
		NAME		provPerimeter
		DATA        provin
		STATUS      OFF
		TYPE        POLYGON
		GROUP		Provincias
		
		PROJECTION
		  "init=epsg:23030"
		END

		METADATA
			"title" "Provincias"
		END	
		
	     LABELITEM "Divi"
	     CLASSITEM    "Case1"
			CLASS
				EXPRESSION "D1"
				COLOR 99 154 206
				OUTLINECOLOR 0 0 0
			END
			CLASS
				EXPRESSION "D2"
				COLOR 255 154 99
				OUTLINECOLOR 0 0 0
			END
			CLASS
				EXPRESSION "D3"
				COLOR 99 255 206
				OUTLINECOLOR 0 0 0
			END
			CLASS
				EXPRESSION "D4"
				COLOR 255 101 99
				OUTLINECOLOR 0 0 0
			END
			CLASS
				EXPRESSION "D5"
				COLOR 255 207 99
				OUTLINECOLOR 0 0 0
			END
END



-----Mensaje original-----
De: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
Enviado el: viernes, 02 de julio de 2004 14:49
Para: Javier Castillejo Montes
CC: Mapserver-users at lists.gis.umn.edu
Asunto: Re: [Mapserver-users] Different colors in different layers


Same idea, but you have to know the range of colors that are possible 
and create a CLASS for each COLOR then use an EXPRESSION to select the 
color instead of the "divi" so if your values were like 1 .. 100 and you 
wanted assign colors based on 1-10, 11-20, 21-30, ..., 91-100

CLASS
   EXPRESSION ([divi] < 11)
   STYLE
     COLOR ...
   END
END
CLASS
   EXPRESSION ([divi] < 21)
   STYLE
     COLOR ...
   END
END
...
CLASS
   # no expression is like an default: and will catch
   # anything not caught above.
   STYLE
     COLOR ...
   END
END

CLASS is like a CASE statement, it will stop after one is selected.

-Steve W.

Javier Castillejo Montes wrote:

> Oh thanks that looks fine... 
> 
> and... how about do it dinamically (i think it's said "on the fly"), I
mean,
> I have the color I need on a database field... how can I assign the "divi"
> to his color at runtime.
> 
> Javier C.
> 
> 
> -----Mensaje original-----
> De: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
> Enviado el: viernes, 02 de julio de 2004 14:14
> Para: Javier Castillejo Montes
> CC: Mapserver-users at lists.gis.umn.edu
> Asunto: Re: [Mapserver-users] Different colors in different layers
> 
> 
> Javier Castillejo Montes wrote:
> 
> 
>>Hi!
>> 
>>First of all  Im very bad english writer (its not my language so please
>>forgive my mistakes
>> 
>>and im really new at mapserver
>> 
>>I'll try to make myself clear
>> 
>>I have differents layers and one of then is a layer a field , this field
> 
> has
> 
>>various divisions(layer 1)  and inside each division(divi A) there is one
>>more division (layer 1) (divi AA,AB,AC). Can anybody tell me how can I put
> 
> a
> 
>>different color for each diviA and a different color for divi   AA,AB,AC
> 
> 
> Javier,
> 
> You will need to know what all the possible divi are then you can try 
> something like the following:
> 
> LAYER
>    NAME "your_layer"
>    CLASSEXPRESSION "divi"  # set the attribute field name here
>    DATA ...
>    CLASS
>      EXPRESSION "A"
>      STYLE
>        COLOR 255 0 0  # red
>      END
>    END
>    CLASS
>      EXPRESSION "AA"
>      STYLE
>        COLOR 0 255 0  # green
>      END
>    END
>    ...
> END
> 
> You will have to add the other stuff you need in the layers, classes and 
> styles to make them complete, but this should give you the idea of how 
> to do it.
> 
> EXPRESSION /^A/   # will select all "divi" starting with "A..."
> EXPRESSION /^A|^B/ # will select all "divi" starting with "A..." or "B..."
> 
> -Steve W.
> 
> 


------_=_NextPart_001_01C46B01.7DAC04C2
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12">
<TITLE>CLASS is like a CASE statement, it will stop after one is =
selected????</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Hi all </FONT>
</P>

<P><FONT SIZE=3D2>this is the newbie again</FONT>
</P>

<P><FONT SIZE=3D2>Stephen wrote</FONT>
<BR><FONT SIZE=3D2> "CLASS is like a CASE statement, it will =
stop after one is selected"</FONT>
</P>

<P><FONT SIZE=3D2>on an explanation he told me some weeks ago... I =
tried with this but it doesn't work for me.</FONT>
<BR><FONT SIZE=3D2>I have one layer with some class on it and  ALL =
are done. Where have I the error???</FONT>
</P>

<P><FONT SIZE=3D2>.map:</FONT>
</P>

<P>        <FONT SIZE=3D2>LAYER # =
Provincias polygon layer begins here</FONT>
<BR>        =
        <FONT =
SIZE=3D2>NAME    =
        provPerimeter</FONT>
<BR>        =
        <FONT =
SIZE=3D2>DATA        provin</FONT>
<BR>        =
        <FONT =
SIZE=3D2>STATUS      OFF</FONT>
<BR>        =
        <FONT =
SIZE=3D2>TYPE        POLYGON</FONT>
<BR>        =
        <FONT =
SIZE=3D2>GROUP           =
Provincias</FONT>
<BR>        =
       =20
<BR>        =
        <FONT =
SIZE=3D2>PROJECTION</FONT>
<BR>        =
        <FONT SIZE=3D2>  =
"init=3Depsg:23030"</FONT>
<BR>        =
        <FONT SIZE=3D2>END</FONT>
</P>

<P>        =
        <FONT =
SIZE=3D2>METADATA</FONT>
<BR>        =
        =
        <FONT =
SIZE=3D2>"title" "Provincias"</FONT>
<BR>        =
        <FONT =
SIZE=3D2>END     </FONT>
<BR>        =
       =20
<BR>        <FONT =
SIZE=3D2>     LABELITEM "Divi"</FONT>
<BR>        <FONT =
SIZE=3D2>     CLASSITEM    =
"Case1"</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>CLASS</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>EXPRESSION =
"D1"</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>COLOR 99 154 =
206</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>OUTLINECOLOR =
0 0 0</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>END</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>CLASS</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>EXPRESSION =
"D2"</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>COLOR 255 154 =
99</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>OUTLINECOLOR =
0 0 0</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>END</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>CLASS</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>EXPRESSION =
"D3"</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>COLOR 99 255 =
206</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>OUTLINECOLOR =
0 0 0</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>END</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>CLASS</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>EXPRESSION =
"D4"</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>COLOR 255 101 =
99</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>OUTLINECOLOR =
0 0 0</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>END</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>CLASS</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>EXPRESSION =
"D5"</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>COLOR 255 207 =
99</FONT>
<BR>        =
        =
        =
        <FONT SIZE=3D2>OUTLINECOLOR =
0 0 0</FONT>
<BR>        =
        =
        <FONT SIZE=3D2>END</FONT>
<BR><FONT SIZE=3D2>END</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=3D2>-----Mensaje original-----</FONT>
<BR><FONT SIZE=3D2>De: Stephen Woodbridge [<A =
HREF=3D"mailto:woodbri at swoodbridge.com">mailto:woodbri at swoodbridge.com</=
A>]</FONT>
<BR><FONT SIZE=3D2>Enviado el: viernes, 02 de julio de 2004 =
14:49</FONT>
<BR><FONT SIZE=3D2>Para: Javier Castillejo Montes</FONT>
<BR><FONT SIZE=3D2>CC: Mapserver-users at lists.gis.umn.edu</FONT>
<BR><FONT SIZE=3D2>Asunto: Re: [Mapserver-users] Different colors in =
different layers</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Same idea, but you have to know the range of colors =
that are possible </FONT>
<BR><FONT SIZE=3D2>and create a CLASS for each COLOR then use an =
EXPRESSION to select the </FONT>
<BR><FONT SIZE=3D2>color instead of the "divi" so if your =
values were like 1 .. 100 and you </FONT>
<BR><FONT SIZE=3D2>wanted assign colors based on 1-10, 11-20, 21-30, =
..., 91-100</FONT>
</P>

<P><FONT SIZE=3D2>CLASS</FONT>
<BR><FONT SIZE=3D2>   EXPRESSION ([divi] < 11)</FONT>
<BR><FONT SIZE=3D2>   STYLE</FONT>
<BR><FONT SIZE=3D2>     COLOR ...</FONT>
<BR><FONT SIZE=3D2>   END</FONT>
<BR><FONT SIZE=3D2>END</FONT>
<BR><FONT SIZE=3D2>CLASS</FONT>
<BR><FONT SIZE=3D2>   EXPRESSION ([divi] < 21)</FONT>
<BR><FONT SIZE=3D2>   STYLE</FONT>
<BR><FONT SIZE=3D2>     COLOR ...</FONT>
<BR><FONT SIZE=3D2>   END</FONT>
<BR><FONT SIZE=3D2>END</FONT>
<BR><FONT SIZE=3D2>...</FONT>
<BR><FONT SIZE=3D2>CLASS</FONT>
<BR><FONT SIZE=3D2>   # no expression is like an default: and =
will catch</FONT>
<BR><FONT SIZE=3D2>   # anything not caught above.</FONT>
<BR><FONT SIZE=3D2>   STYLE</FONT>
<BR><FONT SIZE=3D2>     COLOR ...</FONT>
<BR><FONT SIZE=3D2>   END</FONT>
<BR><FONT SIZE=3D2>END</FONT>
</P>

<P><FONT SIZE=3D2>CLASS is like a CASE statement, it will stop after =
one is selected.</FONT>
</P>

<P><FONT SIZE=3D2>-Steve W.</FONT>
</P>

<P><FONT SIZE=3D2>Javier Castillejo Montes wrote:</FONT>
</P>

<P><FONT SIZE=3D2>> Oh thanks that looks fine... </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> and... how about do it dinamically (i think =
it's said "on the fly"), I mean,</FONT>
<BR><FONT SIZE=3D2>> I have the color I need on a database field... =
how can I assign the "divi"</FONT>
<BR><FONT SIZE=3D2>> to his color at runtime.</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> Javier C.</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> -----Mensaje original-----</FONT>
<BR><FONT SIZE=3D2>> De: Stephen Woodbridge [<A =
HREF=3D"mailto:woodbri at swoodbridge.com">mailto:woodbri at swoodbridge.com</=
A>]</FONT>
<BR><FONT SIZE=3D2>> Enviado el: viernes, 02 de julio de 2004 =
14:14</FONT>
<BR><FONT SIZE=3D2>> Para: Javier Castillejo Montes</FONT>
<BR><FONT SIZE=3D2>> CC: Mapserver-users at lists.gis.umn.edu</FONT>
<BR><FONT SIZE=3D2>> Asunto: Re: [Mapserver-users] Different colors =
in different layers</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> Javier Castillejo Montes wrote:</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>>>Hi!</FONT>
<BR><FONT SIZE=3D2>>> </FONT>
<BR><FONT SIZE=3D2>>>First of all  Im very bad english =
writer (its not my language so please</FONT>
<BR><FONT SIZE=3D2>>>forgive my mistakes</FONT>
<BR><FONT SIZE=3D2>>> </FONT>
<BR><FONT SIZE=3D2>>>and im really new at mapserver</FONT>
<BR><FONT SIZE=3D2>>> </FONT>
<BR><FONT SIZE=3D2>>>I'll try to make myself clear</FONT>
<BR><FONT SIZE=3D2>>> </FONT>
<BR><FONT SIZE=3D2>>>I have differents layers and one of then is =
a layer a field , this field</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> has</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>>>various divisions(layer 1)  and inside =
each division(divi A) there is one</FONT>
<BR><FONT SIZE=3D2>>>more division (layer 1) (divi AA,AB,AC). Can =
anybody tell me how can I put</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> a</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>>>different color for each diviA and a =
different color for divi   AA,AB,AC</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> Javier,</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> You will need to know what all the possible =
divi are then you can try </FONT>
<BR><FONT SIZE=3D2>> something like the following:</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> LAYER</FONT>
<BR><FONT SIZE=3D2>>    NAME =
"your_layer"</FONT>
<BR><FONT SIZE=3D2>>    CLASSEXPRESSION =
"divi"  # set the attribute field name here</FONT>
<BR><FONT SIZE=3D2>>    DATA ...</FONT>
<BR><FONT SIZE=3D2>>    CLASS</FONT>
<BR><FONT SIZE=3D2>>      EXPRESSION =
"A"</FONT>
<BR><FONT SIZE=3D2>>      STYLE</FONT>
<BR><FONT SIZE=3D2>>        COLOR =
255 0 0  # red</FONT>
<BR><FONT SIZE=3D2>>      END</FONT>
<BR><FONT SIZE=3D2>>    END</FONT>
<BR><FONT SIZE=3D2>>    CLASS</FONT>
<BR><FONT SIZE=3D2>>      EXPRESSION =
"AA"</FONT>
<BR><FONT SIZE=3D2>>      STYLE</FONT>
<BR><FONT SIZE=3D2>>        COLOR =
0 255 0  # green</FONT>
<BR><FONT SIZE=3D2>>      END</FONT>
<BR><FONT SIZE=3D2>>    END</FONT>
<BR><FONT SIZE=3D2>>    ...</FONT>
<BR><FONT SIZE=3D2>> END</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> You will have to add the other stuff you need =
in the layers, classes and </FONT>
<BR><FONT SIZE=3D2>> styles to make them complete, but this should =
give you the idea of how </FONT>
<BR><FONT SIZE=3D2>> to do it.</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> EXPRESSION /^A/   # will select all =
"divi" starting with "A..."</FONT>
<BR><FONT SIZE=3D2>> EXPRESSION /^A|^B/ # will select all =
"divi" starting with "A..." or =
"B..."</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> -Steve W.</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C46B01.7DAC04C2--



More information about the MapServer-users mailing list