[Mapserver-users] php clone() doesn't cut it

Sean Gillies sgillies at frii.com
Tue Feb 3 18:11:09 EST 2004


On Feb 3, 2004, at 3:20 PM, Charlton Purvis wrote:

> Hi, folks:
>
> I finally rewrote a raster querying kludge that works well.  At least,
> in my opinion.  But I learned the hard way that I can't count on php's
> mapObj clone().
>
> If you try to clone() a mapObj and save it to a new variable, 
> everything
> will be OK *unless* you try to manipulate the layers.  I could not get
> something like the following sequence to work:
>
> (1) original mapObj's first layer is STATUS ON
> (2) draw the original map (first layer is drawn)
> (3) clone the original map to cloneMap
> (4) set the clonMap's first layer to STATUS OFF
> (5) draw the clone map (first layer is off)
> (6) now draw the original map *** first layer is OFF !!! ***
>
> It is a PHP fault.  Something along the lines of the paragraph that
> begins "Want to allow . ." from
> http://www.masterofweb.com/item/102/catid/10.
>
> So my workaround was to save my current map state to a .map, and then
> create a new mapObj based on that .map.
>
> Just trying to save others some tears and premature graying.
>
> Charlton
>
>

Charlton,

As far as I know, PHP MapScript's clone() is using the code in 
mapcopy.c.
and this is working OK for the Python MapScript:

Python 2.3 (#6, Sep 14 2003, 15:46:16)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> from mapscript import *
 >>> mapobj = mapObj('tests/test.map')
 >>> clone = mapobj.clone()
 >>> mapobj.getLayer(0)
<C layerObj instance at _000e8000_p_layerObj>
 >>> clone.getLayer(0)
<C layerObj instance at _000f1000_p_layerObj>
 >>> mapobj.getLayer(0).status
2
 >>> clone.getLayer(0).status
2
 >>> mapobj.getLayer(0).status = MS_OFF
 >>> mapobj.getLayer(0).status
0
 >>> clone.getLayer(0).status
2

I don't understand what would be different with PHP, unless it's not
using MapServer's map cloning after all.

Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies




More information about the mapserver-users mailing list