[Mapserver-dev] [Fwd: Re: [Mapserver-users] Changing Colors in Map !!]

Stephen Woodbridge woodbri at swoodbridge.com
Wed Jul 21 11:51:28 EDT 2004


Steve, Daniel, et al,

Have you been following this thread. This is not the first time we have 
had this discussion with users. It is a major hassle and waste of 
peoples time. There was some discussion about having mapserver just do 
this behind the scenes, ie: to load explicitly defined colors into the 
look color table before implicitly defined colors like in rasters ate up 
all the color slots.

something like ...

1) load COLOR statements first
2) load symbol colors next
3) load raster colors last

It has at least one bug # 306, there might be others that are related to 
this.

It would be great is someone had time to fix this issue before the next 
release.

-Steve W.


-------- Original Message --------
Subject: Re: [Mapserver-users] Changing Colors in Map !!
Date: Wed, 21 Jul 2004 08:18:12 -0700
From: ANDY CANFIELD <andy_canfield at hotmail.com>
To: woodbri at swoodbridge.com

Ok I had the same problem and this is how I fixed it. Just protecting the
layers with an inline point doesn't work if that point isn't in the viewed
area of the gif that gets cut. Here is what I did. I took and made a 
polygon
shapefile. In that shapefile is a single polygon that covers the entire 
area
that can be viewed. In my case two US states. I then make copies of that
polygon. One for each color I want to preserve. They are all just stacked
right on top of each other. The file has one field called "SAVE" in it I 
put
the name of the color I want to save IE "GREEN" "BLUE" "LIGHT_BLUE" etc 
it's
just to give you something to query off of. Then in the map file I do
classes off of expressions that way I only use one layer for this whole
thing. Each class ends up being one of those polygons in the shape file. 
The
topmost class which for me is actually one of the middle classes in the
layer I shade the same color as the map. This color preserving layer is my
first layer. That way no matter where they go on my map that all needed
colors are always present. Here is an example layer with nine colors. Also
this layer must always be on or it won't work. It's tedious and a headache
but it only uses one layer and since the points I need to protect are
thematic in nature I can't have them washing out or it ruins the whole 
point
of having the map in the first place as it is tracking alarms on pieces of
system eqpt.

#this layer protects against the bug that causes colors to wash out of
#dynamiclly created symbols
		LAYER
			NAME "Color_Saver"
			TYPE POLYGON
			STATUS ON
			DATA "Color_Saver"
			CLASSITEM "SAVE"

			CLASS
				EXPRESSION /RED/
				STYLE
					COLOR 255 0 0
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /GREEN/
				STYLE
					COLOR 0 255 0
					SYMBOL 0
				END
			END
			#this one hides the others as it is the same color as the map
                        #and this color saving layer is the first layer on
the map
			CLASS
				EXPRESSION /TOP_MOST/
				STYLE
					COLOR 245 245 240
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /YELLOW/
				STYLE
					COLOR 255 255 0
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /PURPLE/
				STYLE
					COLOR 255 0 255
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /BLACK/
				STYLE
					COLOR 0 0 0
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /BROWN/
				STYLE
					COLOR 156 97 66
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /GREY/
				STYLE
					COLOR 198 199 198
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /LIGHT_BLUE/
				STYLE
					COLOR 82 215 247
					SYMBOL 0
				END
			END
			CLASS
				EXPRESSION /BLUE/
				STYLE
					COLOR 0 0 255
					SYMBOL 0
				END
			END
		END	#end of layer color saver


>From: Stephen Woodbridge <woodbri at swoodbridge.com>
>To: Satyajit <satyajit.gantayat at aurovision.com>
>CC: 'ANDY CANFIELD' <andy_canfield at hotmail.com>,  
>girish.shewale at aurovision.com,  mapserver-users at lists.gis.umn.edu
>Subject: Re: [Mapserver-users] Changing Colors in Map !!
>Date: Wed, 21 Jul 2004 08:08:23 -0400
>
>Hi Satyajit,
>
>Since the problem is that you are overflowing the browser lookup table 
>there is not guarantee that this method will work. When I did this I have a 
>few colors that were changing so I only used the dummy layers to protect 
>them.
>
>I also notice that you have a RASTER layer. It is possible that this is the 
>layer that is using up all the colors. Try adding the following to any 
>RASTER type LAYER
>   PROCESSING "COLOR_MATCH_THRESHOLD=3"
>
>http://lists.gis.umn.edu/pipermail/mapserver-dev/2003-February/000177.html
>
>and see if that helps.
>
>Satyajit wrote:
>
>>
>>Hi Steve and Andy,
>>            I tried Steve's method of adding dummy layers to my map file.
>>But I don't see any significant improvement in the "changing color"
>>problem. My map still behaves the same. I am using a lot of colors in my
>>map. Since I have some 39 layers in my map, there are more than 40
>>unique colors used in the map (outline colors also count). Do I have to
>>use these 40 colors in the dummy layers i.e. 40 dummy layers have to be
>>created ?? I tried using only 10 dummy layers with only one class in
>>each of them. Will my problem be solved if I use a single dummy layer
>>with 40 classes added in it ? The legend problem has been solved. As Steve 
>>used HTML legend stuff, I
>>am also using a HTML legend stuff. Hence I have control over the legend.
>>I can choose which layers to be shown in the legend.
>>
>>I am attaching my map file with this mail. The part of map file which
>>Steve has given in his mail ( which is also in the bug list at this
>>place http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=306) seems to be
>>of a different version. When I tried to copy the same to my map file it
>>didn't work. I just added a "Style" object in my "Class" object with
>>only a color entity in it. Please have a look at the map file.
>>
>>Waiting for your replies.
>>
>>Regards
>>~sat.
>>
>>-----Original Message-----
>>From: mapserver-users-admin at lists.gis.umn.edu
>>[mailto:mapserver-users-admin at lists.gis.umn.edu] On Behalf Of ANDY
>>CANFIELD
>>Sent: Monday, July 19, 2004 6:50 PM
>>To: woodbri at swoodbridge.com; satyajit.gantayat at aurovision.com
>>Cc: girish.shewale at aurovision.com; mapserver-users at lists.gis.umn.edu
>>Subject: Re: [Mapserver-users] Changing Colors in Map !!
>>
>>
>>Yes, I believe there is a way to do what you want. I have a legend on
>>the side of my maps that I generate on the fly by looping through the 
>>layers
>>of the map and adding each layer to the legend as the loop progresses as
>>check boxes with the layer name so the user can turn off or on the layers.
>>
>>This allows the legend to be dynamic so no matter what the layers are in
>>any map I always get a uniformly formatted legend with no code changes.
>>
>>I have a cosmetic layer much like the layer you are describing that I
>>use to copy for placing geocoded points on the map. The users are 
>>geocoding
>>from multiple text files so I want different colored points for each file 
>>so
>>they can compare the results of the files. That's why I use copies of that 
>>cosmetic layer so I can use it's symbols and only have to change the
>>color.
>>
>>I don't want the users to have access to these cosmetic layer copies
>>that are created on the fly. So I make that the first layer and my loop
>>through the layers starts at layer 1 rather than layer 0 so the first 
>>layer
>>never shows up in the legend. You could do the same thing with as many
>>cosmetic or contruction layers as you wanted just be sure to start your 
>>loop one
>>beyond the last "invisible" layer.
>>
>>
>>
>>>From: Stephen Woodbridge <woodbri at swoodbridge.com>
>>>To: Satyajit <satyajit.gantayat at aurovision.com>
>>>CC: Girish <girish.shewale at aurovision.com>,        MapServer List 
>>><mapserver-users at lists.gis.umn.edu>
>>>Subject: Re: [Mapserver-users] Changing Colors in Map !!
>>>Date: Mon, 19 Jul 2004 08:16:59 -0400
>>>
>>>You raise a good issue. I don't usually display legends, but have used 
>>>HTML
>>>Legend stuff that allows you a lot of control over your legends and I
>>
>>think
>>
>>>you can eliminate layers on a named basis. which might work for you.
>>>
>>>Please add a comment to the bug referenced below about this problem. I 
>>>hope
>>>that the developers will tackle this problem but it helps to have a 
>>>complete picture of the problem and issues and their work arounds.
>>>
>>>-Steve W
>>>
>>>Satyajit wrote:
>>>
>>>
>>>>Hi Steve,
>>>>      Thanks a lot for the info. I have not tried your method yet but
>>
>>
>>>>shall try it very soon. And let you know the result. I have a question
>>
>>
>>>>in my mind though. When we add a dummy layer in our map and add classes 
>>>>to it ( to preserve the colors ..as you said), the layer will be shown 
>>>>in the legend in the browser. That dummy layer in the legend might 
>>>>confuse the end user as that layer's features won't be easily visible in 
>>>>the map and of course that layer doesn't have much meaning to it. Is 
>>>>there any way by which I can add that layer in my map file with all the 
>>>>classes but still make it invisible in the legend ? Thanks a lot again 
>>>>steve. Shall get back to you after modifying my map
>>
>>
>>>>file.
>>>>
>>>>~sat
>>>>
>>>>Stephen Woodbridge wrote:
>>>>
>>>>
>>>>
>>>>>I think I may have created a feature and inserted a one pixel dot on 
>>>>>the map that gets covers by later layers. Play with it and if you have 
>>>>>a problem let me know and I can dig through old mapfiles and find out
>>>>
>>>>how
>>>>
>>>>
>>>>>I did it.
>>>>
>>>>
>>>>Here are some examples of preserving the colors in a symbol that were
>>>>changing. The big problem with this approach is that it uses up a lot
>>
>>of
>>
>>>>layers, so you might try using one layer with lots of classes, but I'm
>>
>>
>>>>not
>>>>sure it that will work.
>>>>
>>>>The bug for this problem is:
>>>>   http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=306
>>>>I just updated it with this information.
>>>>
>>>>## dummy layer to protect symbol colors from changing
>>>>   LAYER
>>>>     NAME "color_symbol"
>>>>     STATUS DEFAULT
>>>>     TYPE point
>>>>     TRANSFORM false
>>>>     FEATURE
>>>>       POINTS
>>>>         1 1
>>>>       END
>>>>     END
>>>>     CLASS
>>>>       SYMBOL "color_symbol"
>>>>       COLOR 0 0 0
>>>>     END
>>>>   END
>>>>## protect other colors
>>>>   LAYER
>>>>     NAME blue
>>>>     STATUS DEFAULT
>>>>     TYPE point
>>>>     TRANSFORM false
>>>>     FEATURE
>>>>       POINTS
>>>>         1 1
>>>>       END
>>>>     END
>>>>     CLASS
>>>>       COLOR 0 0 255
>>>>     END
>>>>   END
>>>>   LAYER
>>>>     NAME green
>>>>     STATUS DEFAULT
>>>>     TYPE point
>>>>     TRANSFORM false
>>>>     FEATURE
>>>>       POINTS
>>>>         1 1
>>>>       END
>>>>     END
>>>>     CLASS
>>>>       COLOR 8 206 107
>>>>     END
>>>>   END
>>>>
>>>>
>>>>
>>
>>Satyajit wrote :
>>
>>Dear Users,
>>             Thanks a million to all the users who gave me their valuable
>>suggestions while building site. Without the help of this group it would
>>have been impossible for me to build such a nice site ( I hope you too
>>find it nice). Though my map is smoothly running, I have a strange
>>problem in my hands. The data layers in my map are changing colors while
>>browsing through them. The change in color happens randomly at some zoom
>>levels. At times the colors of the data layer match with the colors in
>>the map. You can check out this site http://203.199.114.111/newham/ .
>>Normally the data is shown in the color specified in the map file. But
>>when I try to zoom in the data layers seem to take the colors of
>>different other data layers. And it create a whole lot of confusion. I
>>can't really find any reason for this. Any ideas ?   Sat
>>Sr. Specialist - GIS
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/







More information about the mapserver-dev mailing list