Changeset 4431


Ignore:
Timestamp:
17/11/08 13:08:52 (11 years ago)
Author:
domlowe
Message:

prototype support for attributes in getpropertyvalue method - need to check with ogc.

Location:
cows/trunk/cows
Files:
2 edited

Legend:

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

    r4429 r4431  
    161161        a set of wfs:members containing property values expressed in the xpath""" 
    162162        resultset=[]         
    163         for feature in features: 
    164             featureXML=feature._feature.elem #the underlying XML 
    165             valuecomponent=featureXML.find(xpath) 
    166             if valuecomponent is not None: 
    167                 valstr=etree.tostring(valuecomponent)            
    168                 resultset.append(valstr) 
     163        #if xpath is looking for an attribute, handle it differently - this should be unnecessary when migrated to element tree 1.3 
     164        #i.e. if of the form /somepath/path[@attribute] 
     165        attstart=xpath.find('[') 
     166        if attstart == -1: #no attribute             
     167            for feature in features: 
     168                featureXML=feature._feature.elem #the underlying XML 
     169                valuecomponent=featureXML.find(xpath) 
     170                if valuecomponent is not None: 
     171                    valstr=etree.tostring(valuecomponent)            
     172                    resultset.append(valstr) 
     173        else: 
     174            #there is an attribute: 
     175            attributeName=xpath.split('[')[1][1:-1] 
     176            xpath=xpath.split('[')[0] 
     177            for feature in features: 
     178                featureXML=feature._feature.elem #the underlying XML 
     179                log.debug('xpath path %s'%xpath) 
     180                log.debug('attribute %s'%attributeName) 
     181                if len(xpath) ==0: 
     182                    valuecomponent=featureXML 
     183                else: 
     184                    valuecomponent=featureXML.find(xpath) 
     185                log.debug('valuecomponent %s'%valuecomponent) 
     186                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)             
     194        log.debug(resultset) 
    169195        return resultset       
    170196     
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmlstoredqueries.py

    r4422 r4431  
    1515import csml.parser 
    1616from xml.etree import ElementTree as etree 
     17from pylons import request, config 
    1718 
    1819class dummyfeaturefortesting(object): 
     
    3334    return featureset.getFeaturesByPropertyEqualTo('csml:parameter', phenomenon)     
    3435 
    35 def query_extractPointFromPointSeries(featureset, timeinstance): 
     36def query_extractPointFromPointSeries(featureset, featureid, timeinstance): 
    3637    #TODO:  configure output directory 
    3738    #TODO: error handling 
    38     feature=featureset.getFeatureByGMLid('S9c7oW2p')._feature 
    39     newfeature, netcdfpath, storagedescriptor=feature.subsetToPoint(time=str(timeinstance), outputdir='/home/dom/csmlstore/csmlout')         
     39    csmloutputdir=config['publish_dir'] 
     40    feature=featureset.getFeatureByGMLid(featureid)._feature 
     41    newfeature, netcdfpath, storagedescriptor=feature.subsetToPoint(time=str(timeinstance), outputdir=csmloutputdir)         
    4042    #wrap this in a wfs CSMLFeatureInstance object: 
    4143    csmlfi=wfs_csmllayer.CSMLFeatureInstance('subset feature title', 'subset feature abstract', newfeature) 
     
    4345    qualifiedFeatureType='{http://ndg.nerc.ac.uk/csml}' + storagedescriptor.__class__.__name__  
    4446    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 
    4550    csmlelem=storagedescriptor.toXML(emptyelem) 
    4651    storagedescXML=etree.tostring(csmlelem)       
Note: See TracChangeset for help on using the changeset viewer.