Ignore:
Timestamp:
02/10/08 14:11:28 (13 years ago)
Author:
domlowe
Message:

Adding initial WFS code. Plus further separation of CSML code and service specific code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/csmlbackend/wfs_csmllayer.py

    r4269 r4274  
     1""" 
     2implementation of ILayerMapper, IwfsLayer, IDimension, ILayerSlab interfaces, as defined in wfs_iface.py & wxs_iface.py 
     3 
     4""" 
     5 
     6from cows.service.imps.csmlbackend.csmlcommon import CSMLLayerMapper, CSMLConnector 
     7from cows.service.wfs_iface import IwfsLayer 
     8import csml 
     9 
     10import logging 
     11log = logging.getLogger(__name__) 
     12 
     13class CSMLwfsLayerMapper(CSMLLayerMapper): 
     14    """ 
     15    Map keyword arguments to a collection of layers. 
     16    Supports the retrieval of sets of layers according to arbitary 
     17    keyword/value pairs. 
     18    Implements  ILayerMapper  
     19     
     20    """ 
     21    def __init__(self): 
     22        super(CSMLwfsLayerMapper, self).__init__() 
     23     
     24 
     25    def map(self, **kwargs): 
     26        """ 
     27        Given csml.parser.Dataset object list the names of 
     28        all layers available. 
     29         
     30        @return: A mapping of layer names to ILayer implementations. 
     31        @raise ValueError: If no layers are available for these keywords.  
     32        """ 
     33        fileoruri=kwargs['fileoruri'] 
     34        if fileoruri in self.layermapcache.keys(): 
     35            #we've accessed this layer map before, get it from the cache dictionary 
     36            return self.layermapcache[fileoruri] 
     37          
     38        ds = self.connector.get_csml_doc(fileoruri) 
     39        layermap={} 
     40        for feature in csml.csmllibs.csmlextra.listify(ds.featureCollection.featureMembers): 
     41            title, abstract=self._getInfo(feature) 
     42            layermap[feature.id]=CSMLwfsLayer(title,abstract, feature) 
     43        if len(layermap) > 0: 
     44            self.layermapcache[fileoruri]=layermap 
     45            return layermap 
     46        else: 
     47            raise ValueError 
     48 
     49 
     50class CSMLwfsLayer(IwfsLayer): 
     51    """ representing a WFS Feature (termed layer here). Implements IwfsLayer 
     52    @ivar title: The layer title.  As seen in the Capabilities document. 
     53    @ivar abstract:  Abstract as seen in the Capabilities document. 
     54    """ 
     55    def __init__(self, title, abstract, feature): 
     56        self.title=title 
     57        self.abstract=abstract 
     58        self._feature=feature 
     59        bb= self._feature.getCSMLBoundingBox().getBox() 
     60        #convert 0 - 360 to -180, 180 as per common WMS convention 
     61        if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
     62            bb[0], bb[2]=-180, 180 
     63        self.wgs84BBox = bb 
Note: See TracChangeset for help on using the changeset viewer.