Changeset 4292 for cows/trunk


Ignore:
Timestamp:
07/10/08 11:12:12 (11 years ago)
Author:
domlowe
Message:

Creating FeatureSet? class to provide query methods on collection of FeatureInstances?.

Location:
cows/trunk/cows
Files:
3 edited

Legend:

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

    r4289 r4292  
    5555        """ 
    5656        log.debug('loading layers') 
    57         self.layers, self.featureinstances = self.layerMapper.map(**kwargs) 
    58         log.debug('Feature instances %s'%self.featureinstances) 
     57        self.layers, self.featureset = self.layerMapper.map(**kwargs) 
     58        log.debug('Feature instances %s'%self.featureset.featureinstances) 
    5959     
    6060        #------------------------------------------------------------------------- 
     
    9292         
    9393        ftlist={} 
    94          
    95         #create dictionary of form {featuretype: [layer, layer, ...], {featuretype2: [layer, layer, ...]} 
    96 #        for layerName, layer in self.layers.items(): 
    97 #            log.info(dir(layer)) 
    98 #            if type(layer._feature) not in ftlist: 
    99 #                ftlist[type(layer._feature)] = [layer] 
    100 #            else: 
    101 #                ftlist[type(layer._feature)].append(layer) 
    102 #        log.info('FeatureTypeList: %s'%ftlist) 
    103 #         
     94        #         
    10495         
    10596        for layerName, layer in self.layers.items(): 
     
    109100            wgs84BBox = WGS84BoundingBox(layer.wgs84BBox[:2], 
    110101                                         layer.wgs84BBox[2:]) 
    111 #            wgs84BBox = WGS84BoundingBox(['10','20'],['20','40']) 
    112102             
    113103            ds = WfsFeatureSummary(keywords=layer.keywords,  
     
    146136        typename=self.getOwsParam('typename') 
    147137        ftschema =self._parsetypename(typename) 
    148         log.debug(self.layers.items()) 
    149          
    150  
    151                  
     138        log.debug(self.layers.items())        
     139                
    152140        outputformat=self.getOwsParam('outputformat', default='text/xml') 
    153141         
     
    168156        featureid=self.getOwsParam('featureid') 
    169157        #TODO populate self.featureinstances! 
    170         feature=self.featureinstances[featureid]     
     158        feature=self.featureset.featureinstances[featureid]     
    171159        response.headers['content-type'] = 'text/xml' 
    172160        return feature.toGML() 
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4291 r4292  
    55 
    66from cows.service.imps.csmlbackend.csmlcommon import CSMLLayerMapper, CSMLConnector, BboxAggregator 
    7 from cows.service.wfs_iface import IwfsLayer, IFeatureInstance 
     7from cows.service.wfs_iface import * 
    88import csml 
    99from xml.etree import ElementTree as etree 
     
    4747        #feature *types* not *instances*. However a record of instances is also  
    4848        #needed to fulfil GetFeature requests: 
    49         featureinstances={} #feature instances         
     49        featureset=CSMLFeatureSet() #holds feature instances                 
    5050        layermap={} #feature types        
    5151        bboxAggregators={}#for aggregations of bounding boxes. 
     
    5353        for feature in csml.csmllibs.csmlextra.listify(ds.featureCollection.featureMembers): 
    5454            title, abstract=self._getInfo(feature) 
    55             featureinstances[feature.id]=CSMLFeatureInstance(title, abstract, feature)              
    56         for id, instance in featureinstances.iteritems(): 
     55            featureset.featureinstances[feature.id]=CSMLFeatureInstance(title, abstract, feature)              
     56        for id, instance in featureset.featureinstances.iteritems(): 
    5757            ftype='csml:' + instance.featuretype 
    5858            if ftype not in layermap.keys(): 
     
    7272            #cache results 
    7373            self.layermapcache[fileoruri]=layermap 
    74             self.featureinstancecache[fileoruri]=featureinstances 
    75             return layermap, featureinstances 
     74            self.featureinstancecache[fileoruri]=featureset 
     75            return layermap, featureset 
    7676        else: 
    7777            raise ValueError 
     78 
     79class CSMLFeatureSet(IFeatureSet): 
     80    """ A set of features available via a WFS. Supports querying methods as used by OGG filters """ 
     81    def __init__(self): 
     82        self.featureinstances={} 
     83     
     84    def getFeatureByGMLid(self, gmlid): 
     85        pass 
     86     
    7887 
    7988class CSMLFeatureInstance(IFeatureInstance): 
  • cows/trunk/cows/service/wfs_iface.py

    r4289 r4292  
    1414    """ 
    1515    An interface representing a WFS FeatureType, based on ILayer. 
    16     @ivar: list keywords describing this feature type. 
    17     @outputformats: list of output formats available for this feature type. 
     16    @ivar keywords: describing this feature type. 
     17    @ivar outputformats: list of output formats available for this feature type. 
    1818    """ 
    1919    keywords=outputformats=NotImplemented 
     20 
     21class IFeatureSet(object): 
     22    """ A set of features available via a WFS. Supports querying methods as used by OGG filters  
     23    @ivar featureinstances: feature instances available in this feature set""" 
     24 
     25    def getFeatureByGMLid(self, gmlid): 
     26        """ return a feature specified by gmlid  
     27        @return: IFeatureInstance 
     28        """ 
     29        raise NotImplementedError 
     30     
     31    #TODO: Define other types of filter query that can be done on the FeatureSet 
    2032     
    2133         
Note: See TracChangeset for help on using the changeset viewer.