I think there is a copy-paste bug in OWSLib/trunk/owslib/wms.py (rev. 1698).
All 3rd level nested layers have set wrong parent in ContentMetadata - 3rd
level layers will have set 1st level layer as their parent, and not 2nd
level layer (grandfather instead of father). Here is a patch for better
illustration:
--- OWSLib/trunk/owslib/wms.py 2010-11-21 14:26:57.153503998 +0100
+++ OWSLib/trunk/owslib/wms_patched.py 2010-11-21 14:27:13.000000000
+0100
@@ -112,11 +112,11 @@
for subelem in elem.findall('Layer'):
subcm=ContentMetadata(subelem, cm)
self.contents[subcm.id]=subcm
#added another layer of nesting - should really be
recursive though...
for subsubelem in subelem.findall('Layer'):
- subsubcm=ContentMetadata(subsubelem, cm)
+ subsubcm=ContentMetadata(subsubelem, subcm)
self.contents[subsubcm.id]=subsubcm
#exceptions
self.exceptions = [f.text for f \
in
self._capabilities.findall('Capability/Exception/Format')]
I have also one suggestion. Seems like there is no way (if I don't count
giving such names to the layers, that they would be ordered in python
dictionary) to get order of layers (their elements in XML). With normal
layers, their order wasn't probably never needed, but now if you can have
layer consisting of another layers, then in most use cases their order
should be fixed (same as order in XML). So I would suggest to add position
attribute to the ContentMetadata, something like this:
--- OWSLib/trunk/owslib/wms.py 2010-11-15 14:26:57.153503998 +0100
+++ OWSLib/trunk/owslib/wms_patched.py 2010-11-22 08:59:46.000000000
+0100
@@ -111,12 +111,12 @@
self.contents[cm.id]=cm
for subelem in elem.findall('Layer'):
subcm=ContentMetadata(subelem, cm)
self.contents[subcm.id]=subcm
#added another layer of nesting - should really be
recursive though...
- for subsubelem in subelem.findall('Layer'):
- subsubcm=ContentMetadata(subsubelem, cm)
+ for position, subsubelem in
enumerate(subelem.findall('Layer')):
+ subsubcm=ContentMetadata(subsubelem, subcm, position)
self.contents[subsubcm.id]=subsubcm
#exceptions
self.exceptions = [f.text for f \
in
self._capabilities.findall('Capability/Exception/Format')]
@@ -302,12 +302,13 @@
"""
Abstraction for WMS layer metadata.
Implements IContentMetadata.
"""
- def __init__(self, elem, parent=None):
+ def __init__(self, elem, parent=None, position=None):
self.parent = parent
+ self.position = position
if elem.tag != 'Layer':
raise ValueError('%s should be a Layer' % (elem,))
for key in ('Name', 'Title'):
val = elem.find(key)
if val is not None:
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community