source: DPPP/kml/csml2kml/python/csml2kml/csml2kml/scripts/wms2kml.py @ 3595

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/kml/csml2kml/python/csml2kml/csml2kml/scripts/wms2kml.py@3595
Revision 3595, 1.3 KB checked in by mkochan, 12 years ago (diff)

Split WMSLayer-related functionality into two modules: WMSLayer.py and WMSLayerConvertor.py.

Line 
1import sys
2from cElementTree import ElementTree, XML
3from csml2kml.utils import wget
4from csml2kml.WMSLayer import WMSCapabilities
5from csml2kml.WMSLayerConvertor import WMSLayerConvertor
6
7# Get the config file name
8if len(sys.argv) != 2:
9    raise ValueError('The name of config file (and nothing more) required')
10configFileName = sys.argv[1]
11
12# Load the config file (in XML format)
13configElementTree = ElementTree()
14configElementTree.parse(configFileName)
15
16# Read the output root directory, and the root network URL where the output will be stored
17outputRootDirectory = configElementTree.getroot().find('OutputRootDirectory').text
18serverRootDirectory = configElementTree.getroot().find('ServerRootDirectory').text
19
20# Read in the Layers document from the source WMS service
21wmsRequestConfigElement = configElementTree.getroot().find('WMSRequest')
22wmsCapabilitiesUrl = wmsRequestConfigElement.find('URL').text + '?request=GetCapabilities'
23wmsCapabilitiesElement = XML( wget(wmsCapabilitiesUrl) )
24wmsCapabilities = WMSCapabilities()
25wmsCapabilities.parseXML(wmsCapabilitiesElement)
26
27# Initialise the convertor and perform the conversion
28wmsLayerConvertor = WMSLayerConvertor(
29    wmsCapabilities.topWmsLayer, wmsRequestConfigElement, outputRootDirectory, serverRootDirectory
30    )
31wmsLayerConvertor.convert()
Note: See TracBrowser for help on using the repository browser.