Changeset 4266 for cows


Ignore:
Timestamp:
02/10/08 10:19:58 (11 years ago)
Author:
domlowe
Message:

Splitting wms_iface into wxs_iface and wms_iface interfaces.
Modifying implemenations of wms_iface to inherit from new interfaces.

Location:
cows/trunk/cows/service
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/wms_csmllayer.py

    r4228 r4266  
    2020import ConfigParser 
    2121 
     22from cows.service.wxs_iface import ILayerMapper 
     23from cows.service.wms_iface import IwmsLayer, IwmsDimension, IwmsLayerSlab 
     24 
    2225try: 
    2326    from ndgUtils import ndgObject, ndgRetrieve 
     
    2629 
    2730 
    28 class CSMLLayerMapper(object): 
     31 
     32 
     33class CSMLLayerMapper(ILayerMapper): 
    2934    """ 
    3035    Map keyword arguments to a collection of layers. 
     
    128133 
    129134 
    130 class CSMLLayer(object): 
     135class CSMLLayer(IwmsLayer): 
    131136    """ 
    132137     representing a WMS layer.    Implements ILayer 
     
    294299 
    295300 
    296 class CSMLDimension(object): 
     301class CSMLDimension(IwmsDimension): 
    297302    """ 
    298303    implements IDimension 
     
    322327            self.units='ISO8601' 
    323328        
    324 class CSMLLayerSlab(object): 
     329class CSMLLayerSlab(IwmsLayerSlab): 
    325330    """ 
    326331    Implements LayerSlab 
  • cows/trunk/cows/service/imps/wms_gdal.py

    r4106 r4266  
    99 
    1010""" 
    11  
    12 from cows.service.wms_iface import * 
     11from cows.service.wxs_iface import ILayerMapper 
     12from cows.service.wms_iface import IwmsLayer, IwmsDimension, IwmsLayerSlab 
    1313from cows.bbox_util import geoToPixel 
    1414from osgeo import osr, gdal 
     
    6767 
    6868 
    69 class GDALLayer(ILayer): 
    70     """ 
    71     This implementation of ILayer can warp images from a source CRS to 
     69class GDALLayer(IwmsLayer): 
     70    """ 
     71    This implementation of IwmsLayer can warp images from a source CRS to 
    7272    various other CRSs. 
    7373 
     
    129129        return str((x, y)) 
    130130 
    131 class GDALLayerSlab(ILayerSlab): 
     131class GDALLayerSlab(IwmsLayerSlab): 
    132132    def __init__(self, layer, crs, dimValues=None, renderOpts={}): 
    133133        self.layer = layer 
  • cows/trunk/cows/service/imps/wms_layers.py

    r4228 r4266  
    1818from matplotlib import dates  
    1919 
     20from cows.service.wxs_iface import ILayerMapper 
     21from cows.service.wms_iface import IwmsLayer, IwmsDimension, IwmsLayerSlab 
     22 
    2023import logging 
    2124log = logging.getLogger(__name__) 
    2225 
    23 class WMSLayerMapper(object): 
     26class WMSLayerMapper(ILayerMapper): 
    2427    """ 
    2528    Map keyword arguments to a collection of layers. 
     
    111114 
    112115 
    113 class StationLayer(object): 
     116class StationLayer(IwmsLayer): 
    114117    """ 
    115118    representing a WMS layer for MIDAS/ECN Stations.    Implements ILayer 
     
    238241        return legImage 
    239242 
    240 class StationDimension(object): 
     243class StationDimension(IwmsDimension): 
    241244    """ 
    242245    implements IDimension 
     
    255258         
    256259         
    257 class StationLayerSlab(object): 
     260class StationLayerSlab(IwmsLayerSlab): 
    258261    """ 
    259262    Implements LayerSlab 
  • cows/trunk/cows/service/wms_iface.py

    r4008 r4266  
    11""" 
    22The classes in this module define an interface between the OWS Pylons 
    3 server and components that provide Web Map Server layers.  The 
    4 intention is that a WMS can be created for a given datatype and 
    5 renderring engine by creating classes that implement these interfaces 
    6 -- there is no need to mess around with Pylons controllers or the 
    7 cows metadata model. 
     3server and components that provide Web Map Server layers. They extend the interfaces 
     4defined in wxs_iface.py. 
    85 
    96The interface was designed with several requirements in mind: 
     
    1411 - To hide how layers are actually retrieved and rendered from ows_server. 
    1512 
    16 The main entry point for the OWS Pylons server is the ILayerMapper 
    17 interface.  This provides a mechanism for serving multiple WMS 
    18 endpoints through a single server.  Keywords deduced from the pylons 
    19 routes mapper are passed to the ILayerMapper instance to return a 
    20 dictionary of ILayer instances.  These are the layers available to the 
    21 WMS on this route. 
    22  
    23 ILayer instances provide dimension and CRS information to the server 
     13IwmsLayer instances provide dimension and CRS information to the server 
    2414and can render a legend.  A layer image is requested by a two stage 
    2515process.  First the CRS and non-geospatial dimensions are selected 
    26 through ILayer to return a ILayerSlab instance.  WMS images are then 
    27 retrieved through ILayerSlab for a given bounding box. 
     16through IwmsLayer to return a IwmsLayerSlab instance.  WMS images are then 
     17retrieved through IwmsLayerSlab for a given bounding box. 
    2818 
    2919This allows implementations to cache the result if it makes sense to 
    30 do so.  implementing ILayer.getCacheKey() will cause the server to 
    31 cache ILayerSlab objects for future use, therefore not requiring 
    32 repeated calls to ILayer.getSlab().  This strategy works well with 
     20do so.  implementing IwmsLayer.getCacheKey() will cause the server to 
     21cache IwmsLayerSlab objects for future use, therefore not requiring 
     22repeated calls to IwmsLayer.getSlab().  This strategy works well with 
    3323tiling WMS clients that will make multiple GetMap requests with the 
    3424same CRS and dimension parameters. 
    3525 
    36 It is expected that implementing classes will inherit from these 
    37 interface classes, using them as abstract base classes.  However, in 
    38 the future zope.Interface might be used to associate interfaces with 
    39 implementations. 
    4026 
    4127 
    4228""" 
    4329 
    44 class ILayerMapper(object): 
    45     """ 
    46     Maps keyword arguments to a collection of layers. 
     30from wxs_iface import ILayer 
    4731 
    48     ILayerMapper supports the retrieval of sets of layers according to arbitary 
    49     keyword/value pairs. 
    50  
    51     """ 
    52     def map(self, **kwargs): 
    53         """ 
    54         Given arbitary keywords/value pairs list the names of 
    55         all layers available. 
    56  
    57         @return: A mapping of layer names to ILayer implementations. 
    58         @raise ValueError: If no layers are available for these keywords. 
    59  
    60         """ 
    61         raise NotImplementedError 
    6232         
    6333 
    64 class ILayer(object): 
     34class IwmsLayer(ILayer): 
    6535    """ 
    66     An interface representing a WMS layer. 
    67  
    68     @ivar title: The layer title.  As seen in the Capabilities document. 
    69     @ivar abstract:  Abstract as seen in the Capabilities document. 
    70     @ivar dimensions: A mapping of dimension names to IDimension objects. 
    71     @ivar units: A string describing the units. 
    72     @ivar crss: A sequence of SRS/CRSs supported by this layer. 
    73     @ivar wgs84BBox: The bounding box in CRS:84 (lat/lon) 
     36    An interface representing a WMS layer, based on ILayer. 
     37     
    7438    @ivar legendSize: (width, height) in pixels of legend. 
    7539 
     
    8145 
    8246    """ 
    83     title = abstract = dimensions = units = crss = wgs84BBox = NotImplemented 
    84     featureInfoFormats = NotImplemented 
    8547 
    86     def getBBox(self, crs): 
    87         """ 
    88         @return: the bounding box (llx, lly, urx, ury) in the given 
    89             coordinate reference system. 
    90  
    91         """ 
    92         raise NotImplementedError 
    9348 
    9449    def getSlab(self, crs, dimValues=None, renderOpts={}): 
     
    150105         
    151106 
    152 class IDimension(object): 
     107class IwmsDimension(object): 
    153108    """ 
    154109    An interface representing a WMS dimension 
     
    160115    units = extent = NotImplemented 
    161116 
    162 class ILayerSlab(object): 
     117class IwmsLayerSlab(object): 
    163118    """ 
    164119    An interface representing a particular horizontal slice of a WMS layer. 
    165120 
    166     ILayerSlab objects are designed to be convenient to cache. 
     121    IwmsLayerSlab objects are designed to be convenient to cache. 
    167122    Ideally they should be pickleable to enable memcached support in 
    168123    the future. 
    169124 
    170     @ivar layer: The source ILayer instance. 
     125    @ivar layer: The source IwmsLayer instance. 
    171126    @ivar crs: The coordinate reference system. 
    172127    @ivar dimValues: A mapping of dimension values of this view. 
Note: See TracChangeset for help on using the changeset viewer.