Changeset 4685


Ignore:
Timestamp:
19/12/08 11:27:58 (11 years ago)
Author:
domlowe
Message:

more merging

Location:
cows/branches/wcsmerge/cows
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cows/branches/wcsmerge/cows/model/wcs.py

    r4581 r4685  
    2020    def __init__(self, CRSs=[], description=None, formats=[],supportedCRSs=[],timelimits=[],**kw): 
    2121        super(WcsDatasetSummary, self).__init__(**kw) 
    22  
    2322        self.CRSs = CRSs 
    2423        self.description=description 
     
    2726        self.timeLimits=timelimits 
    2827 
    29  
    30 class FormattedURL(object): 
     28class CoverageDescription(WcsDatasetSummary):  
    3129    """ 
    32     @ivar format 
    33     @type format: str 
    34     @ivar onlineResource 
    35     @type onlineResource: OnlineResource object 
    36  
     30    Further extends WCSDatasetSummary to provide a fuller coverage description 
     31    used in DescribeCoverageResponse. Building up this extra information may require more  
     32    work on the servers part, hence this is separate class from the simpler WcsDatasetSummary. 
    3733    """ 
    38     def __init__(self, format, onlineResource): 
    39         self.format = format 
    40         self.onlineResource = onlineResource 
    41  
    42  
    43 class Dimension(Domain): 
    44     """ 
    45     Use Domain attributes where possible. 
    46      
    47     @ivar multipleValues 
    48     @type multipleValues: boolean (default False) 
    49     @ivar nearestValue 
    50     @type nearestValue: boolean (default False) 
    51     @ivar current 
    52     @type current: boolean (default False) 
    53  
    54     """ 
    55     def __init__(self, multipleValues=False, nearestValue=False, 
    56                  current=False, *kw): 
    57         super(Dimension, self).__init__(**kw) 
    58          
    59         self.multipleValues = multipleValues 
    60         self.nearestValue = nearestValue 
    61         self.current = current 
    62  
    63  
    64 # 
    65 #!TODO: Other objects referenced by WmsDatasetSummary 
    66 # 
     34    def __init__(self, **kw): 
     35        super(CoverageDescription, self).__init__(**kw) 
     36#       TODO, add DescribeCoverage extensions 
  • cows/branches/wcsmerge/cows/pylons/wcs_controller.py

    r4634 r4685  
    2020 
    2121from cows.model.wms import Dimension 
    22 from cows.model.wcs import WcsDatasetSummary 
     22from cows.model.wcs import WcsDatasetSummary, CoverageDescription 
    2323from cows.model import PossibleValues, WGS84BoundingBox, BoundingBox, Contents 
    2424from cows.pylons import ows_controller 
     
    4444        ['GetCoverage', 'DescribeCoverage']) 
    4545    validVersions = ['1.0.0'] 
     46     
    4647 
    4748    #------------------------------------------------------------------------- 
     
    7879 
    7980        """ 
    80  
    81         ows_controller.addOperation('GetCoverage')  
     81        self.datasetSummaries=[] 
     82        ows_controller.addOperation('GetCoverage') 
     83        ows_controller.addOperation('DescribeCoverage')   
    8284        featureInfoFormats = Set() 
    8385 
     
    111113                                 ) 
    112114 
    113  
    114  
    115115            c.capabilities.contents.datasetSummaries.append(ds) 
    116116 
    117      
     117             
    118118    def _getLayerParam(self, paramName='coverage'): 
    119119        """ 
     
    132132            #layerName = layerName.split(',')[0] 
    133133            raise InvalidParameterValue( 
    134                 'Multi-layer GetLegend requests are not supported', 'layers') 
     134                'Multi-coverage getCoverage requests are not supported', 'coverage') 
    135135        try: 
    136136            layerObj = self.layers[layerName] 
    137137        except KeyError: 
    138             raise InvalidParameterValue('Layer %s not found' % layerName, 
     138            raise InvalidParameterValue('coverage %s not found' % layerName, 
    139139                                        paramName) 
    140140 
     
    169169        times= self.getOwsParam('times') 
    170170#                 
    171         #------------------------------------------------------- 
    172         #!TODO: Minimum and maximum values 
    173 #        filepath = self._retrieveSubset(layerObj, srs, bbox, restoredDimValues) 
    174         filepath = layerObj.getCvg(bbox, time=times) 
     171        filepath = layerObj.getCvg(bbox, time=times) #TODO, refactor so is more flexible (e.g. not just netcdf) 
    175172        fileToReturn=open(filepath, 'r') 
    176173        mType='application/cf-netcdf' 
     
    179176        return response.write(fileToReturn.read()) 
    180177             
     178    def DescribeCoverage(self): 
     179        c.descriptions=[] 
     180        requestCvg=self.getOwsParam('coverage') 
     181#        super(WCSController, self).GetCapabilities() 
     182        #TODO, the bounding box may include a Z dimension in WCS. 
     183        log.debug(requestCvg) 
     184        for cvgName, coverage in self.layers.items(): 
     185            log.debug(cvgName) 
     186            if cvgName == requestCvg: 
     187                log.debug('found match') 
     188                wgs84BBox = WGS84BoundingBox(coverage.wgs84BBox[:2], 
     189                                         coverage.wgs84BBox[2:]) 
     190                # Get CRS/BBOX pairs 
     191                bboxObjs = [] 
     192                for crs in coverage.crss: 
     193                    bbox = coverage.getBBox(crs) 
     194                    bboxObjs.append(BoundingBox(bbox[:2], bbox[2:], crs=crs)) 
     195                     
     196                # Create the enhanced Dataset summary for thic coverage 
     197                #TODO, the bounding box may include a Z dimension in WCS. 
     198                #TODO, what extra information does this require over the normal dataset summary                 
     199                ds = CoverageDescription(identifier=coverage.id, 
     200                                     titles=coverage.title, 
     201                                     boundingBoxes=[BoundingBox([bbox[0],bbox[1]], [bbox[2],bbox[3]], 
     202                                     crs='CRS:84')],  
     203                                     description=coverage.description, 
     204                                     abstracts=coverage.abstract, 
     205                                     formats=['application/cf-netcdf'], 
     206                                     supportedCRSs=coverage.crss,  
     207                                     timelimits=coverage.timeLimits 
     208                                     ) 
     209 
     210                c.descriptions.append(ds) 
     211        response.headers['content-type']='text/xml' 
     212        return response.write(c.descriptions) 
     213 
    181214 
    182215    def GetFeatureInfo(self): #TODO: This should be DescribeCoverage 
  • cows/branches/wcsmerge/cows/service/imps/csmlbackend/wcs_csmllayer.py

    r4635 r4685  
    1515log = logging.getLogger(__name__) 
    1616 
    17 from cows.model.contents import DatasetSummary 
     17from cows.model.wcs import WcsDatasetSummary 
    1818from cows.service.imps.csmlbackend.csmlcommon import CSMLLayerMapper, CSMLConnector, extractToNetCDF 
    1919 
    2020 
    21 class CSMLwcsCoverageMapper(CSMLLayerMapper): #Todo define IwcsCoverageMapper 
     21class CSMLwcsCoverageMapper(CSMLLayerMapper):  
    2222    """ 
    2323    Map keyword arguments to a collection of layers (coverages) 
     
    4747 
    4848        return title, abstract, timelimits, units, crss 
    49         
     49             
     50    def getCoverageDescription(self): 
     51        pass 
    5052         
    5153       
     
    7577            raise ValueError 
    7678 
    77 class CoverageDescription(DatasetSummary): #ToDo define ICoverageDescription? 
    78     """ 
    79     Extends DatasetSummary from cows.model.contents 
    80     """ 
    81     def __init__(self, identifier, timeDomain, crs=None, **kw): 
    82         super(CoverageDescription, self).__init__(**kw) 
    83         self.identifier=identifier 
    84         self.timeLimits=timeDomain 
    85         self.crs=crs 
     79 
    8680 
    8781 
     
    10498        self.wgs84BBox = bb 
    10599        self.featureInfoFormats = ['text/html'] 
    106          
    107     def getDescription(self): 
    108         pass 
    109100     
    110101    def getBBox(self, crs): 
  • cows/branches/wcsmerge/cows/service/imps/wms_layers.py

    r4266 r4685  
    11""" 
    22implementation of ILayerMapper, ILayer, IDimension, ILayerSlab interfaces, as defined in wms_iface.py 
    3  
     3this implementation was written to read station data. 
    44""" 
    55import os 
  • cows/branches/wcsmerge/cows/service/wcs_iface.py

    r4574 r4685  
    1 """ 
    2 The classes in this module define an interface between the OWS Pylons 
    3 server and components that provide Web Map Server layers. They extend the interfaces 
    4 defined in wxs_iface.py. 
     1"""  
     2TODO: formally describe WCS interfaces 
     3"""  
    54 
    6 The interface was designed with several requirements in mind: 
    7  - support multiple dimensions (in the WMS sense, i.e. non-geospatial dimensions). 
    8  - support multiple CRSs/SRSs 
    9  - Allow caching of horizontal slices (called layer slabs) by 
    10    dimensions and CRS to mitigate the overhead of data retreival and rendering. 
    11  - To hide how layers are actually retrieved and rendered from ows_server. 
    12  
    13 IwmsLayer instances provide dimension and CRS information to the server 
    14 and can render a legend.  A layer image is requested by a two stage 
    15 process.  First the CRS and non-geospatial dimensions are selected 
    16 through IwmsLayer to return a IwmsLayerSlab instance.  WMS images are then 
    17 retrieved through IwmsLayerSlab for a given bounding box. 
    18  
    19 This allows implementations to cache the result if it makes sense to 
    20 do so.  implementing IwmsLayer.getCacheKey() will cause the server to 
    21 cache IwmsLayerSlab objects for future use, therefore not requiring 
    22 repeated calls to IwmsLayer.getSlab().  This strategy works well with 
    23 tiling WMS clients that will make multiple GetMap requests with the 
    24 same CRS and dimension parameters. 
    25  
    26  
    27 #NOTE: FOR NOW, copy wms iface as starting point 
    28  
    29 """ 
    30  
    31 from wxs_iface import ILayer 
    32  
    33          
    34  
    35 class IwmsLayer(ILayer): 
    36     """ 
    37     An interface representing a WMS layer, based on ILayer. 
    38      
    39     @ivar legendSize: (width, height) in pixels of legend. 
    40  
    41     @ivar featureInfoFormats: A sequence of formats supported for the 
    42         self.getFeatureInfo method.  If this is None or empty GetFeatureInfo 
    43         is not supported. 
    44  
    45     @todo: Do we need minValue/maxValue? 
    46  
    47     """ 
    48  
    49  
    50     def getSlab(self, crs, dimValues=None, renderOpts={}): 
    51         """ 
    52         Creates a slab of the layer in a particular CRS and set of 
    53         dimensions. 
    54  
    55         @param crs: The coordinate reference system. 
    56         @param dimValues: A mapping of dimension names to dimension values 
    57             as specified in the IDimension.extent 
    58         @param renderOpts: A generic mapping object for passing rendering 
    59             options 
    60         @return: An object implementing ILayerSlab 
    61  
    62         """ 
    63         raise NotImplementedError 
    64  
    65     def getCacheKey(self, crs, dimValues=None, renderOpts={}): 
    66         """ 
    67         Create a unique key for use in caching a slab. 
    68  
    69         Any unique combination of crs, dimValues and renderOpts should 
    70         produce a unique key. 
    71  
    72         The intention here is that most of the work should be done when 
    73         instantiating an ILayerSlab object.  These can be cached by the 
    74         server for future use.  The server will first call getCacheKey() 
    75         for the slab creation arguments and if the key is in it's cache 
    76         it will use a pre-generated ILayerSlab object. 
    77  
    78         """ 
    79         raise NotImplementedError 
    80  
    81     def getLegendImage(self, orientation='vertical', renderOpts={}): 
    82         """ 
    83         Create an image of the colourbar for this layer. 
    84          
    85         @param orientation: Either 'vertical' or 'horizontal' 
    86         @return: A PIL image 
    87  
    88         """ 
    89         raise NotImplementedError 
    90  
    91     def getFeatureInfo(self, format, crs, point, dimValues): 
    92         """ 
    93         Return a response string descibing the feature at a given 
    94         point in a given CRS. 
    95  
    96         @param format: One of self.featureInfoFormats.  Defines which 
    97             format the response will be in. 
    98         @param crs: One of self.crss 
    99         @param point: a tuple (x, y) in the supplied crs of the point 
    100             being selected. 
    101         @param dimValues: A mapping of dimension names to dimansion values. 
    102         @return: A string containing the response. 
    103  
    104         """ 
    105         raise NotImplementedError 
    106          
    107  
    108 class IwmsDimension(object): 
    109     """ 
    110     An interface representing a WMS dimension 
    111      
    112     @ivar units: The units string. 
    113     @ivar extent: Sequence of extent values. 
    114  
    115     """ 
    116     units = extent = NotImplemented 
    117  
    118 class IwmsLayerSlab(object): 
    119     """ 
    120     An interface representing a particular horizontal slice of a WMS layer. 
    121  
    122     IwmsLayerSlab objects are designed to be convenient to cache. 
    123     Ideally they should be pickleable to enable memcached support in 
    124     the future. 
    125  
    126     @ivar layer: The source IwmsLayer instance. 
    127     @ivar crs: The coordinate reference system. 
    128     @ivar dimValues: A mapping of dimension values of this view. 
    129     @ivar renderOpts: The renderOpts used to create this view. 
    130     @ivar bbox: The bounding box as a 4-tuple. 
    131  
    132     """ 
    133     layer = crs = dimValues = renderOpts = bbox = NotImplemented 
    134  
    135     def getImage(self, bbox, width, height): 
    136         """ 
    137         Create an image of a sub-bbox of a given size. 
    138  
    139         @param bbox: A bbox tuple (llx, lly, urx, ury).  bbox will 
    140             always lie within the self.layer.getBBox(self.crs) 
    141         @param width: width in pixels. 
    142         @param height: height in pixels. 
    143         @return: A PIL Image object. 
    144  
    145         """ 
    146         raise NotImplementedError 
    147  
Note: See TracChangeset for help on using the changeset viewer.