Changeset 4517 for cows


Ignore:
Timestamp:
28/11/08 13:31:29 (11 years ago)
Author:
domlowe
Message:

Tidying up DescribeQuery? and allowing multiple ParameterExpressions?

Location:
cows/trunk/cows
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/model/storedquery.py

    r4416 r4517  
    33 
    44class StoredQuery(object): 
    5     def __init__(self, id, title=None, abstract=None,metadata=None, parameter=None, queryExpressionText=None ): 
     5    def __init__(self, id, title=None, abstract=None,metadata=None, parameter=[], queryExpressionText=None ): 
    66        self.id=id 
    77        self.title=title 
     
    2020     
    2121class QueryExpressionText(object): 
    22     def __init__(self, returnFeatureType, language=None, any=None, isPrivate=True): 
     22    def __init__(self, returnFeatureType, language='urn-x:wfs:StoredQueryLanguage:WFS_QueryExpression', any=None, isPrivate=True): 
    2323        self.returnFeatureType=returnFeatureType         
    2424        self.language=language 
  • cows/trunk/cows/pylons/templates/wfs_describestoredqueries.xml

    r4416 r4517  
    1212            <Abstract py:content="querydesc.abstract"/> 
    1313            <ows:Metadata  py:content="querydesc.metadata"></ows:Metadata> 
    14             <Parameter name="${querydesc.parameter.name}" type="${querydesc.parameter.name}"></Parameter> 
    15             <QueryExpressionText returnFeatureTypes="" language=""></QueryExpressionText>            
     14            <Parameter py:for="param in querydesc.parameter" name="${param.name}" type="${param.type}"></Parameter> 
     15         <!--!   <QueryExpressionText returnFeatureTypes="${querydesc.queryExpressionText.returnFeatureType}" language="${querydesc.queryExpressionText.language}"></QueryExpressionText> -->        
    1616        </StoredQueryDescription>        
    1717</DescribeStoredQueriesResponse> 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4481 r4517  
    8989        #where func is the name of the implementation of the stored query (typically) in wfs_csmlstoredqueries       
    9090        self.queries={} 
     91         
     92        #simple example query 
    9193        qid='queryOne'         
    92         qet=QueryExpressionText('csml:PointSeriesFeature') #TODO, possibly this could differ for different features... 
    93         pex=ParameterExpression('nameblah1', 'typeblah1') 
    94         query=StoredQuery(qid, title='blah1', abstract = 'my blah1 query', queryExpressionText = qet, parameter=pex) 
     94        qet=QueryExpressionText('xyzml:SomeFeatureType')  
     95        pex1=ParameterExpression('arg1', 'xsd:string') 
     96        pex2=ParameterExpression('arg2', 'xsd:string') 
     97        query=StoredQuery(qid, title='test query', abstract = 'my test query', queryExpressionText = qet, parameter=[pex1, pex2]) 
    9598        self.queries[qid]=(query, CSMLQueries.query_one_func) 
    96          
    97         qid='queryTwo' 
    98         qet=QueryExpressionText('csml:AbstractFeature') #TODO, possibly this could differ for different features... 
    99         pex=ParameterExpression('nameblah2', 'typeblah2') 
    100         query=StoredQuery(qid, title='blah2', abstract = 'my blah2 query', queryExpressionText = qet, parameter=pex) 
    101         self.queries[qid]=(query, CSMLQueries.query_two_func)       
    102          
     99      
     100          
    103101        #mandatory get feature by id 
    104102        qid='urn-x:wfs:StoredQueryId:ISO:GetFeatureById' 
    105103        qet=QueryExpressionText('csml:AbstractFeature') 
    106104        pex=ParameterExpression('id', 'xsd:anyURI') 
    107         query=StoredQuery(qid, title='GetFeatureById', abstract = 'Get any feature by id', queryExpressionText = qet, parameter=pex) 
     105        query=StoredQuery(qid, title='GetFeatureById', abstract = 'Get any feature by id', queryExpressionText = qet, parameter=[pex]) 
    108106        self.queries[qid]=(query, CSMLQueries.query_getFeatureById) 
    109107 
    110108        #query to select features by phenomenon 
    111         qid='phenomenonQuery' 
     109        qid='urn-x:wfs:StoredQueryId:badc.nerc.ac.uk:phenomenonQuery' 
    112110        qet=QueryExpressionText('csml:AbstractFeature')#TODO, this could definitely differ for different features... 
    113         pex=ParameterExpression('phenomenon', 'string') 
    114         query=StoredQuery(qid, title='SelectFeaturesByPhenomenon', abstract = 'Select features based on their phenomenon type, e.g. "temperature"', queryExpressionText = qet, parameter=pex) 
     111        pex=ParameterExpression('phenomenon', 'xsd:string') 
     112        query=StoredQuery(qid, title='SelectFeaturesByPhenomenon', abstract = 'Select features based on their phenomenon type, e.g. "temperature"', queryExpressionText = qet, parameter=[pex]) 
    115113        self.queries[qid]=(query, CSMLQueries.query_getFeatureByPhenomenon) 
    116114         
    117115        #query to extract a PointFeature from a PointSeriesFeature 
    118         qid='extractPointFromPointSeries' 
     116        qid='urn-x:wfs:StoredQueryId:badc.nerc.ac.uk:extractPointFromPointSeries' 
    119117        qet=QueryExpressionText('csml:PointFeature') 
    120         pex=ParameterExpression('timeinstance', 'string') 
    121         query=StoredQuery(qid, title='ExtractPointFromPointSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=pex) 
     118        pex1=ParameterExpression('featureid', 'xsd:anyURI') 
     119        pex2=ParameterExpression('timeinstance', 'gml:TimePositionUnion') 
     120        query=StoredQuery(qid, title='ExtractPointFromPointSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=[pex1, pex2]) 
    122121        self.queries[qid]=(query, CSMLQueries.query_extractPointFromPointSeries) 
    123122 
    124123        #query to extract a GridSeriesFeature from a GridSeriesFeature 
    125         qid='extractGridSeriesFromGridSeries' 
     124        qid='urn-x:wfs:StoredQueryId:badc.nerc.ac.uk:extractGridSeriesFromGridSeries' 
    126125        qet=QueryExpressionText('csml:GridSeriesFeature') 
    127         pex=ParameterExpression('timerange', 'string') 
    128         query=StoredQuery(qid, title='ExtractGridSeriesFromGridSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=pex) 
     126        pex1=ParameterExpression('featureid', 'xsd:anyURI') 
     127        pex2=ParameterExpression('mintime', 'gml:TimePositionUnion') 
     128        pex3=ParameterExpression('maxtime', 'gml:TimePositionUnion') 
     129        pex4=ParameterExpression('bbox', 'xsd:string') 
     130        paramlist=[pex1,pex2,pex3] 
     131        query=StoredQuery(qid, title='ExtractGridSeriesFromGridSeries', abstract = 'Extract a csml:PointFeature for a single time instance from a csml:PointSeriesFeature', queryExpressionText = qet, parameter=[pex]) 
    129132        self.queries[qid]=(query, CSMLQueries.query_extractGridSeriesFromGridSeries) 
    130133 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r4481 r4517  
    1717from pylons import request, config 
    1818 
     19 
    1920class dummyfeaturefortesting(object): 
    2021    def __init__(self, x): 
     
    2324        return '<someGML>%s</someGML>'%self.x 
    2425 
    25 def query_one_func(featureset, arg1='blah1', arg2=None): 
     26def query_one_func(featureset, arg1='string1', arg2='string2'): 
    2627    result = [dummyfeaturefortesting(arg1 + ' ' + arg2)] 
    27     return result 
    28  
    29 def query_two_func(featureset, arg1=None, arg2=None): 
    30     result = [dummyfeaturefortesting('blah2')] 
    3128    return result 
    3229 
     
    7471 
    7572 
    76 def query_extractGridSeriesFromGridSeries(featureset, featureid, bbox, timerange): 
     73def query_extractGridSeriesFromGridSeries(featureset, featureid, bbox, mintime, maxtime): 
    7774    #TODO factor out code in common with other subsetting queries 
    7875    csmloutputdir=config['publish_dir'] 
    7976    feature=featureset.getFeatureByGMLid(featureid)._feature 
     77    timerange=(mintime, maxtime,) 
    8078    #break the bounding box into latitude and longitude:  
    8179    #TODO, this really needs to be generic and refer to the srs of the underlying feature. 
     
    8482    lon=(float(bb[0]),float(bb[2])) 
    8583    log.debug('requesting latitude: %s, longitude: %s'%(lat, lon)) 
    86     newfeature, netcdfpath, storagedescriptor=feature.subsetToGridSeries(time=str(timerange), latitude=lat, longitude=lon, outputdir=csmloutputdir) 
     84    newfeature, netcdfpath, storagedescriptor=feature.subsetToGridSeries(time=timerange, latitude=lat, longitude=lon, outputdir=csmloutputdir) 
    8785    #wrap this in a wfs CSMLFeatureInstance object: 
    8886    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
Note: See TracChangeset for help on using the changeset viewer.