source: TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/wms_iface.py @ 3554

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/wms_iface.py@3554
Revision 3554, 3.6 KB checked in by spascoe, 13 years ago (diff)

Changed the way we associate a layerMapper with WMSController.

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
13class ILayerMapper(object):
14    """
15    Map keyword arguments to a collection of layers.
16
17    ILayerMapper supports the retrieval of sets of layers according to arbitary
18    keyword/value pairs.
19   
20    """
21    def map(self, **kwargs):
22        """
23        Given arbitary keywords/value pairs list the names of
24        all layers available.
25
26        @return: A mapping of layer names to ILayer implementations.
27        @raise ValueError: If no layers are available for these keywords.
28
29        """
30        raise NotImplementedError
31
32
33class ILayer(object):
34    """
35    An interface representing a WMS layer.
36
37    @ivar title: The layer title.  As seen in the Capabilities document.
38    @ivar abstract:  Abstract as seen in the Capabilities document.
39    @ivar dimensions: A dictionary of IDimension objects.
40    @ivar units: A string describing the units.
41    @ivar crss: A sequence of SRS/CRSs supported by this layer.
42
43    @todo: Do we need minValue/maxValue?
44
45    """
46    title = abstract = dimensions = units = crss = NotImplemented
47
48    def getBBox(self, crs):
49        """
50        @return: A 4-typle of the bounding box in the given coordinate
51            reference system.
52
53        """
54        raise NotImplementedError
55
56    def getSlab(self, crs, dimValues=None, renderOpts={}):
57        """
58        Creates a slab of the layer in a particular CRS and set of
59        dimensions.
60
61        @param crs: The coordinate reference system.
62        @param dimValues: A mapping of dimension names to dimension values
63            as specified in the IDimension.extent
64        @param renderOpts: A generic mapping object for passing rendering
65            options
66        @return: An object implementing ILayerSlab
67
68        """
69        raise NotImplementedError
70
71    def getCacheKey(self, crs, dimValues=None, renderOpts={}):
72        """
73        Create a unique key for use in caching a slab.
74
75        The intention here is that most of the work should be done when
76        instantiating an ILayerSlab object.  These can be cached by the
77        server for future use.  The server will first call getCacheKey()
78        for the slab creation arguments and if the key is in it's cache
79        it will use a pre-generated ILayerSlab object.
80
81        """
82        raise NotImplementedError
83
84
85class IDimension(object):
86    """
87    @ivar units: The units string.
88    @ivar extent: Sequence of extent values.
89
90    """
91    units = extent = NotImplemented
92
93class ILayerSlab(object):
94    """
95    An interface representing a particular horizontal slice of a WMS layer.
96
97    ILayerSlab objects are designed to be convenient to cache.
98    They should be pickleable to enable memcached support in the future.
99
100    @ivar layer: The source ILayer instance.
101    @ivar crs: The coordinate reference system.
102    @ivar dimValues: A mapping of dimension values of this view.
103    @ivar renderOpts: The renderOpts used to create this view.
104    @ivar bbox: The bounding box as a 4-tuple.
105
106    """
107    layer = crs = dimValues = renderOpts = bbox = NotImplemented
108
109    def getImage(self, bbox, width, height):
110        """
111        Create an image of a sub-bbox of a given size.
112
113        @ivar bbox: A bbox 4-tuple.
114        @ivar width: width in pixels.
115        @ivar height: height in pixels.
116        @return: A PIL Image object.
117
118        """
119        raise NotImplementedError
120
Note: See TracBrowser for help on using the repository browser.