[GRASS-SVN] r47345 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 2 06:18:04 EDT 2011
Author: sudeepsingh
Date: 2011-08-02 03:18:04 -0700 (Tue, 02 Aug 2011)
New Revision: 47345
Modified:
grass-addons/grass7/gui/wxpython/wx.wms/parse.py
grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Hierarchial Displaying of layers functionality added, working
Modified: grass-addons/grass7/gui/wxpython/wx.wms/parse.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/parse.py 2011-08-02 09:52:17 UTC (rev 47344)
+++ grass-addons/grass7/gui/wxpython/wx.wms/parse.py 2011-08-02 10:18:04 UTC (rev 47345)
@@ -2,6 +2,7 @@
import re
from urllib2 import Request, urlopen, URLError, HTTPError
+
def parsexml(xml):
xmltext = xml
@@ -41,25 +42,30 @@
-def getLayers(xml):
- soup = BeautifulStoneSoup(xml)
- print 'dfs starting'
- #print soup
- dfs(soup," ")
- print 'dfs ending'
-
-def dfs(root, indent):
- if not hasattr(root, 'contents'):
- #print root.string
- return
- else:
- #print root.name
- if(root.name == 'layer'):
- print indent + root.name
- children = root.contents
- for child in children:
- dfs(child,indent+" ")
- return
+def populateLayerTree(xml,LayerTree, layerTreeRoot):
+ f = open('cacheGetCapabilities.xml','w')
+ f.write(xml)
+ f.close()
+
+ f = open('cacheGetCapabilities.xml','r')
+ xml = f.read()
+ #print xml
+ soup = BeautifulSoup(xml)
+ dfs(soup,LayerTree, layerTreeRoot)
+
+def dfs(root,LayerTree, ltr):
+ if not hasattr(root, 'contents'):
+ #print root.string
+ return
+ else:
+ id = ltr
+ #print root.name
+ if(root.name == 'layer'):
+ names = root.findAll('name')
+ id = LayerTree.AppendItem(ltr,names[0].string)
+ print names[0].string
+ children = root.contents
+ for child in children:
+ dfs(child, LayerTree, id)
+ return
-
-
Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-02 09:52:17 UTC (rev 47344)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-02 10:18:04 UTC (rev 47345)
@@ -5,7 +5,7 @@
import wx
from wxPython.wx import *
from urllib2 import Request, urlopen, URLError, HTTPError
-from parse import parsexml, isServiceException, getLayers
+from parse import parsexml, isServiceException, populateLayerTree
from WMSMapDisplay import NewImageFrame
from addserver import AddServerFrame
from passwordPopUp import PasswordPopUpFrame, check
@@ -118,10 +118,11 @@
response = urlopen(req)
xml = response.read()
#self.statusbar.SetStatusText(xml)
- getLayers(xml)
+
reslist = parsexml(xml)
- for res in reslist:
- self.LayerTree.AppendItem(self.layerTreeRoot, res)
+ populateLayerTree(xml,self.LayerTree, self.layerTreeRoot)
+ #for res in reslist:
+ # self.LayerTree.AppendItem(self.layerTreeRoot, res)
#self.Layers.SetValue(st)
#print xml
self.LayerTree.Expand(self.layerTreeRoot)
More information about the grass-commit
mailing list