Changeset 6305


Ignore:
Timestamp:
13/01/10 14:12:42 (10 years ago)
Author:
domlowe
Message:

Changes to wfs backend to support point series subsetting in wfs interface

Location:
cows/trunk/cows/service/imps/csmlbackend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r6138 r6305  
    132132        query=StoredQuery(qid, title='ExtractPointFromPointSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=[pex1, pex2]) 
    133133        self.queries[qid]=(query, CSMLQueries.query_extractPointFromPointSeries) 
     134 
     135        #query to extract a PointSeriesFeature from a PointSeriesFeature 
     136        qid='urn-x:wfs:StoredQueryId:badc.nerc.ac.uk:extractPointSeriesFromPointSeries' 
     137        qet=QueryExpressionText('csml:PointSeriesFeature') 
     138        pex1=ParameterExpression('featureid', 'xsd:anyURI') 
     139        pex2=ParameterExpression('mintime', 'gml:TimePositionUnion') 
     140        pex3=ParameterExpression('maxtime', 'gml:TimePositionUnion') 
     141        query=StoredQuery(qid, title='ExtractPointSeriesFromPointSeries', abstract = 'Extract a csml:PointSeriesFeature for a range of times from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=[pex1, pex2, pex3]) 
     142        self.queries[qid]=(query, CSMLQueries.query_extractPointSeriesFromPointSeries) 
    134143 
    135144        #query to extract a GridSeriesFeature from a GridSeriesFeature 
     
    264273            if hasattr(self._feature.value, att): 
    265274                domain=getattr(self._feature.value,att) 
    266                 for ordinate in listify(domain.coordTransformTable.gridOrdinates): 
    267                     #insertedExtract is the 'hidden' resolved xlink data, expose inline 
    268                     if hasattr(ordinate.coordAxisValues, 'insertedExtract'): 
    269                         ordinate.coordAxisValues.CONTENT=cleanString2(str(ordinate.coordAxisValues.insertedExtract.getData()[0].tolist()))                             
     275                if hasattr(domain, 'coordTransformTable'): 
     276                    for ordinate in listify(domain.coordTransformTable.gridOrdinates): 
     277                        #insertedExtract is the 'hidden' resolved xlink data, expose inline 
     278                        if hasattr(ordinate.coordAxisValues, 'insertedExtract'): 
     279                            ordinate.coordAxisValues.CONTENT=cleanString2(str(ordinate.coordAxisValues.insertedExtract.getData()[0].tolist()))                             
    270280     
    271281    def toGML(self): 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r5887 r6305  
    6565    #wrap the feature in a wfs CSMLFeatureInstance object: 
    6666    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
    67      
    68      
    6967    return [csmlfi] 
    7068    #This following code is used to maintain the storage descriptor filename consistency, but has been commented out for this  
     
    8179#    storagedescXML=etree.tostring(csmlelem)       
    8280#    return [csmlfi], [storagedescXML] 
     81 
     82def query_extractPointSeriesFromPointSeries(featureset, featureid, starttime, endtime): 
     83    csmloutputdir=config['cows.csml.publish_dir'] 
     84    feature=featureset.getFeatureByGMLid(featureid)._feature 
     85    timerange=(starttime, endtime,) 
     86    subsetdictionary={'times':timerange} 
     87    ncname=_getCSMLFilename() 
     88    newfeature, netcdfpath, storagedescriptor=feature.subsetToPointSeries(outputdir=csmloutputdir, ncname=ncname,**subsetdictionary) 
     89    #wrap this in a wfs CSMLFeatureInstance object: 
     90    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
     91    #And serialise the storage descriptor as XML. 
     92    qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
     93    emptyelem=etree.Element(qualifiedFeatureType) 
     94    log.debug(request.environ) 
     95    #change the path of the storage descriptor to the download url - assumes routes maps to filestore 
     96    #TODO: THIS SHOULD HANDLE SERVER PROXIES. 
     97    storagedescriptor.fileName.CONTENT='http://'+request.environ['HTTP_HOST']+'/filestore/' +ncname 
     98    csmlelem=storagedescriptor.toXML(emptyelem) 
     99    storagedescXML=etree.tostring(csmlelem) 
     100    return [csmlfi], [storagedescXML] 
    83101 
    84102 
Note: See TracChangeset for help on using the changeset viewer.