[mapserver-users] One layer filled with 3 colors

Steve Lime Steve.Lime at dnr.state.mn.us
Tue Apr 22 18:41:56 EDT 2008


If in your database you transformed the various values of zona into colors (e.g. stored the color in a column called zona_color)
then you could do:

LAYER
   DATA "the_geom from car_marccata"
   CLASS
      STYLE
        COLOR [zona_color]
      END
    END
END

You'd need to set those up ahead of time, or at least create a color lookup table and do the join in the DATA statement.

Steve
-- 

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-259-5473

>>> On 4/22/2008 at 10:38 AM, in message
<9c2e09570804220838h2d9075c8q1379c764d90eee0e at mail.gmail.com>, "Emilio Ponce"
<yosoycore at gmail.com> wrote:
> This code takes me now to a new one question:
> 
> Is there a way to assign colours dynamically? I'm wondering  if
> mapserver is able to detect the different options of the column
> 'zona', and then use random palette colours to represent these
> automatically, without having to set COLOR for each one manually. It
> can be useful because every column has different options.
> 
> Thank you guys,
> 
> 
> 
> 2008/4/22 Emilio Ponce <yosoycore at gmail.com>:
>> Thanks Stephen!
>>  I've found the solution with your idea, is very similar to your code:
>>
>>
>>         LAYER
>>
>>         ...
>>
>>                 DATA "the_geom from car_marccata"
>>                 CLASSITEM "zona"
>>
>>                 CLASS
>>                         EXPRESSION "FORA"
>>
>>                         COLOR 143 81 8
>>                 END
>>
>>                 CLASS
>>                         EXPRESSION "MAR"
>>
>>                         COLOR 0 154 239
>>                 END
>>
>>                 CLASS
>>                         EXPRESSION "CATA"
>>
>>                         COLOR 223 223 223
>>                 END
>>
>>         END
>>
>>
>>  Regards,
>>
>>
>>  2008/4/22 Stephen Woodbridge <woodbri at swoodbridge.com>:
>>
>>
>> >
>>  > Emilio Ponce wrote:
>>  >
>>  > > Hi everyone,
>>  > >
>>  > > I'm trying to paint one layer with 3 different colors, depending on
>>  > > one field called 'zona' that is a column of the table stored at a
>>  > > postGIS database. I'm doing this in the layer:
>>  > >
>>  > >                ...
>>  > >                STATUS DEFAULT
>>  > >                CONNECTIONTYPE postgis
>>  > >                CONNECTION "host=**** dbname=**** user=**** password=****
>>  > port=****'"
>>  > >                DATA "the_geom from car_marccata"
>>  > >
>>  > >                FILTER "zona='FORA'"
>>  > >                CLASS
>>  > >                        COLOR 143 81 8
>>  > >                END
>>  > >
>>  > >                FILTER "zona='MAR'"
>>  > >                CLASS
>>  > >                        COLOR 0 154 239
>>  > >                END
>>  > >
>>  > >                FILTER "zona='CATA'"
>>  > >                CLASS
>>  > >                        COLOR 223 223 223
>>  > >                END
>>  > >
>>  > > It doesn't works.. I've tried different strategies but I haven't found
>>  > > the problem yet. Does anyone knows what's wrong?
>>  > >
>>  > > Thanks!
>>  > >
>>  > >
>>  >
>>  >  Try this:
>>  >
>>  >                 STATUS DEFAULT
>>  >                 CONNECTIONTYPE postgis
>>  >                 CONNECTION "host=**** dbname=**** user=**** assword=****
>>  > port=****'"
>>  >
>>  >                 DATA "the_geom from car_marccata"
>>  >                 CLASSITEM "zona"
>>  >
>>  >                 CLASS
>>  >                         EXPRESSION ([zona] = 'FORA')
>>  >
>>  >                         COLOR 143 81 8
>>  >                 END
>>  >
>>  >                 CLASS
>>  >                         EXPRESSION ([zona] = 'MAR')
>>  >
>>  >                         COLOR 0 154 239
>>  >                 END
>>  >
>>  >                 CLASS
>>  >                         EXPRESSION ([zona] = 'CATA')
>>  >
>>  >
>>  >                         COLOR 223 223 223
>>  >                 END
>>  >
>>
>>
>>
>>  --
>>  Emilio
>>
> 
> 



More information about the mapserver-users mailing list