Changeset 4303 for cows/trunk/cows


Ignore:
Timestamp:
08/10/08 11:53:33 (11 years ago)
Author:
domlowe
Message:

Added interfaces for getFeaturesByBBox and getFeaturesByTemporalRange type filters. Also added code for combining filter resultsets.

Location:
cows/trunk/cows
Files:
3 edited

Legend:

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

    r4299 r4303  
    6767class FEQueryProcessor(object): 
    6868    """ Given a Featureset and a list of of Filters, applies the filters  
    69     to the Featureset and creates a resultset """ 
     69    to the Featureset and creates a resultset  
     70    Assumptions: 
     71        1) GmlObjectId is only used as a filter alone or with other GmlObjectId filters, not with other filter types. 
     72        2) Other filter types, such as bounding box or temporal range fitlers only appear once.  
     73     
     74     
     75    """ 
    7076     
    7177    def __init__(self, featureset, filters): 
    7278        self.featureset=featureset 
    73         self.resultset=[] 
     79        self.resultset=[]               
     80        temporalrangeresults=[] 
     81        bboxresults=[] 
    7482        for filter in filters: 
    7583            if filter.filtertype=='GmlObjectId':            
    76                 feature=self.featureset.featureinstances[filter.filtervalue] 
     84                feature=self.featureset.getFeatureByGMLid(filter.filtervalue) 
    7785                if feature: 
    78                     self.resultset.append(feature)  
    79  
     86                    self.resultset.append(feature)     
     87            else: 
     88                #handle other filtertypes, bbox & temporal for now: 
     89                if filter.filtertype=='BBox': 
     90                    bboxresults=self.featureset.getFeaturesByBBox()                     
     91                if filter.filtertype=='TemporalRange': 
     92                    temporalrangeresults=self.featureset.getFeaturesByTemporalRange()            
     93                self.resultset=self._combineresults([set(temporalrangeresults), set(bboxresults)]) 
     94                 
     95    def _combineresults(self, results):       
     96        """ combine (AND operation) results from two or more filters """ 
     97        baseset=[] 
     98        for set in results: 
     99            if baseset == []: 
     100                baseset = set 
     101            else: 
     102                baseset=baseset.intersection(set)                         
     103        return baseset 
    80104             
     105             
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4292 r4303  
    8383     
    8484    def getFeatureByGMLid(self, gmlid): 
    85         pass 
     85        return self.featureinstances[gmlid] 
    8686     
    87  
     87    def getFeaturesByBBox(self,bboxtuple): 
     88        return [] 
     89     
     90    def getFeaturesByTemporalRange(self, range): 
     91        #TODO: getFeaturesByTemporalRange 
     92        return [] 
     93     
     94     
    8895class CSMLFeatureInstance(IFeatureInstance): 
    8996    def __init__(self, title, abstract, feature): 
  • cows/trunk/cows/service/wfs_iface.py

    r4292 r4303  
    2525    def getFeatureByGMLid(self, gmlid): 
    2626        """ return a feature specified by gmlid  
    27         @return: IFeatureInstance 
     27        @return: zero or one IFeatureInstance 
    2828        """ 
    2929        raise NotImplementedError 
    3030     
    31     #TODO: Define other types of filter query that can be done on the FeatureSet 
     31    def getFeaturesByBBox(self,bboxtuple): 
     32        """ return features within a bbox (llx, lly, urx, ury) 
     33        @return: zero or more IFeatureInstance  
     34        """ 
     35        raise NotImplementedError 
     36 
     37     
     38    def getFeaturesByTemporalRange(self, range): 
     39        """ return features within a temporal range (minT, maxT) in form YYYY-MM-DDT00:00:00.0 
     40        @return: zero or more IFeatureInstance  
     41        """ 
     42        raise NotImplementedError     
    3243     
    3344         
Note: See TracChangeset for help on using the changeset viewer.