source: TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/geoUtilities.py @ 949

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/geoUtilities.py@949
Revision 949, 1.8 KB checked in by lawrence, 15 years ago (diff)

Further modifications to python discovery gui, and the entities
which support it ...

Line 
1from Utilities import wrapGetText
2class Bounding:
3    ''' Separated out because this is NDG specific really '''
4    def __init__(self,elem,entity='stubB'):
5        '''Parse a data entity and load a bounding box '''
6        match={'stubB':
7                 {'North':'dgDataSummary/dgDataCoverage/dgSpatialCoverage/BoundingBox/LimitNorth',
8                  'South':'dgDataSummary/dgDataCoverage/dgSpatialCoverage/BoundingBox/LimitSouth',
9                  'West':'dgDataSummary/dgDataCoverage/dgSpatialCoverage/BoundingBox/LimitWest',
10                  'East':'dgDataSummary/dgDataCoverage/dgSpatialCoverage/BoundingBox/LimitEast'},
11                'DIF':
12                 {'North':'Spatial_Coverage/Northernmost_Latitude',
13                  'South':'Spatial_Coverage/Southernmost_Latitude',
14                  'West':'Spatial_Coverage/Westernmost_Longitude',
15                  'East':'Spatial_Coverage/Easternmost_Longitude'}
16                }
17        North=wrapGetText(elem,match[entity]['North'])
18        South=wrapGetText(elem,match[entity]['South'])
19        West=wrapGetText(elem,match[entity]['West'])
20        East=wrapGetText(elem,match[entity]['East'])
21
22        try:
23                self.box=[float(i) for i in [North, West, East, South]]
24        except:
25                self.box=None
26               
27    def toHTML(self):
28                if self.box is not None:
29                        html='''<p>
30                                Limit North: %s <br/>
31                                Limit West: %s Limit East: %s <br/>
32                                Limit South: %s <br/>   
33                                </p>'''%self.box
34                else:
35                        html='No bounding box available'
36                return html     
37    def toHTMLbox(self):
38        print self.box
39        if self.box is not None:
40            html='''<table><tbody><tr><td colspan="2" align="center">%s</td></tr>
41                    <tr><td>%s</td?><td>%s</td></tr>
42                    <tr><td colspan="2" align="center">%s</td></tr></tbody></table>'''%tuple(self.box)
43        else:
44            html=''
45        return html
Note: See TracBrowser for help on using the repository browser.