SWIG mapscript request/bug?
Sean Gillies
sgillies at FRII.COM
Tue Jan 25 15:20:53 PST 2005
On Jan 25, 2005, at 4:05 PM, Ryan, Adam wrote:
>> -----Original Message-----
>> From: Sean Gillies [mailto:sgillies at frii.com]
>> Sent: Tuesday, January 25, 2005 2:48 PM
>> To: Ryan, Adam
>> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
>> Subject: Re: SWIG mapscript request/bug?
>>
>>
>> On Jan 25, 2005, at 3:28 PM, Ryan, Adam wrote:
>>
>>> Hi. I'd like to make a request. In using python mapscript I find
>>> that a
>>> layer's index property is unchanged after using
>> map.moveLayerUp/Down.
>>> Shouldn't the index values of the two layers that are swapped be
>>> swapped
>>> themselves?
>>>
>>> Is this a bug that I should report?
>>>
>>> Cheers,
>>>
>>> Adam
>>
>> Adam,
>>
>> A MapServer mapObj has an array of layerObjs and also an array of
>> indexes of these layerObjs in drawing order. It is this second array
>> that is modified by moveLayerUp/Down. Same situation for the other
>> mapscripts including PHP. It's not a bug, just the way that
>> MapServer
>> is designed.
>>
>> cheers,
>> Sean
>>
>> --
>> Sean Gillies
>> sgillies at frii dot com
>> http://users.frii.com/sgillies
>>
>
> Hey Sean, thanks for the reply.
>
> Maybe you can lend a suggestion. I want to manipulate the draw order
> using
> a list of layer names from the client. I'd like to do this:
> ...
> curI = 0
> for layerName in layerList:
> layerO = mapO.getLayerByName(layerName)
> while layerO.index > curI: mapO.moveLayerUp( layerO.index )
> curI += 1
> ...
> The problem, if I understand it, is that the layer index is indeed
> being
> moved up in the drawing order, but the index values don't change.
> Thus, my
> while statement runs forever.
>
> I see there are get/setLayersDrawingOrder methods but how much work is
> it to
> set them up?
>
> Thanks again,
>
> Adam
>
Check out mapObj::getLayerOrder() and mapObj::setLayerOrder(). I was
going to point you this document
http://users.frii.com/sgillies/projects/mapscript/python.html
but then realized that I've neglected to document those methods. For
their usage, look at tests of the MapLayersTestCase in
mapscript/python/tests/cases/maptest.py. getLayerOrder() returns a
tuple of ints and setLayerOrder takes a tuple of ints. These methods
work directly on the mapObj's drawing order and will be much faster
than moving layers up and down.
cheers,
Sean
--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies
More information about the MapServer-users
mailing list