[Mapserver-users] PHPmapscript 4, color

Dylan Keon keon at nacse.org
Thu Jul 3 17:29:22 EDT 2003


Erich,

Check out the Migration Guide page on the Wiki.  There are examples of 
color handling, as well as other changes to make when moving from 3.5 to 
4.0.  http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?MigrationGuide


This should help (copied from the Wiki page):

   Most class parameter definitions are now handled by the new style
   object.

     For example,

         $classObj->set('color', $map->addColor(255,255,0));
         $classObj->set('size', 18);

     is now implemented as

         $style = ms_newStyleObj($classObj);
         $style->color->setRGB(255,255,0);
         $style->set('size', 18);


--Dylan


Erich Schroeder wrote:

> Hi,
>   I'm confused in how I should be rewriting some phpmapscript for changing 
> from version 3.5 to 4.
> 
> In my application it looks to see if a polygon shapefile showing modern 
> distribution of a taxon exists, and if so adds it as a layer. It then 
> checks to see if the user wanted it to show, and if not turns the layer 
> off.
> 
>  The old script looks like:
> 
> //Check if modern distribution is present, and add
>  if (file_exists("mammal/$TaxonLower.shp")) {
>    $distpresent = TRUE;
>    $layer = ms_newLayerObj($map);
>    $layer->set("data","mammal/$TaxonLower");
>    $layer->set("name","moderndist");
>    $layer->set("type",MS_LAYER_POLYGON);
>    $layer->set("status",MS_ON);
>    if ($drawdist == "n") {$layer->set("status",MS_OFF);}
>    $distcolor = $map->addColor(232,151,97);
>    $class = ms_newClassObj($layer);
>    $class->set("name","ModernDistribution");
>    $class->set("symbol",0);
>    $class->set("color",$distcolor);
>    $ok = $map->moveLayerUp(3);
>    $ok = $map->moveLayerUp(3);
>    $img = $map->draw();
>  } //end of modern dist
> 
> And now of course it chokes on the    
>     $distcolor = $map->addColor(232,151,97);
> line.
> 
> Am I supposed to now have a line like:
> 
> $class->setRGB(232,151,97);
> 
> Erich





More information about the mapserver-users mailing list