MapServer / MapServer-import

3 stars 2 forks source link

LayerObj data #1055

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: ivano.picco@aqupi.tk Date: 2004/11/11 - 11:26

Hi!,
I try to load data from a SDE connection by perl mapscript. I try to get data
from different SDE layer using only one layerObj and changing only data attribute:
[...CUT...]
$layer->close();
$layer->{data}="ctr.regione,SHAPE";
$layer->open();
[...CUT...]
Unfortunately it does not work, it returns the same data as the old connection,
like if the layerObj->data were the old one. 
I try with Oracle Spatial and it works.
Could you confirm this bug?
thanks a lot,
Ivano Picco
tbonfort commented 12 years ago

Author: ivano.picco@aqupi.tk Date: 2004/11/11 - 12:21

Obviously I use mapserver version 4.4.0-beta2. is it a connection pooling problem?
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/11/15 - 20:20

Sean here.  I've made change to msCopyLayer so that no layerinfo is copied.
Cloned layers have no layerinfo and begin in a closed state.
tbonfort commented 12 years ago

Author: ivano.picco@aqupi.tk Date: 2004/11/17 - 22:14

Hi, 
I don't understand, I have changed only the data value.Do you mean that when I
close connection the function free all layer info? Then when I open a new
connection, Does the open() load again all info?
Thanks,
Ivano Picco
tbonfort commented 12 years ago

Author: hobu Date: 2004/11/18 - 17:09

Ivano,

That is essentially correct.  However, the "connection" part has been separated
from the "layerinfo" part in SDE.  Both are cached.  They are cached in slightly
different ways.  

There are two use cases going on here.  One is to take an existing layer and
just change the data member.  Under SDE, this will not work as intended because
the layerinfo cache already has information regarding the old DATA stuff, and it
is not sensitive to changes from MapScript.  

The second use case is to take the layerObj and execute its clone() method. 
This will copy all of the pertinent elements of the layerObj into a new
instance.  When it does this, it *does not* copy over the opened layerinfo
stuff.  When you then set the DATA member, not having the layerinfo stuff forces
the cache to look up its information (which it won't find because this DATA
member is now new) and draw the appropriate layer.  This is the bug that Sean
was refering to in his reply.

So, for clarification, here's how you should get what you want:
$mynewlayer = $layer->clone();
$mynewlayer->{data}="ctr.regione,SHAPE";
$mynewlayer->open();

Howard
tbonfort commented 12 years ago

Author: hobu Date: 2004/11/18 - 17:13

oops.  I forgot to add that the clone() method was just fixed in CVS to adhere
to this behavior.  The code I outlined above will work in beta3, but not in beta2.
tbonfort commented 12 years ago

Author: hobu Date: 2004/12/07 - 18:20

The clone() method was fixed just before 4.4 was released to deal with this
situation.