Changeset 4772


Ignore:
Timestamp:
08/01/09 16:03:06 (11 years ago)
Author:
domlowe
Message:

adding support for z dimension in WCS requests - axisdescriptions currently stubs

Location:
cows/trunk/cows
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/pylons/wcs_controller.py

    r4769 r4772  
    167167            raise InvalidParameterValue('Layer %s does not support SRS %s' % (layerName, srs)) 
    168168        times= self.getOwsParam('time') 
     169         
     170        kwargs={} 
     171        for axis in layerObj.axisDescriptions: #TODO - axisDescriptions attribute 
     172            log.debug('axis: %s'%axis.name) 
     173            axisvalues=self.getOwsParam(axis.name, default=None) 
     174            log.debug('values: %s'%axisvalues) 
     175            if axisvalues: 
     176                values=tuple(float(x) for x in axisvalues.split(',')) 
     177                if len(values)==1: 
     178                    values=(values[0], values[0],) #set min and max to be equal if single value 
     179                kwargs[axis.name]=values     
     180         
    169181#                 
    170         filepath = layerObj.getCvg(bbox, time=times) #TODO, refactor so is more flexible (e.g. not just netcdf) 
     182        filepath = layerObj.getCvg(bbox, time=times, **kwargs) #TODO, refactor so is more flexible (e.g. not just netcdf) 
    171183        fileToReturn=open(filepath, 'r') 
    172184        mType='application/cf-netcdf' 
  • cows/trunk/cows/service/imps/csmlbackend/wcs_csmllayer.py

    r4769 r4772  
    7878            raise ValueError 
    7979 
     80class AxisDescription(object): 
     81    """ represents an axisDescription from the rangeSet (see wcs 1.0.0 describe coverage) """ 
     82    def __init__(self): 
     83        self.name='air_pressure' 
     84        self.label='air_pressure' 
     85        self.values=[10, 30, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 850, 950,1000] 
    8086 
    81  
    82  
    83 class CSMLCoverage(): #TODO: define ICoverage 
     87class CSMLCoverage(object): #TODO: define ICoverage 
    8488    """ represents a WCS Coverage. Implements ICoverage """ 
    8589     
     
    100104        self.wgs84BBox = bb 
    101105        self.featureInfoFormats = ['text/html'] 
     106        self.axisDescriptions = [AxisDescription()] 
    102107     
    103108    def getBBox(self, crs): 
     
    109114        return self.wgs84BBox 
    110115     
    111     def getCvg(self, bbox, time=None, crs=None, response_crs=None): 
     116    def getCvg(self, bbox, time=None, crs=None, response_crs=None, **kwargs): 
    112117        """ 
    113118        Creates a subset of the layer in a particular CRS and set of 
     
    134139        if None in [lon, lat, t]: 
    135140            #TODO need to return a suitable wcs error. 
    136             print 'warning, could not get correct axis info' 
     141            log.debug('warning, could not get correct axis info') 
    137142            #best guess! 
    138143            if t is None: 
     
    152157            else: 
    153158                sel[t]=time 
    154         #z is the 4th axis (eg height or pressure). 
    155         #NOTE, need to decide whether bounding box is of form: x1,y1,z1,x2,y2,z2 or x1,y1,x2,y2,z1,z2 
    156         #currently the latter is implemented.  
    157              
    158         if len(boundingbox)  == 6: 
     159                 
     160        #z is the 4th axis/band (eg height or pressure or wavelength) requested via kwargs as defined in the rangeset.axisDescriptions. 
     161        for kw in kwargs: 
     162            log.debug(kw) 
     163            log.debug(self._feature.getAxisLabels()) 
    159164            for ax in self._feature.getAxisLabels(): 
    160165                if ax not in [lat, lon, t]: 
    161                     #must be Z   
    162                     z=str(ax) 
    163                     sel[z]=(boundingbox[4], boundingbox[5]) 
    164              
    165              
    166         axisNames=self._feature.getAxisLabels() 
     166                    if ax == kw: 
     167                        z=str(ax) 
     168                        sel[z]=(kwargs[kw]) 
     169                        log.debug('Z axis: %s'%z)      
    167170        ################################################################## 
    168          
     171        log.debug('Final selection being made to the csml api %s'%str(sel)) 
    169172        filename = extractToNetCDF(self._feature, sel) 
    170173        return filename 
Note: See TracChangeset for help on using the changeset viewer.