[mapserver-users] Set Colors with php_mapscript in 3.7

Daniel Morissette morissette at dmsolutions.ca
Mon Nov 11 21:50:24 EST 2002


Nicol Hermann wrote:
> 
> how can i set colors with php_mapscript in Mapserver 3.7?
> I am using the following code with 3.6.3 which works fine.
> 
> $classObj = ms_newClassObj($layer);
> $classObj -> set("color", $map->addColor(255, 255, 0) );
> $classObj -> set("outlinecolor", $map->addColor(0, 0, 0) );
> 
> The same code causes a fatal error with the CVS Version of 3.7:
> 

The way colors are handled internally has changed in 3.7, and as a
result of that the internal color table, and the addColor() method that
was used to allocate colors are gone.  

They have been replaced with instances of colorObj everywhere a color is
used in MapScript and you set the colors using the 
$color->setRGB(r, g, b) method.

Now, another change in 3.7 that affects you is that the $class->color
parameter is gone, as well as most of the class parameters that have
been moved to a new styleObj.  This was to get rid of the duplication of
parameters for overlaycolor, overlaysymbol, etc.

So in 3.7 your code would become something like this:

 $classObj = ms_newClassObj($layer);
 $style = ms_newStyleObj($classObj);
 $style->color->setRGB(255, 255, 0);
 $style->outlinecolor->setRGB(0, 0, 0);

Note that 3.6 mapfiles using the old CLASS COLOR parameters are still
going to load properly for backwards compatibility, but in MapScript you
must use the new styleObj to assign your colors.

Finally, the file mapserver/mapscript/php3/README in the 3.7 nightly
builds (or from CVS) is usually up to date with respect to the state of
PHP MapScript.  So you should refer to it to find out what else has
changed in PHP MapScript in 3.7.  I also placed a live copy of this file
that will be automatically updated every morning from CVS at:
http://www2.dmsolutions.ca/mapserver/dl/mapserver-3.7-dev-PHP-MAPSCRIPT-README.txt

Daniel
--
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------




More information about the mapserver-users mailing list