http://trac.gispython.org/lab/ticket/215
It collects 'roots' of layers into owslib.wms.WebMapService's layers
attribute (there may be any number of such layers, so it is a list),
and each ContentMetadata has attribute children that stores list of
children.
Of course, there may be a better name than 'layers' for the
WebMapService attribute.
Code is also available at my GitHub repository, branch tree:
https://github.com/monoid/owslib/tree/tree
--
Ivan Boldyrev
diff --git a/owslib/wms.py b/owslib/wms.py
index 3d5b0ab..b044cb9 100644
--- a/owslib/wms.py
+++ b/owslib/wms.py
@@ -110,14 +110,18 @@ class WebMapService(object):
#recursively gather content metadata for all layer elements.
#To the WebMapService.contents store only metadata of named layers.
def gather_layers(parent_elem, parent_metadata):
+ layers = []
for index, elem in enumerate(parent_elem.findall('Layer')):
cm = ContentMetadata(elem, parent=parent_metadata, index=index+1)
+ layers.append(cm)
if cm.id:
if cm.id in self.contents:
raise KeyError('Content metadata for layer "%s" already exists' % cm.id)
self.contents[cm.id] = cm
- gather_layers(elem, cm)
- gather_layers(caps, None)
+ cm.children = gather_layers(elem, cm)
+ return layers
+
+ self.layers = gather_layers(caps, None)
#exceptions
self.exceptions = [f.text for f \
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community