Ignore:
Timestamp:
02/07/07 10:31:43 (13 years ago)
Author:
lawrence
Message:

ows stack now has the equivalent support for DIF to
the older wsgi stack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/geoUtilities.py

    r2643 r2680  
    1010 
    1111class Bounding: 
    12     ''' Separated out because this is NDG specific really ''' 
     12    ''' Separated out because this is NDG specific really  
     13    NB needs to support multiple bounding boxes properly and doesn't ... ''' 
    1314    def __init__(self,elem,entity='stubB',getter=wrapGetText): 
    1415        '''Parse a data entity and load a bounding box ''' 
     
    2930        West=getter(elem,match[entity]['West']) 
    3031        East=getter(elem,match[entity]['East']) 
     32        self.boxes=[] 
     33        self.nboxes=0 
     34         
    3135        self.set([North,West,East,South]) 
    32         #except: 
    33         #    self.box=None 
    34  
     36         
    3537    def set(self,box): 
    3638        try:  
    37             self.box=[geoString2float(i) for i in box] 
     39            self.boxes.append([geoString2float(i) for i in box]) 
     40            self.nboxes+=1 
    3841        except: 
    39             self.box=None 
    40  
    41     def toHTML(self): 
    42         return self.toHTMLbox() 
    43      
     42            pass 
     43         
    4444    def toHTMLbox(self): 
    45         if self.box is not None: 
    46             html='''<table><tbody><tr><td colspan="2" align="center">%s</td></tr> 
     45        if self.nboxes!=1: 
     46            return '<p> Record includes %s bounding boxes </p>'%self.nboxes 
     47        else: 
     48            return '''<table><tbody><tr><td colspan="2" align="center">%s</td></tr> 
    4749                      <tr><td>%s,</td><td>&nbsp;%s</td></tr> 
    4850                      <tr><td colspan="2" align="center">%s</td></tr> 
    49                     </tbody></table>'''%tuple(self.box) 
    50         else: 
    51             html='' 
    52         return html 
     51                    </tbody></table>'''%tuple(self.boxes[0]) 
    5352 
    5453class TimeCoverage: 
     
    7069        return self.data[i] 
    7170         
    72 import unittest 
    73 class TestCase(unittest.TestCase): 
    74      
    75     def testgeoString2float(self): 
    76         self.assertEqual(geoString2float('12S'),-12.0) 
    77          
    78     def testBounding(self): 
    79         bbox=Bounding('dummy') 
    80         bbox.set(['15N','12W','12E','15S']) 
    81         y=bbox.toHTML() 
    82          
    83     def testTimeCoverage(self): 
    84         ''' Test time coverage class ''' 
    85         tc=TimeCoverage(('01-01-2001','01-02-2001','Complete')) 
    86         print tc 
    87         self.assertEqual(tc[2],'Complete') 
    88      
    89 if __name__=="__main__": 
    90     unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.