Creation of layer object in Python Maps cript

Sean Gillies sgillies at FRII.COM
Thu Oct 28 17:38:59 EDT 2004


On Oct 28, 2004, at 12:07 PM, Ryan, Adam wrote:

>> -----Original Message-----
>> From: Sean Gillies [mailto:sgillies at frii.com]
>> Sent: Thursday, October 28, 2004 10:15 AM
>> To: Ryan, Adam
>> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
>> Subject: Re: Creation of layer object in Python Maps cript
>>
>>
>> On Oct 28, 2004, at 11:03 AM, Ryan, Adam wrote:
>>
>>>> -----Original Message-----
>>>> From: Bill Hudspeth [mailto:bhudspeth at EDAC.UNM.EDU]
>>>> Sent: Thursday, October 28, 2004 8:56 AM
>>>> To: MAPSERVER-USERS at LISTS.UMN.EDU
>>>> Subject: [UMN_MAPSERVER-USERS] Creation of layer object in Python
>>>> Mapscript
>>>>
>>>>
>>>> Hello,
>>>>
>>>> I want to write new map layers on the fly in my scripting. I have
>>>> found the reference to "new layerObj()" in the
>> documentation, but am
>>>> unsure of how to write the exact syntax. Haven't had any luck with
>>>> "new_layer=layerObj(mapObj)".
>>>>
>>>> Any help greatly appreciated.
>>>>
>>>> Bill
>>>>
>>>
>>> Hi Bill,
>>>
>>> I'm working on the same thing 'bout now.
>>> For me, this crashes Python:
>>>
>>>     layerO = mapscript.layerObj(mapO)
>>>    layerO = mapscript.layerObj()
>>>     mapO.insertLayer(layerO)
>>> But this works OK:
>>>
>>>
>>>
>>> However, if I then check layerO.index, I get 1634300513.
>> That's a lot
>>> of
>>> layers.
>>>
>>> If I check mapO.getLayersDrawingOrder(), I get _30fc8200_p_int.  Is
>>> this a
>>> typemap issue?
>>>
>>> If I try layerO.promote() or layerO.demote(), I'm told those methods
>>> don't
>>> exist.
>>>
>>> I'm still trying to figure this one out.  Let me know if
>> you make any
>>> headway.
>>>
>>> Adam
>>>
>>>
>>
>> Which version of mapserver are y'all using?
>>
>> Sean
>>
>
> OK,
>
> The new layer is appended so it's index is  mapO.numlayers-1 even
> though
> it's index parameter is foobar.
>
> And although promote and demote don't seem to be in mapscript.py, we
> can use
> mapO.moveLayerDown(index), so that's cool...
>
> Adam
>
>

Adam,

Promote and demote are gone for good.  It's better design to use
methods of the container.

In the next beta I'll make sure that the index of a new layer is
initialized to something sensible.  Meanwhile, I cannot reproduce
your problem with creating a new layerObj instance with a mapObj
argument.  I have a test case for this in the unit tests and it
always passes.  Please report the error that occurs and I'll work
on it.

cheers,
Sean


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



More information about the mapserver-users mailing list