Changeset 4439


Ignore:
Timestamp:
18/11/08 15:23:13 (11 years ago)
Author:
domlowe
Message:

Support for gridseries subsetting stored query

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

Legend:

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

    r4422 r4439  
    112112        qet=QueryExpressionText('csml:PointFeature') 
    113113        pex=ParameterExpression('timeinstance', 'string') 
    114         query=StoredQuery(qid, title='SelectFeaturesByPhenomenon', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=pex) 
     114        query=StoredQuery(qid, title='ExtractPointFromPointSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=pex) 
    115115        self.queries[qid]=(query, CSMLQueries.query_extractPointFromPointSeries) 
     116 
     117        #query to extract a GridSeriesFeature from a GridSeriesFeature 
     118        qid='extractGridSeriesFromGridSeries' 
     119        qet=QueryExpressionText('csml:GridSeriesFeature') 
     120        pex=ParameterExpression('timerange', 'string') 
     121        query=StoredQuery(qid, title='ExtractGridSeriesFromGridSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=pex) 
     122        self.queries[qid]=(query, CSMLQueries.query_extractGridSeriesFromGridSeries) 
    116123 
    117124 
     
    209216        self._feature=feature 
    210217        self.featuretype=self._feature.__class__.__name__ 
    211         bb= self._feature.getCSMLBoundingBox().getBox() 
    212         #convert 0 - 360 to -180, 180 as per common WMS convention 
    213         if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    214             bb[0], bb[2]=-180, 180 
    215         self.wgs84BBox = bb 
    216          
     218        try: 
     219            bb= self._feature.getCSMLBoundingBox().getBox() 
     220            #convert 0 - 360 to -180, 180 as per common WMS convention 
     221            if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
     222                bb[0], bb[2]=-180, 180 
     223            self.wgs84BBox = bb 
     224        except AttributeError: 
     225            log.debug('there is a problem getting the bounding box for feature id %s'%self._feature.id) 
     226            self.wgs84BBox=() 
    217227    def toGML(self): 
    218228        """ Create a GML (CSML) representation of the feature """ 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r4431 r4439  
    5151    storagedescXML=etree.tostring(csmlelem)       
    5252    return [csmlfi], [storagedescXML] 
     53 
     54def query_extractGridSeriesFromGridSeries(featureset, featureid, bbox, timerange): 
     55    #TODO factor out code in common with other subsetting queries 
     56    csmloutputdir=config['publish_dir'] 
     57    feature=featureset.getFeatureByGMLid(featureid)._feature 
     58    #break the bounding box into latitude and longitude:  
     59    #TODO, this really needs to be generic and refer to the srs of the underlying feature. 
     60    bb=str(bbox).split(',') 
     61    lat=(float(bb[1]),float(bb[3])) 
     62    lon=(float(bb[0]),float(bb[2])) 
     63    log.debug('requesting latitude: %s, longitude: %s'%(lat, lon)) 
     64    newfeature, netcdfpath, storagedescriptor=feature.subsetToGridSeries(time=str(timerange), latitude=lat, longitude=lon, outputdir=csmloutputdir) 
     65    #wrap this in a wfs CSMLFeatureInstance object: 
     66    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
     67    #And serialise the storage descriptor as XML. 
     68    qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
     69    emptyelem=etree.Element(qualifiedFeatureType) 
     70    log.debug(request.environ) 
     71    #change the path of the storage descriptor to the download url - assumes routes maps to filestore 
     72    storagedescriptor.fileName.CONTENT='http://'+request.environ['HTTP_HOST']+'/filestore/' +storagedescriptor.fileName.CONTENT 
     73    csmlelem=storagedescriptor.toXML(emptyelem) 
     74    storagedescXML=etree.tostring(csmlelem) 
     75    return [csmlfi], [storagedescXML] 
     76     
Note: See TracChangeset for help on using the changeset viewer.