Changeset 5532 for cows


Ignore:
Timestamp:
28/07/09 15:56:45 (10 years ago)
Author:
domlowe
Message:

changes to enable fetch controller for WFS and subset gridseries to pointseries stored queries

Location:
cows/trunk/cows
Files:
1 added
3 edited

Legend:

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

    r4912 r5532  
    1111 
    1212log=logging.getLogger(__name__) 
    13 class FetchController(WSGIController): 
     13class WXSFetchController(WSGIController): 
    1414    ''' returns a file from the filestore. Used for the WCS store parameter in WCS 1.1.0, and also used for  
    1515    fetching of documents referenced by CSML storagedescriptors in the WFS. Could also be used for other services. 
     
    2727         
    2828        #given the filename, these are the paths to the file, and to the accompanying text file 
    29         filePath=config['publish_dir'] + '/' + file 
     29        filePath=config['cows.csml.publish_dir'] + '/' + file 
    3030         
    3131        #just return the file, no security check implemented for now. 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r5131 r5532  
    139139        self.queries[qid]=(query, CSMLQueries.query_extractGridSeriesFromGridSeries) 
    140140 
    141  
     141        #query to extract a PointSeriesFeature from a GridSeriesFeature 
     142        qid='urn-x:wfs:StoredQueryId:badc.nerc.ac.uk:extractPointSeriesFromGridSeries' 
     143        qet=QueryExpressionText('csml:PointSeriesFeature') 
     144        pex1=ParameterExpression('featureid', 'xsd:anyURI') 
     145        pex2=ParameterExpression('mintime', 'gml:TimePositionUnion') 
     146        pex3=ParameterExpression('maxtime', 'gml:TimePositionUnion') 
     147        pex4=ParameterExpression('latitude', 'xsd:string') 
     148        pex5=ParameterExpression('longitude', 'xsd:string') 
     149        paramlist=[pex1,pex2,pex3, pex4, pex5] 
     150        query=StoredQuery(qid, title='ExtractPointSeriesFromGridSeries', abstract = 'Extract a csml:PointSeries from a csml:GridSeriesFeature', queryExpressionText = qet, parameter=paramlist) 
     151        self.queries[qid]=(query, CSMLQueries.query_extractPointSeriesFromGridSeries) 
     152         
    142153 
    143154class CSMLFeatureSet(IFeatureSet): 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r5137 r5532  
    2020import logging 
    2121log = logging.getLogger(__name__) 
    22 import csml.parser 
     22import csml.parser, csml.csmllibs.csmlextra 
    2323from xml.etree import ElementTree as etree 
    2424from pylons import request, config 
     
    3030    def toGML(self): 
    3131        return '<someGML>%s</someGML>'%self.x 
     32 
     33def _getCSMLFilename(): 
     34    return 'csml%s.nc'%(csml.csmllibs.csmlextra.getRandomID()) 
     35 
    3236 
    3337def query_one_func(featureset, arg1='string1', arg2='string2'): 
     
    4650    csmloutputdir=config['cows.csml.publish_dir'] 
    4751    feature=featureset.getFeatureByGMLid(featureid)._feature 
    48     newfeature, netcdfpath, storagedescriptor=feature.subsetToPoint(time=str(timeinstance), outputdir=csmloutputdir)         
     52    ncname=_getCSMLFilename() 
     53    newfeature, netcdfpath, storagedescriptor=feature.subsetToPoint(time=str(timeinstance), ncname=ncname, outputdir=csmloutputdir)         
    4954     
    5055    #modify the rangeset of the feature to store the data inline and discard the storage descriptor. 
     
    7883 
    7984 
     85def query_extractPointSeriesFromGridSeries(featureset, featureid, latitude, longitude, mintime, maxtime): 
     86    csmloutputdir=config['cows.csml.publish_dir'] 
     87    feature=featureset.getFeatureByGMLid(featureid)._feature 
     88    timerange=(mintime, maxtime,) 
     89    lat=float(latitude) 
     90    lon=float(longitude) 
     91    subsetdictionary={'time':timerange, 'latitude':lat, 'longitude':lon} 
     92    ncname=_getCSMLFilename() 
     93    newfeature, netcdfpath, storagedescriptor=feature.subsetToPointSeries(outputdir=csmloutputdir, ncname=ncname,**subsetdictionary) 
     94    #wrap this in a wfs CSMLFeatureInstance object: 
     95    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
     96    #And serialise the storage descriptor as XML. 
     97    qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
     98    emptyelem=etree.Element(qualifiedFeatureType) 
     99    log.debug(request.environ) 
     100    #change the path of the storage descriptor to the download url - assumes routes maps to filestore 
     101    storagedescriptor.fileName.CONTENT='http://'+request.environ['HTTP_HOST']+'/filestore/' +ncname 
     102    csmlelem=storagedescriptor.toXML(emptyelem) 
     103    storagedescXML=etree.tostring(csmlelem) 
     104    return [csmlfi], [storagedescXML] 
     105  
     106 
    80107def query_extractGridSeriesFromGridSeries(featureset, featureid, bbox, mintime, maxtime): 
    81108    #TODO factor out code in common with other subsetting queries 
     
    89116    lon=(float(bb[0]),float(bb[2])) 
    90117    log.debug('requesting latitude: %s, longitude: %s'%(lat, lon)) 
    91     newfeature, netcdfpath, storagedescriptor=feature.subsetToGridSeries(time=timerange, latitude=lat, longitude=lon, outputdir=csmloutputdir) 
     118    ncname=_getCSMLFilename() 
     119    newfeature, netcdfpath, storagedescriptor=feature.subsetToGridSeries(time=timerange, latitude=lat, longitude=lon, ncname=ncname, outputdir=csmloutputdir) 
    92120    #wrap this in a wfs CSMLFeatureInstance object: 
    93121    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
Note: See TracChangeset for help on using the changeset viewer.