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

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

First code to support a GUI for python based searching through the
discovery WS interface. Includes some refactoring of the browse code
to support multiple entities (i.e. DIF etc). (NB: browse still
wont work properly until we get the security stuff working ok).

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, South,West, East]]
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 South: %s <br/>
32                                Limit West: %s <br/>
33                                Limit East: %s <br/>   
34                                </p>'''%self.box
35                else:
36                        html='No bounding box available'
37                return html     
Note: See TracBrowser for help on using the repository browser.