Changeset 4303 for cows/trunk/cows/model


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.

File:
1 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             
Note: See TracChangeset for help on using the changeset viewer.