[mapserver-users] Different color for each row and it'schild

Fawcett, David David.Fawcett at state.mn.us
Mon Sep 15 13:52:20 PDT 2008


It could just be the documentation, but it looks like the attribute
binding may not work at the class level.  Wrap your styling info in a
STYLE and see if that works.  

http://mapserver.gis.umn.edu/docs/reference/mapfile/style

       CLASS            
            NAME 'crews'
            # MAXSCALE 250000
            STYLE 
               COLOR [symcolor]
               BACKGROUNDCOLOR  255 255 255
               OUTLINECOLOR 255 255 255
               SYMBOL 'crewsymbol'
               SIZE 25
            END   # end of style
            LABEL
                COLOR [symcolor]
		    OUTLINECOLOR 255 255 255
                TYPE TRUETYPE
                FONT arial
                SIZE 9
                MAXSIZE 9
                MINSIZE 8
                ANTIALIAS TRUE
                POSITION UC
                PARTIALS FALSE
                FORCE TRUE
            END
        END

-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Lee Keel
Sent: Monday, September 15, 2008 3:43 PM
To: Steve Lime; mapserver-users at lists.osgeo.org; David Fawcett
Subject: RE: [mapserver-users] Different color for each row and
it'schild


Sorry....

LAYER
		NAME "crews"
		GROUP "data"
		CONNECTIONTYPE postgis
		CONNECTION "db" 		
        DATA "the_geom from (select prikey, the_geom, crewname || ' ' ||
last_name as name, color as symcolor from crews) as foo using srid=2236,
using unique prikey"
		PROCESSING "CLOSE_CONNECTION=DEFER"
		METADATA
			"wms_title" "Crews"
			"wms_group_title" "data"
			"wms_layer_title" "Crews"
		END
		PROJECTION
			"init=epsg:2236"
		END
		STATUS ON
		TYPE POINT
		# MAXSCALE 250000
        
		LABELMAXSCALE 250000
        LABELITEM  "name"  
        
        CLASS            
            NAME 'crews'
            # MAXSCALE 250000
            COLOR [symcolor]
            BACKGROUNDCOLOR  255 255 255
            OUTLINECOLOR 255 255 255
            SYMBOL 'crewsymbol'
            SIZE 25
            
            LABEL
                COLOR [symcolor]
		    OUTLINECOLOR 255 255 255
                TYPE TRUETYPE
                FONT arial
                SIZE 9
                MAXSIZE 9
                MINSIZE 8
                ANTIALIAS TRUE
                POSITION UC
                PARTIALS FALSE
                FORCE TRUE
            END
        END
        
	END

-----Original Message-----
From: Steve Lime [mailto:Steve.Lime at dnr.state.mn.us] 
Sent: Monday, September 15, 2008 3:39 PM
To: mapserver-users at lists.osgeo.org; David Fawcett; Lee Keel
Subject: RE: [mapserver-users] Different color for each row and
it'schild

Sharing the snippet of mapfile would help...

Steve

>>> On 9/15/2008 at 3:35 PM, in message
<944DCD961F4CD649BCEBB52E3C929F650270805A at usd-am-xch-01.am.trimblecorp.n
et>,
"Lee Keel" <lee_keel at trimble.com> wrote:
> David,
> 
>  
> 
> Thanks for the reply, but I can't seem to get this to work.  When I 
> change my mapfile to use this new attribute column, that layer (and
most
> all my others) go away and I get this as the response in FF:
> 
>  
> 
> <HTML>
> 
>  
> 
> <HEAD><TITLE>MapServer Message</TITLE></HEAD>
> 
>  
> 
> <!-- MapServer version 5.0.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG 
> OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT
> 
>  
> 
> =SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER 
> SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
> 
>  
> 
>  SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER 
> SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS
> 
>  
> 
> =GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
-->
> 
>  
> 
> <BODY BGCOLOR="#FFFFFF">
> 
>  
> 
> getSymbol(): Symbol definition error. Parsing error near 
> (symcolor):(line 1684)
> 
>  
> 
> </BODY></HTML>
> 
>  
> 
> I added the column to my query and add that column name, in [] to my 
> class item.  Is there something that I am missing?
> 
>  
> 
> Please note:  I have looked at the 
> http://mapserver.gis.umn.edu/development/rfc/ms-rfc-19/ page and I
think
> I understand what is required.  But now I am thinking that this is not

> in MS4W 2.2.6.  Can anyone answer if that is the case?  And if so, is 
> there another solution like this around that version?
> 
>  
> 
> Thanks in advance,
> 
> Lee
> 
>  
> 
> From: Fawcett, David [mailto:David.Fawcett at state.mn.us]
> Sent: Monday, September 15, 2008 9:51 AM
> To: Lee Keel; mapserver-users at lists.osgeo.org 
> Subject: RE: [mapserver-users] Different color for each row and it's
> child
> 
>  
> 
> I would suggest creating a column in table A to store a color value
and
> pre-populating it.  You would want to store the RGB triplet (e.g. '255
0
> 0').  I assume that you could have some sort of a stored proc that
gets
> triggered when a new record gets added.
> 
>  
> 
> Using the new attribute binding in MapServer 5, you could then just
set
> the feature color by specifying the column name in the style in your
map
> file layer definition.
> 
>  
> 
> Something like:
> 
>  
> 
> STYLE
> 
>    COLOR [myColorColumn]
> 
>    OUTLINECOLOR 0 0 0
> 
> END
> 
>  
> 
> As soon as someone kicks the MapServer site server and it restarts, I 
> suggest looking at the map file reference document under style.
> 
>  
> 
> Also, make sure that your color column is specified in the query in
your
> data statement.
> 
>  
> 
> David.
> 
> 	-----Original Message-----
> 	From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Lee Keel
> 	Sent: Monday, September 15, 2008 9:33 AM
> 	To: mapserver-users at lists.osgeo.org 
> 	Subject: [mapserver-users] Different color for each row and it's
> child
> 
> 	I had a client request something that sounds really cool, but I
don't 
> know how to do it (or if it is even possible in mapserver).
> 
> 	 
> 
> 	First, my setup:
> 
> 	I am running MS4W 2.6 on windows xp against postgis 8.2
database.  I 
> have table A that has anywhere from 4 to 35 rows.  And table B which 
> could have several hundred rows each relating back to
one
> of the rows from table A.
> 
> 	 
> 
> 	For Example:
> 
> 	TableA
> 
> 	 
> 
> 	ID                            Name
> 
> 	1                                             t
> 
> 	2                                             t2
> 
> 	3                                             t3
> 
> 	4                                             t4
> 
> 	 
> 
> 	 
> 
> 	TableB
> 
> 	ID            ta_id                      Value
> 
> 	1              1                              something
> 
> 	2              1                              something else
> 
> 	3              1                              test
> 
> 	4              2                              foo
> 
> 	5              2                              bar
> 
> 	6              3                              done
> 
> 	 
> 
> 	Now my problem:
> 
> 	The client would like to see all the rows rendered from tableA
as 
> different colors.  These colors can be random, it doesn't matter.
On
> top of this, they want to see all the associated rows in tableB as the

> same color as their parent from tableA.
> 
> 	 
> 
> 	Can I add a column to tableA and use that as a value in the
mapfile 
> for the style?  And if so, how?
> 
> 	 
> 
> 	I would greatly appreciate any help that anyone can provide.
> 
> 	 
> 
> 	Thanks in advance,
> 
> 	Lee
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the MapServer-users mailing list