[Mapserver-users] Coloring Problem

Norbert Thieme norbert.thieme at ilmenau.baw.de
Tue May 4 00:23:07 PDT 2004


Sam Choudry schrieb:
> Hello,
> 
>     Here is the same old problem still not solved. I want to change the
> color of my area layer "nal-blk" according to user input. For that I am
> using the code:
> 
> 	if($r!='' && $g!='' && $b!='')
> 	{
> 		$layer = $map->getlayerbyname("nal-blks");
> 		$class = $layer->getclass(0);
> 		$layer->open($map->shapepath);
> 		$index = findindex($r,$g,$b);
> 		$class->set('color',index);
> 	}
> 
> 
> 
>     I am using a function I received from one of the list members,
> 	
> 	function findindex($r,$g,$b)
>  	{
>    		GLOBAL $map;
>    
>    		$r1=(int) $r;
>    		$g1=(int) $g;
>    		$b1=(int) $b;
>  
>    		for($i=-10;$i<0;$i++)
>     		{
>       			$col=$map->getColorByIndex($i);
>       
>       			$tr=$col->red;
>       			$tg=$col->green;
>       			$tb=$col->blue;
> 
>       			if(($r1 == $tr) && ($g1 == $tg) && ($b1 == $tb))
>        			{
>          			$in=$i;
>          			break;      
>        			}  
>      		}
>    		$in=$in+1;
>    		return($in);
>  	}
> 
> 
>   The Error message are :
> 	Warning: Wrong parameter count for open() in 
> c:\inetpub\wwwroot\php\nalbari.php on line 21
> 

Hi,

The layer->open() function don't except any paramters I think so simply 
leave it empty.

> 	Fatal error: Property 'color' does not exist in this object.
> 	in c:\inetpub\wwwroot\php\nalbari.php on line 23
> 

The next message say that there is no color in the class-object. So you 
can't change it and I just had a look in the mapscript docs - there seem 
to be no color-object. If I don't have missed something there will be no 
way to change that but I think there should be one.

I hope someone more experienced knows a workaround or can point us to 
the right objects/functions or docs.

Regards,
Norbert

> 
>   The Map File snippet is also provided:
> 
> 	LAYER 			#DISTRICT BLOCKS#
> 	  NAME "nal-blks"
> 	  DATA nal-blks
> 	  STATUS ON
> 	  TYPE POLYGON
> 	  CLASS
> 	   NAME '0'
> 	   COLOR 219 250 253
> 	   OUTLINECOLOR 154 181 250
> 	  END
> 	END        
> 
>   What can be the possile solution to this? Regards,
> 
> 					Samuzzal
> 
> 
> _____________________________________________________________
> Linux.Net -->Open Source to everyone
> Powered by Linare Corporation
> http://www.linare.com/
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 
> 




More information about the MapServer-users mailing list