source: DPPP/kml/python/csml2kml/csml2kml/ @ 3757

Subversion URL:
Revision 3757, 2.4 KB checked in by mkochan, 11 years ago (diff)

Made list of views views to be used in wms2kml configurable. Enforced timestamps in WMS queries to contain ".0" for microseconds.

2Contains the class C{WMSLayerConvertor}.
5from WMSLayer import *
7class WMSLayerConvertor:
8    '''
9    Encapsulates conversion from WMS layers to a KML file hierarchy.
10    '''
12    def __init__(self, topWmsLayer, viewTypes, 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.viewTypes = viewTypes
28        self.wmsRequestConfigElement = wmsRequestConfigElement
29        self.baseKmlOutputDirectory = baseKmlOutputDirectory
30        self.baseKmlOutputUrl = baseKmlOutputUrl
32    def convert(self):
33        """
34        Perform the conversion.
36        This will create a hierarchy of KMZ files embedded in directories.
37        Each KMZ files encodes a single I{<wms:Layer>} element, as follows:
38          - Each KMZ file encoding a {non-bottom WMS layer} contains a number of I{<kml:NetworkLink>}'s mapping
39            to the KMZ files in a lower directory.
40            The I{<kml:NetworkLink>} contains an absolute URL of the target on the machine from the KMZ file
41            is being served.
42          - Each KML file encoding a I{bottom WMS layer} contains views of the data in the bottom layer,
43            with the views specified by the C{viewTypes} parameter.
45        The convertor uses the following 3 types of views, as defined in the C{WMSLayer} module:
46        C{ViewWholeTimecourse}, C{ViewSplittedByMonth}, C{ViewSplittedByPeriod}.
47        However, more views can be created (by extending {WMSLayer.View}) and added later.
48        """
49        self.topWmsLayer.toKML(self.wmsRequestConfigElement, self.viewTypes, self.baseKmlOutputDirectory, self.baseKmlOutputUrl)
Note: See TracBrowser for help on using the repository browser.