[Mapserver-users] Rendering mapscript style modifications

Wheaton, William D. wdw at rti.org
Wed Mar 17 16:43:34 EST 2004


Eric--

Thanks for the response and suggestion.  Unfortunately, no joy.

I've now tried:

  $image=$map->prepareImage();
  $layer->draw($map, $image);
  $image=$map->draw();

 $image_url=$image->saveWebImage(MS_PNG,1,1,0);

And:

  $image=$map->prepareImage();
  $image=$map->draw();
  $layer->draw($map, $image);

 $image_url=$image->saveWebImage(MS_PNG,1,1,0);

In both cases, I get this error:
Fatal error: Object has an invalid _handle_ property in
/var/www/htdocs/els/mapscript_test.phtml on line 43

The error refers to the $layer->draw($map, $image) line...Is that an error
that helps decipher the problem?  I searched the list and didn't find
anything on that error...Many thanks for helping out!

Bill.


-----Original Message-----
From: Eric Bridger [mailto:eric at gomoos.org] 
Sent: Wednesday, March 17, 2004 4:15 PM
To: Wheaton, William D.
Cc: 'mapserver-users at lists.gis.umn.edu'
Subject: Re: [Mapserver-users] Rendering mapscript style modifications


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