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

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@3548
Revision 3548, 3.2 KB checked in by spascoe, 12 years ago (diff)

Added a simple data interface for WMS. This may not live in ows_common
in the long term but is the most convenient place to put it for now.

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
72class IDimension(object):
73    """
74    @ivar units: The units string.
75    @ivar extent: Sequence of extent values.
76
77    """
78    units = extent = NotImplemented
79
80class ILayerSlab(object):
81    """
82    An interface representing a particular horizontal slice of a WMS layer.
83
84    ILayerSlab objects are designed to be convenient to cache.
85    They should be pickleable to enable memcached support in the future.
86
87    @ivar layer: The source ILayer instance.
88    @ivar CRS: The coordinate reference system.
89    @ivar dimValues: A mapping of dimension values of this view.
90    @ivar renderOpts: The renderOpts used to create this view.
91    @ivar bbox: The bounding box as a 4-tuple.
92
93    """
94    layer = CRS = dimValues = renderOpts = bbox = NotImplemented
95
96    def getImage(self, bbox, width, height):
97        """
98        Create an image of a sub-bbox of a given size.
99
100        @ivar bbox: A bbox 4-tuple.
101        @ivar width: width in pixels.
102        @ivar height: height in pixels.
103        @return: A PIL Image object.
104
105        """
106        raise NotImplementedError
107
108    def getCacheKey(self):
109        """
110        Create a unique key for use in caching.
111
112        """
113        raise NotImplementedError
Note: See TracBrowser for help on using the repository browser.