Changeset 2726 for TI05-delivery


Ignore:
Timestamp:
13/07/07 13:22:25 (12 years ago)
Author:
domlowe
Message:

more on describecoverage operation

Location:
TI05-delivery/ows_framework/trunk/ows_server/ows_server
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcs.py

    r2711 r2726  
    3333from ows_server.lib.csml_util import get_csml_doc, extractToNetCDF 
    3434from ows_server.lib.ndgInterface import interface 
     35from ows_server.models.wcs_CoverageDescription import CoverageDescription 
    3536 
    3637from email.mime.multipart import MIMEMultipart 
     
    4950    def _createMultipartMime(self, xml, netcdf): 
    5051        #returns a multipart mime file containing the coverage xml + a netcdf file 
    51          
     52 
    5253        # Create the container (outer) email message. 
    53         msg = MIMEMultipart()         
    54          
     54        msg = MIMEMultipart() 
     55 
    5556        xmlfile =StringIO.StringIO(xml) 
    5657        xmlfile.readline(), xmlfile.readline() #don't read in first 2 lines (the content type) as MIMEBase also provides it. 
    57              
    58          
     58 
     59 
    5960        #add the XML part 
    6061        submsg=MIMEText(xmlfile.read(), _subtype='xml') 
     
    6465        msg.attach(submsg) 
    6566 
    66          
     67 
    6768        #add the NetCDF part 
    6869        submsg= MIMEBase('application', 'CF-netcdf') #check in ogc docs 
     
    7576        encoders.encode_base64(submsg) 
    7677        msg.attach(submsg) 
    77          
     78 
    7879        #return the message 
    7980        return msg 
    80          
     81 
    8182 
    8283    def _loadFeatureDimensions(self, feature): 
     
    9091        for axis_name, axis in domain.iteritems(): 
    9192            if axis_name in [lon,lat]: 
    92                 continue             
     93                continue 
    9394            dims[axis_name] =            Domain(possibleValues=PossibleValues.fromAllowedValues(axis), 
    9495                                 #!TODO: this is a fudge until we can deduce UOM. 
     
    118119        sm = super(CsmlWcsController, self)._loadCapabilities() 
    119120        ds = WcsDatasetSummary(titles=['Root Dataset'], datasetSummaries=[], CRSs=['CRS:84']) 
    120         # Add a DatasetSummary for each feature         
    121  
    122         for f_n in c.dataset.getFeatureList():         
     121        # Add a DatasetSummary for each feature 
     122 
     123        for f_n in c.dataset.getFeatureList(): 
    123124            feature_ds = self._loadFeatureSummary(c.dataset.getFeature(f_n)) 
    124125            ds.datasetSummaries.append(feature_ds) 
     
    126127        return sm 
    127128 
    128      
     129    def _buildCoverageDescriptions(self): 
     130        """ builds a collection of CoverageDescription objects - used for DescribeCoverage """ 
     131        CoverageDescriptions=[] 
     132        for f in self.features: 
     133          cd=CoverageDescription(identifier=f) 
     134          CoverageDescriptions.append(cd) 
     135        return CoverageDescriptions 
     136 
     137 
     138 
     139 
    129140    @operation 
    130141    @parameter('Format', possibleValues=['text/xml']) 
     
    138149        """ 
    139150        # Populate the context object with information required by the template 
    140          
     151 
    141152        #get doc from cache or disk: 
    142153        rstatus,c.dataset=interface.GetParsedCSML(fileoruri) 
    143         if not rstatus: raise ValueError(c.dataset)         
    144        
    145          
     154        if not rstatus: raise ValueError(c.dataset) 
     155 
     156 
    146157        if type(c.dataset) is str: 
    147             #If not a csml datset is some message from exist such as 'access denied'            
     158            #If not a csml datset is some message from exist such as 'access denied' 
    148159            return Response(c.dataset) 
    149160        return self._renderCapabilities('ows/wcs_capabilities') 
    150      
     161 
    151162    @operation 
    152163    @parameter('Service', possibleValues=['WCS'], required=True) 
    153164    @parameter('Version', possibleValues=['1.1.0']) 
    154     @parameter('Identifier', required=True) 
     165    @parameter('Identifiers', required=True) 
    155166    @parameter('Format', possibleValues=['text/xml'], required=True)  #IS THIS MANDATORY 
    156     def DescribeCoverage(self, fileoruri, version, service, identifier): 
     167    def DescribeCoverage(self, fileoruri, version, service, identifiers, format='text/xml'): 
    157168        """ 
    158169        WCS DescribeCoverage operation 
    159170        """ 
     171        self.features={} #dictionary to hold requested coverages 
    160172        rstatus,c.dataset=interface.GetParsedCSML(fileoruri) 
    161173        if not rstatus: raise ValueError(dataset) 
    162              
    163         #TODO, handle multiple identifiers 
    164         feature = dataset.getFeature(identifier) 
    165         if feature is None: 
    166             raise OWS_E.InvalidParameterValue('Coverage not found', 'identifier') 
    167          
     174        for ident in identifiers.split(','): 
     175            feature = c.dataset.getFeature(ident) 
     176            if feature is None: 
     177                raise OWS_E.InvalidParameterValue('Coverage  with id=%s not found'%ident, 'identifiers') 
     178            self.features[ident]=feature 
     179        c.covDescs=self._buildCoverageDescriptions() 
     180        print c.covDescs 
    168181        r=render_response('wcs_DescribeCoverageResponse', format='xml') 
    169182        r.headers['content-type'] = 'text/xml' 
    170         return r     
    171      
    172      
     183        return r 
     184 
     185 
    173186    @operation 
    174187    @parameter('Version', possibleValues=['1.1.0'], required=True) 
     
    198211            lat=feature.getLatitudeAxis() 
    199212            t=feature.getTimeAxis() 
    200              
     213 
    201214            if None in [lon, lat, time]: 
    202215                #TODO need to return a suitable wcs error. 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/wcs_DescribeCoverageResponse.kid

    r2711 r2726  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <DescribeCoverageResponse>TODO</DescribeCoverageResponse> 
     2<CoverageDescriptions xmlns:py="http://purl.org/kid/ns#" xmlns="http://www.opengis.net/wcs/1.1" 
     3xmlns:ows="http://www.opengis.net/ows" 
     4xmlns:owcs="http://www.opengis.net/wcs/1.1/ows" 
     5xmlns:xlink="http://www.w3.org/1999/xlink" 
     6xmlns:gml="http://www.opengis.net/gml" 
     7xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     8xsi:schemaLocation="http://www.opengis.net/wcs/1.1 
     9../wcsDescribeCoverage.xsd http://www.opengis.net/wcs/1.1/ows 
     10../owsDataIdentification.xsd"> 
     11<CoverageDescription py:for="cd in c.covDescs"> 
     12    <Identifier py:content="cd.identifier"/> 
     13</CoverageDescription> 
     14</CoverageDescriptions> 
Note: See TracChangeset for help on using the changeset viewer.