Ignore:
Timestamp:
15/06/07 14:15:22 (12 years ago)
Author:
domlowe
Message:

skeleton getCoverage request working, edits to csml_utils to create separate extractToVariable, extractToNetCDF functions

Location:
TI05-delivery/ows_framework/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/wcs.py

    r2589 r2592  
    4343    """ 
    4444    def __init__(self, CRSs=[], styles=[''], dimensions={}, attribution=None, authorityURLs=[], 
    45                  identifiers=[], dataURLs=[], featureListURLs=[], 
     45                description=None, dataURLs=[], featureListURLs=[], 
    4646                 minScaleDenominator=None, maxScaleDenominator=None, **kw): 
    4747        super(WcsDatasetSummary, self).__init__(**kw) 
     
    5252        self.attribution = attribution 
    5353        self.authorityURLs = authorityURLs 
    54         self.identifiers = identifiers 
     54        self.description=description 
    5555        self.dataURLs = dataURLs 
    5656        self.featureListURLs = featureListURLs 
    5757        self.minScaleDenominator = minScaleDenominator 
    5858        self.maxScaleDenominator = maxScaleDenominator 
     59 
    5960 
    6061class Style(object): 
  • TI05-delivery/ows_framework/trunk/ows_server/development_dom.ini

    r2589 r2592  
    2222#this path has been changed in development_dom.ini (just for testing) 
    2323csml_dir = /home/dom/DDCDATA 
     24tmp_dir = %(here)s/data/tmp 
    2425ows_common_config = %(here)s/eg_ows_capabilities.xml 
    2526 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcs.py

    r2589 r2592  
    1616 
    1717from elementtree import ElementTree as ET 
    18  
    1918from ows_common import exceptions as OWS_E 
    2019from ows_common.wcs import * 
     
    2221from ows_common.domain import ValuesUnit, PossibleValues 
    2322 
    24 from ows_server.lib.csml_util import get_csml_doc 
     23from ows_server.lib.csml_util import get_csml_doc, extractToNetCDF 
     24 
    2525 
    2626 
     
    5858                                 boundingBoxes=[BoundingBox([-180,-90], [180,90], 
    5959                                                            crs='CRS:84')], 
    60                                  dimensions=dims,                
     60                                 dimensions=dims, description=feature.description.CONTENT             
    6161                                 ) 
    6262 
     
    9898 
    9999    @operation 
    100     @parameter('Version', possibleValues=['1.3.0'], required=True) 
    101     @parameter('Layers', required=True) 
    102     @parameter('Styles', required=True) 
    103     @parameter('CRS', possibleValues=['CRS:84'], required=True) 
    104     @parameter('Bbox', required=True) 
    105     @parameter('Width', required=True) 
    106     @parameter('Height', required=True) 
    107     @parameter('Format', required=True) 
    108     @parameter('Transparent') 
    109     @parameter('Bgcolor') 
    110     @parameter('Exceptions') 
     100    @parameter('Version', possibleValues=['1.1.0'], required=True) 
     101    @parameter('Identifier', required=True) 
     102    @parameter('BoundingBox') 
     103    @parameter('TimeSequence') 
     104    @parameter('Format', possibleValues=['image/netcdf'], required=True) 
     105     
     106    #TODO some more parameter to add here 
    111107    # Dimension parameters Time, Elevation, etc. are handled separately 
    112     def GetMap(self, version, layers, styles, crs, bbox, width, height, format, 
    113                transparent, bgcolor, exceptions): 
     108    def GetCoverage(self, file, version, format, identifier, boundingBox=None, timeSequence=None): 
     109         
     110        # Retrieve dataset and selected feature 
     111        dataset = get_csml_doc(file) 
     112        feature = dataset.getFeature(identifier) 
     113        if feature is None: 
     114            raise OWS_E.InvalidParameterValue('Coverage not found', 'identifier') 
    114115 
    115         dataset = get_csml_doc(file) 
     116        #set bounding box TODO 
     117        sel = dict(time=('1905-04-15T00:00:00.0' ,'1905-12-15T00:00:00.0'), longitude = (-10,10), latitude=(30,45)) 
    116118 
    117         # Support a single layer only 
    118         layer_list = layers.split(',') 
    119         if len(layer_list) > 1: 
    120             raise OWS_E.InvalidParameterValue('Only one layer supported per request', 'layers') 
    121  
    122          
     119        # Extract via CSML.subsetToGridSeries() 
     120        filename = extractToNetCDF(feature, sel) 
     121        netcdfFile=open(filename, 'r') 
     122        return Response(content=netcdfFile, mimetype='image/netcdf') 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wms.py

    r2588 r2592  
    1212from ows_server.lib.decorators import * 
    1313from ows_server.lib import grid_util, render 
    14 from ows_server.lib.csml_util import get_csml_doc, extract 
     14from ows_server.lib.csml_util import get_csml_doc, extractToVariable 
    1515import ows_server.lib.validators as V 
    1616 
     
    152152 
    153153        # Extract via CSML.subsetToGridSeries() 
    154         var = extract(feature, sel) 
     154        var = extractToVariable(feature, sel) 
    155155         
    156156        # Deduce min and max 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/csml_util.py

    r2588 r2592  
    3838    return d 
    3939 
    40  
     40#THIS FUNCTION CAN BE DELETED AFTER extractToVariable HAS BEEN TESTED: 
     41#---------------------------------------------------------------------------------------------------- 
    4142def extract(feature, sel): 
    4243    # Get temporary extract dir 
     
    5859    d.close() 
    5960    os.remove(filename) 
     61    return var 
     62#---------------------------------------------------------------------------------------------------- 
     63         
     64def extractToNetCDF(feature, sel): 
     65    """ 
     66       performs the CSML subset and returns a filename of the netcdf extract 
     67    """ 
     68    # Get temporary extract dir 
     69    extract_dir = request.environ['paste.config']['app_conf']['tmp_dir'] 
     70     
     71    # Subset the feature 
     72    (fd, filename) = tempfile.mkstemp('.nc', 'csml_wms_', extract_dir); os.close(fd) 
     73    feature.subsetToGridSeries(ncname=os.path.basename(filename), 
     74                               outputdir=os.path.dirname(filename), 
     75                               time=sel['time'] # work around for CSML bug 
     76                               #**sel 
     77                               ) 
     78    return filename 
     79         
     80def extractToVariable(feature, sel): 
     81    """ 
     82      calls extractToNetCDF to get the netcdf file, then returns a cdms variable from this file 
     83    """ 
     84    #call extractToNetCDF: 
     85    filename = extractToNetCDF(feature, sel) 
     86    d = cdms.open(filename) 
     87    #var = d(feature.name.CONTENT, squeeze=1) 
     88    # Work around for CSML bug 
     89    var = d(feature.name.CONTENT, longitude=sel['longitude'], latitude=sel['latitude'], 
     90            squeeze=1) 
    6091 
     92    d.close() 
     93    os.remove(filename) 
    6194    return var 
    6295         
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/ows/wcs_capabilities.kid

    r2589 r2592  
    2626 
    2727?> 
    28 <Capabilities xmlns:py="http://purl.org/kid/ns#" 
    29               xmlns="http://www.opengis.net/wcs"  
    30               xmlns:xlink="http://www.w3.org/1999/xlink"  
    31               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    32               xsi:schemaLocation="http://www.opengis.net/wcs 
    33                                   http://schemas.opengis.net/wcs/1.1.0/capabilities_1_1_0.xml" 
    34               version="1.1.0"> 
     28<Capabilities xmlns:py="http://purl.org/kid/ns#" xmlns="http://www.opengis.net/wcs/1.1"              xmlns:ows="http://www.opengis.net/ows"  xmlns:owcs="http://www.opengis.net/wcs/1.1/ows"               xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"               xsi:schemaLocation="http://www.opengis.net/wcs/1.1   ../wcsGetCapabilities.xsd                               http://www.opengis.net/wcs/1.1/ows ../owsDataIdentification.xsd"   version="1.1.0" updateSequence="1.0"> 
     29 
    3530 
    3631  <!--! Named template definitions --> 
     
    5651  <CoverageSummary py:def="coverageSummary(ds)"> 
    5752    <!--!  coverageSummary comes from wmsDatasetSummary  TODO   -->  
    58     <Name py:if="ds.identifier is not None" py:content="ds.identifier"/> 
     53    <Identifier py:if="ds.identifier is not None" py:content="ds.identifier"/> 
     54    <Description py:if="ds.description is not None" py:content="ds.description"/> 
     55    <ows:Title></ows:Title> 
     56    <ows:Abstract></ows:Abstract> 
     57    <ows:Metadata></ows:Metadata> 
     58    <ows:WGS84BoundingBox></ows:WGS84BoundingBox> 
    5959    <CoverageSummary py:for="ds1 in ds.datasetSummaries" py:replace="coverageSummary(ds1)"/> 
    6060  </CoverageSummary> 
Note: See TracChangeset for help on using the changeset viewer.