source: DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms/interfaces.py @ 3532

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms/interfaces.py@3532
Revision 3532, 2.7 KB checked in by spascoe, 14 years ago (diff)

Moving to a different interface between the WMS controller and the
data. interfaces.py now contains ILayer et al. to represent layers
of data.

Line 
1"""
2Refactored model of object to support WMS requests through
3ows_server.
4
5Primary goals of this model is to:
6 - support multiple dimensions.
7 - Allow caching of layer views by dimensions and CRS to mitigate
8   the overhead of data retreival and rendering.
9 - To hide how layers are actually retrieved and rendered from ows_server.
10
11"""
12
13
14class ILayer(object):
15    """
16    An interface representing a WMS layer.
17
18    @ivar title: The layer title.  As seen in the Capabilities document.
19    @ivar abstract:  Abstract as seen in the Capabilities document.
20    @ivar dimensions: A dictionary of IDimension objects.
21    @ivar units: A string describing the units.
22    @ivar crss: A sequence of SRS/CRSs supported by this layer.
23
24    @todo: Do we need minValue/maxValue?
25
26    """
27    title = abstract = dimensions = units = crss = NotImplemented
28
29    def getBBox(self, crs):
30        """
31        @return: A 4-typle of the bounding box in the given coordinate
32            reference system.
33
34        """
35        raise NotImplementedError
36
37    def getView(self, crs, dimValues=None, renderOpts={}):
38        """
39        Creates a view of the layer in a particular CRS and set of
40        dimensions.
41
42        @param crs: The coordinate reference system.
43        @param dimValues: A mapping of dimension names to dimension values
44            as specified in the IDimension.extent
45        @param renderOpts: A generic mapping object for passing rendering
46            options
47        @return: An object implementing ILayerView
48
49        """
50        raise NotImplementedError
51   
52
53
54class IDimension(object):
55    """
56    @ivar units: The units string
57    @ivar extent: The extent string
58
59    """
60    units = extent = NotImplemented
61
62class ILayerView(object):
63    """
64    An interface representing a particular view of a WMS layer.
65
66    ILayerView objects are designed to be convenient to cache.
67    They should be pickleable to enable memcached support in the future.
68
69    @ivar layer: The source ILayer instance.
70    @ivar CRS: The coordinate reference system.
71    @ivar dimValues: A mapping of dimension values of this view.
72    @ivar renderOpts: The renderOpts used to create this view.
73    @ivar bbox: The bounding box as a 4-tuple.
74
75    """
76    layer = CRS = dimValues = renderOpts = bbox = NotImplemented
77
78    def getImage(self, bbox, width, height):
79        """
80        Create an image of a sub-bbox of a given size.
81
82        @ivar bbox: A bbox 4-tuple.
83        @ivar width: width in pixels.
84        @ivar height: height in pixels.
85        @return: A PIL Image object.
86
87        """
88        raise NotImplementedError
89
90    def getCacheKey(self):
91        """
92        Create a unique key for use in caching.
93
94        """
95        raise NotImplementedError
Note: See TracBrowser for help on using the repository browser.