Changeset 4481


Ignore:
Timestamp:
21/11/08 14:22:57 (11 years ago)
Author:
domlowe
Message:

Fixes to enable Point and GridSeries? subsetting in WFS.

Location:
cows/trunk/cows
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/pylons/templates/wfs_valuecollection.xml

    r4417 r4481  
    33<?python  
    44from genshi import XML 
     5         
     6def wrapXML(content): 
     7        #if the string content looks like it contains XML element nodes, then wrap it using the genshi XML function 
     8        #else just return the string 
     9        if content[:1]=='<': 
     10            return XML(content) 
     11        else: 
     12            return content 
     13 
     14         
    515?> 
    616 
     
    1323                  numberReturned="${len(c.resultset)}">  
    1424        <wfs:member py:for="feature in c.resultset" 
    15              py:content="XML(feature)"/> 
     25             py:content="wrapXML(feature)"/> 
    1626</wfs:ValueCollection> 
    1727                   
  • cows/trunk/cows/pylons/wfs_controller.py

    r4431 r4481  
    185185                log.debug('valuecomponent %s'%valuecomponent) 
    186186                if valuecomponent is not None: 
    187                     attribute=valuecomponent.get(attributeName) 
    188                     #TODO: important- how does WFS 2.0 represent xml attribute content?? if it does at all?? 
    189                     #for now, have created element from attribute name e.g. <gml:id> 
    190                     newelem=etree.Element(attributeName) 
    191                     newelem.text=attribute                    
    192                     valstr=etree.tostring(newelem)                     
    193                     resultset.append(valstr)             
     187                    attribute=valuecomponent.get(attributeName)          
     188                    resultset.append(attribute)             
    194189        log.debug(resultset) 
    195190        return resultset       
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4439 r4481  
    9696         
    9797        qid='queryTwo' 
    98         qet=QueryExpressionText('csml:GridSeriesFeature') #TODO, possibly this could differ for different features... 
     98        qet=QueryExpressionText('csml:AbstractFeature') #TODO, possibly this could differ for different features... 
    9999        pex=ParameterExpression('nameblah2', 'typeblah2') 
    100100        query=StoredQuery(qid, title='blah2', abstract = 'my blah2 query', queryExpressionText = qet, parameter=pex) 
    101101        self.queries[qid]=(query, CSMLQueries.query_two_func)       
     102         
     103        #mandatory get feature by id 
     104        qid='urn-x:wfs:StoredQueryId:ISO:GetFeatureById' 
     105        qet=QueryExpressionText('csml:AbstractFeature') 
     106        pex=ParameterExpression('id', 'xsd:anyURI') 
     107        query=StoredQuery(qid, title='GetFeatureById', abstract = 'Get any feature by id', queryExpressionText = qet, parameter=pex) 
     108        self.queries[qid]=(query, CSMLQueries.query_getFeatureById) 
    102109 
    103110        #query to select features by phenomenon 
    104111        qid='phenomenonQuery' 
    105         qet=QueryExpressionText('csml:GridSeriesFeature')#TODO, this could definitely differ for different features... 
     112        qet=QueryExpressionText('csml:AbstractFeature')#TODO, this could definitely differ for different features... 
    106113        pex=ParameterExpression('phenomenon', 'string') 
    107114        query=StoredQuery(qid, title='SelectFeaturesByPhenomenon', abstract = 'Select features based on their phenomenon type, e.g. "temperature"', queryExpressionText = qet, parameter=pex) 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r4439 r4481  
    3434    return featureset.getFeaturesByPropertyEqualTo('csml:parameter', phenomenon)     
    3535 
     36def query_getFeatureById(featureset, id): 
     37    return [featureset.getFeatureByGMLid(id)] 
     38 
    3639def query_extractPointFromPointSeries(featureset, featureid, timeinstance): 
    3740    #TODO:  configure output directory 
     
    4043    feature=featureset.getFeatureByGMLid(featureid)._feature 
    4144    newfeature, netcdfpath, storagedescriptor=feature.subsetToPoint(time=str(timeinstance), outputdir=csmloutputdir)         
    42     #wrap this in a wfs CSMLFeatureInstance object: 
     45     
     46    #modify the rangeset of the feature to store the data inline and discard the storage descriptor. 
     47    storagedescriptor.fileName.CONTENT=csmloutputdir+'/'+storagedescriptor.fileName.CONTENT     
     48    data=storagedescriptor.getData() 
     49    qlist=csml.parser.MeasureOrNullList() 
     50    qlist.uom=newfeature.value.rangeSet.valueArray.valueComponent.uom 
     51    qlist.CONTENT=str(data[0]) 
     52    rs=csml.parser.RangeSet() 
     53    rs.quantityList=qlist     
     54    newfeature.value.rangeSet=rs 
     55     
     56    #wrap the feature in a wfs CSMLFeatureInstance object: 
    4357    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
     58     
     59     
     60    return [csmlfi] 
     61    #This following code is used to maintain the storage descriptor filename consistency, but has been commented out for this  
     62    #operation as there is only a single point value. However code is left here as reminder as it will be needed  
     63    #for other feature types soon 
     64    #change the path of the storage descriptor to the download url - assumes routes maps to filestore 
     65     
    4466    #And serialise the storage descriptor as XML. 
    45     qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
    46     emptyelem=etree.Element(qualifiedFeatureType) 
    47     log.debug(request.environ) 
    48     #change the path of the storage descriptor to the download url - assumes routes maps to filestore 
    49     storagedescriptor.fileName.CONTENT='http://'+request.environ['HTTP_HOST']+'/filestore/' +storagedescriptor.fileName.CONTENT 
    50     csmlelem=storagedescriptor.toXML(emptyelem) 
    51     storagedescXML=etree.tostring(csmlelem)       
    52     return [csmlfi], [storagedescXML] 
     67#    qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
     68#    emptyelem=etree.Element(qualifiedFeatureType) 
     69#    log.debug(request.environ)     
     70#    storagedescriptor.fileName.CONTENT='http://'+request.environ['HTTP_HOST']+'/filestore/' +storagedescriptor.fileName.CONTENT 
     71#    csmlelem=storagedescriptor.toXML(emptyelem) 
     72#    storagedescXML=etree.tostring(csmlelem)       
     73#    return [csmlfi], [storagedescXML] 
     74 
    5375 
    5476def query_extractGridSeriesFromGridSeries(featureset, featureid, bbox, timerange): 
Note: See TracChangeset for help on using the changeset viewer.