[Mapserver-users] Rendering mapscript style modifications

Eric Bridger eric at gomoos.org
Wed Mar 17 16:14:47 EST 2004


William,
I remember going thru the same conceptual confusion when I first started
with mapscript.  I use Perl mapscript but the issues are the same.
I don't have the time to check the docs so take the following with a
grain of salt.
The fundemental difference is: mapscript methods which take an Image
object and those that don't.

I believe that the call to $map->draw() takes care of "preparing" the GD
image for drawing and then draws all the layers in the map file.

You should switch to using:
$img = $map->prepareImage()
And then using the draw methods which take an $img paramter.
E.g. $layer->draw($map, $img).

It may be, that you could use $img = $map->draw() and then use
$layer->draw($map, $img) afterwards. That might work.

My method requires a lot more work, in the sense of getting all the
layers in the map file and drawing them one by one.

HTH
Eric


On Wed, 2004-03-17 at 15:09, Wheaton, William D. wrote:
> Hello all:
> 
> I'm having a basic conceptual problem understanding the interaction between
> the modification of a layer in php/mapscript and then rendering those
> modifications...I've searched far and wide in the e-mail archives, but I
> guess I'm just missing some basic concept here.  
> 
> Given a .map file with several layers, then:
> 
> 1) $map = ms_newMapObj(file.map);
> 
> For the layer I want to change, the .map file looks like this:
> LAYER
>      PROJECTION
>          "proj=latlong"
>          "ellps=clrk66"
>       END
>       CONNECTIONTYPE postgis
>       NAME "Respondents"
>       GROUP "Base Data"
>       CONNECTION "user=xxxx dbname=xxx password=xxxx"
>       DATA "the_geom from resp"
>       STATUS DEFAULT
>       TYPE POINT
>       METADATA
>             LYRNAME "Respondents"
>       END
>   CLASS
>          STYLE
> 		       COLOR 255 0 0
> 		 END
>    END
> END
> 
> 2) Then, through php/mapscript, grab this layer and change its style:
> 
> $layer=$map->getlayerbyname('Respondents');
> 
> 3) Modify the style of this layer:
> 
> $class=ms_newClassObj($layer);
> $style=ms_newStyleObj($class);
> $style->color->setRGB(0,255,0);
> $class->set("status", MS_ON);
> $layer->set("status", MS_ON);
> $image=$map->draw();
> $image_url=$image->saveWebImage(MS_PNG,1,1,0);
> 
> 4) With this, the map gets drawn with the layer symbology as specified in
> the .map file, not with the modifications made above in the mapscript...
> 
> So, I have a basic problem understanding how modifications to a layer in a
> mapscript file get rendered on the map...Is it order?  Am I missing a
> something?
> 
> Many thanks in advance for any help.  I'm at my wits end!
> 
> _______________________________________________
> 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