Changeset 1078

Show
Ignore:
Timestamp:
04/07/08 09:34:57
Author:
domlowe
Message:

Added a grid property to WCS 1.0.0 contents and implementations of gml grid and referenceable grid. Also added test.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OWSLib/branches/wcstemp/owslib/coverage/wcs100.py

    r1074 r1078  
    5050                    
    5151        #serviceProvider metadata 
     52        self.provider=None 
    5253        subelem=self._capabilities.find(ns('Service/')+ns('responsibleParty')) 
    53         self.provider=ServiceProvider(subelem)    
     54        if subelem is not None: 
     55            self.provider=ServiceProvider(subelem)    
    5456         
    5557        #serviceOperations metadata 
     
    245247        self.id=elem.find(ns('name')).text 
    246248        self.title =elem.find(ns('label')).text        
    247         self.keywords = [f.text for f in elem.findall(ns('keywords')+'/'+ns('keyword'))] 
    248                      
    249          
     249        self.keywords = [f.text for f in elem.findall(ns('keywords')+'/'+ns('keyword'))]         
    250250        self.boundingBoxWGS84 = None 
    251251        b = elem.find(ns('lonLatEnvelope'))  
     
    258258                    float(uc.split()[0]), float(uc.split()[1]), 
    259259                    ) 
    260                   
     260         
     261    #grid is either a gml:Grid or a gml:RectifiedGrid if supplied as part of the DescribeCoverage response. 
     262    def _getGrid(self): 
     263        if not hasattr(self, 'descCov'): 
     264                self.descCov=self._service.getDescribeCoverage(self.id) 
     265        gridelem= self.descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}RectifiedGrid') 
     266        if gridelem is not None: 
     267            grid=RectifiedGrid(gridelem) 
     268        else: 
     269            gridelem=self.descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}Grid') 
     270            grid=Grid(gridelem) 
     271        return grid 
     272    grid=property(_getGrid, None) 
     273         
    261274     #timelimits are the start/end times, timepositions are all timepoints. WCS servers can declare one or both or neither of these. 
    262275    def _getTimeLimits(self): 
     
    320333    supportedFormats=property(_getSupportedFormatsProperty, None) 
    321334         
    322          
     335           
     336#Adding classes to represent gml:grid and gml:rectifiedgrid. One of these is used for the cvg.grid property 
     337#(where cvg is a member of the contents dictionary)      
     338#There is no simple way to convert the offset values in a rectifiedgrid grid to real values without CRS understanding, therefore this is beyond the current scope of owslib, so the representation here is purely to provide access to the information in the GML. 
     339    
     340class Grid(object): 
     341    ''' Simple grid class to provide axis and value information for a gml grid ''' 
     342    def __init__(self, grid): 
     343        self.axislabels = [] 
     344        self.dimension=None 
     345        self.axes={}    
     346        if grid is not None: 
     347            self.dimension=int(grid.get('dimension')) 
     348            self.lowlimits= grid.find('{http://www.opengis.net/gml}limits/{http://www.opengis.net/gml}GridEnvelope/{http://www.opengis.net/gml}low').text.split(' ') 
     349            self.highlimits = grid.find('{http://www.opengis.net/gml}limits/{http://www.opengis.net/gml}GridEnvelope/{http://www.opengis.net/gml}high').text.split(' ') 
     350            for axis in grid.findall('{http://www.opengis.net/gml}axisName'): 
     351                self.axislabels.append(axis.text) 
     352       
     353 
     354class RectifiedGrid(Grid): 
     355    ''' RectifiedGrid class, extends Grid with additional offset vector information ''' 
     356    def __init__(self, rectifiedgrid): 
     357        super(RectifiedGrid,self).__init__(rectifiedgrid) 
     358        self.origin=rectifiedgrid.find('{http://www.opengis.net/gml}origin/{http://www.opengis.net/gml}pos').text.split() 
     359        self.offsetvectors=[] 
     360        for offset in rectifiedgrid.findall('{http://www.opengis.net/gml}offsetVector'): 
     361            self.offsetvectors.append(offset.text.split()) 
     362