[Mapserver-users] Different colors in different layers

Stephen Woodbridge woodbri at swoodbridge.com
Fri Jul 2 05:48:30 PDT 2004


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.
> 
> 




More information about the MapServer-users mailing list