[Mapserver-users] Problem Colouring Layers

Mahalakshmi Narayanan mhln25@yahoo.com
Fri, 23 Apr 2004 00:30:19 -0700 (PDT)


I think you are using MapScript 3.6.  In this we can
change the colours to only one of those which is
already present in the mapfile.  To find the colour
you can use this fn below which will find out the
index of the color that you want based on rgb values
passed, 


function findindex($r,$g,$b)
 {
     
   $r1=(int) $r;
   $g1=(int) $g;
   $b1=(int) $b;
 
   for($i=0;$i<$customrange+3;$i++)
    {
     $col=$gpoMap->getColorByIndex($i);
      $tr=$col->red;
      $tg=$col->green;
      $tb=$col->blue;

      if(($r1 == $tr) && ($g1 == $tg) && ($b1 == $tb))
       {
         $in=$i;
         break;      
       }  
     }
   
   return($in);
 }

--
Then set the colour by :

$in=findindex($r1,$g1,$b1);
$col=$gpoMap->getColorByIndex($in);

--

Let me know if this works..

With regards,
Mahalakshmi Narayanan 

--- Sam Choudry <samuzzal@linux.net> wrote:
> Dear group,
> 
>         Thank yo very much for showing me the way to
> sove the 
> problem regarding windows 2000 Server. Although it
> still
> remains but I hope I will be able to solve it.
> 
> 	This time I have another problem. I am trying to
> colour 
> one of my layers using Php-Mapscript function using
> these code
> 
> <?php	.
> 	.
> 	$r = $_POST["R"];
> 	$g = $_POST["G"];
> 	$b = $_POST["B"];
> 
> 	if($r != '' && $g != '' && $b != '')
> 	{
> 	 $coloured_layer =
> $map->getlayerbyname("nal-blks");
> 	 $coloured_layer->set("status", MS_ON);
> 	 $class = $coloured_layer->getClass(0);
> 	 $color = $map->addColor($r,$g,$b);
> 	 $class->set("color", $color);
> 	}
> 	.
> 	.
> 	$image=$map->draw();
> 	$image_url=$image->saveWebImage();
> 	.
> 	.  
> ?>
> <html>
> ..
> 	R<INPUT TYPE=TEXT NAME="R" size = "3">
> 	G<INPUT TYPE=TEXT NAME="G" size = "3">
> 	B<INPUT TYPE=TEXT NAME="B" size = "3">
> ..
> </html>
> 
> But the following error message is displayed as I
> try 
> it in the IE.
> 
> Fatal error: Call to undefined function: addcolor() 
> in c:\inetpub\wwwroot\color.php on line 24
> 
> What could be the possible reason? May I have some 
> help from the group.
> 
> 					Samuzzal
> 
>
_____________________________________________________________
> Linux.Net -->Open Source to everyone
> Powered by Linare Corporation
> http://www.linare.com/
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users@lists.gis.umn.edu
>
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users



	
		
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash
_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users