source: TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/WMC.py @ 3484

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/WMC.py@3484
Revision 3484, 1.4 KB checked in by cbyrom, 13 years ago (diff)

Create new object, WMC, which retrieves a WMC doc, given a valid URL, and then
extracts required info for the kid templates to produce the Con Terra input
file. Adjust these templates + the selectedItems controller to interface
with new object. NB, the templates are not fully implemented, pending updates
from Con Terra on new input format.

Line 
1# python class to support methods on a WMC ... to conform with
2# renderEntity etc ...
3#
4from Utilities import *
5from geoUtilities import *
6from ETxmlView import loadET, nsdumb
7from ndgObject import ndgObject
8from ows_server.models.DocumentRetrieve import genericHTTP
9import urllib
10
11   
12class WMC:
13    ''' Simple representation of a WMC document - for use with the Con Terra interface templates '''
14    def __init__(self,url):
15       
16        '''Initialise a python wmc, retrieving it from the specified URL '''
17        x=genericHTTP(proxyServer='http://wwwcache3.rl.ac.uk:8080/')
18        wmcDoc = x.get(url)
19        self.tree = loadET(wmcDoc) 
20       
21        # now try and interpret it
22        helper=nsdumb(self.tree)
23        self.title=helper.getText(self.tree,'General/Title')
24
25        #load up information about spatial bounding box
26        #self.bbox=Bounding(self.tree,helper,entity='WMC')
27       
28        layersTree = helper.find(self.tree, 'LayerList')
29        if layersTree:
30            # add each of the layer elements
31            self.layers = layersTree.getchildren()
32           
33        self.url = url
34
35               
36
37    def getAllLayers():
38        layersData = []
39        for child in self.layers:
40            layersData.append(ET.tostring(child))
41        return ''.join(layersData)
42
43
44import unittest
45
46class TestCase(unittest.TestCase):
47    """
48    """
49
50
51if __name__=="__main__":
52    unittest.main()
53
54       
55       
Note: See TracBrowser for help on using the repository browser.