Changeset 4274 for cows


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

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

Location:
cows/trunk/cows
Files:
4 added
3 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 
  • cows/trunk/cows/service/imps/csmlbackend/wms_csmllayer.py

    r4272 r4274  
    11""" 
    2 implementation of ILayerMapper, ILayer, IDimension, ILayerSlab interfaces, as defined in wms_iface.py 
     2implementation of ILayerMapper, IwmsLayer, IwmsDimension, ILayerSlab interfaces, as defined in wms_iface.py & wxs_iface.py 
    33 
    44""" 
     
    99except: 
    1010    import cdms 
     11from pylons import config, request, session 
    1112import Image 
    1213from copy import copy 
     
    8586class CSMLwmsLayer(IwmsLayer): 
    8687    """ 
    87      representing a WMS layer.    Implements ILayer 
     88     representing a WMS layer.    Implements IwmsLayer 
    8889 
    8990    @ivar title: The layer title.  As seen in the Capabilities document. 
  • cows/trunk/cows/service/wxs_iface.py

    r4266 r4274  
    5353    @ivar title: The layer title.  As seen in the Capabilities document. 
    5454    @ivar abstract:  Abstract as seen in the Capabilities document. 
    55     @ivar dimensions: A mapping of dimension names to IDimension objects. 
    56     @ivar units: A string describing the units. 
    57     @ivar crss: A sequence of SRS/CRSs supported by this layer. 
    58     @ivar wgs84BBox: The bounding box in CRS:84 (lat/lon) 
    5955 
    6056    """ 
    61     title = abstract = dimensions = units = crss = wgs84BBox = NotImplemented 
     57    title = abstract = NotImplemented 
    6258    featureInfoFormats = NotImplemented 
    6359 
Note: See TracChangeset for help on using the changeset viewer.