1 | from Utilities import wrapGetText |
---|
2 | class 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 |
---|