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

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

Deployed the "csml2kml" package as a development egg. Consequently changed import commands in wms2kml.py.

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