source: DPPP/kml/csml2kml/python/csml2kml/csml2kml/WMSLayerConvertor.py @ 3612

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/kml/csml2kml/python/csml2kml/csml2kml/WMSLayerConvertor.py@3612
Revision 3612, 2.5 KB checked in by mkochan, 14 years ago (diff)

Added Epydoc fields to comments.

Line 
1'''
2Contains the class C{WMSLayerConvertor}.
3'''
4
5from WMSLayer import *
6
7class WMSLayerConvertor:
8    '''
9    Encapsulates conversion from WMS layers to a KML file hierarchy.
10    '''
11
12    def __init__(self, topWmsLayer, wmsRequestConfigElement, baseKmlOutputDirectory, baseKmlOutputUrl):
13        '''
14        The constructor.
15        @param topWmsLayer: The top WMS layer to be converted.
16        @type topWmsLayer: C{WMSLayer.WMSLayer}
17        @param wmsRequestConfigElement: The I{<WMSRequest>} element from the config file (containing information
18        about how WMS requests are to be made, e.g. which server to use, what resolution to use, etc.)
19        @type wmsRequestConfigElement: C{cElementTree.Element}
20        @param baseKmlOutputDirectory: A directory to be used as the root of the output.
21        The KMZ file corresponding to the uppermost layer will be contained directly in this directory.
22        @type baseKmlOutputDirectory: C{str}
23        @param baseKmlOutputUrl: The URL from which the output will be served, corresponding to the root output directory.
24        @type baseKmlOutputUrl: C{str}
25        '''
26        self.topWmsLayer = topWmsLayer
27        self.wmsRequestConfigElement = wmsRequestConfigElement
28        self.baseKmlOutputDirectory = baseKmlOutputDirectory
29        self.baseKmlOutputUrl = baseKmlOutputUrl
30       
31    def convert(self):
32        '''
33        Perform the conversion.
34
35        This will create a hierarchy of KMZ files embedded in directories.
36        Each KMZ files encodes a single I{<wms:Layer>} element, as follows:
37          - Each KMZ file encoding a {non-bottom WMS layer} contains a number of I{<kml:NetworkLink>}'s mapping
38            to the KMZ files in a lower directory.
39            The I{<kml:NetworkLink>} contains an absolute URL of the target on the machine from the KMZ file
40            is being served.
41          - Each KML file encoding a I{bottom WMS layer} contains views of the data in the bottom layer,
42            with the views specified by the C{viewTypes} parameter.
43
44        The convertor uses the following 3 types of views, as defined in the C{WMSLayer} module:
45        C{ViewWholeTimecourse}, C{ViewSplittedByMonth}, C{ViewSplittedByPeriod}.
46        However, more views can be created (by extending {WMSLayer.View}) and added later.
47        '''
48        viewTypes = [ViewWholeTimecourse, ViewSplittedByMonth, ViewSplittedByPeriod]
49        self.topWmsLayer.toKML(self.wmsRequestConfigElement, viewTypes, self.baseKmlOutputDirectory, self.baseKmlOutputUrl)
Note: See TracBrowser for help on using the repository browser.