source: DPPP/kml/csml2kml/python/csml2kml/csml2kml/tests/testWMSCapabilities.py @ 3559

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/kml/csml2kml/python/csml2kml/csml2kml/tests/testWMSCapabilities.py@3559
Revision 3559, 1.2 KB checked in by mkochan, 13 years ago (diff)

Changed interaction with WMS script.

Line 
1import getopt
2from cElementTree import ElementTree, XML
3import utils
4from WMSCapabilities import *
5import sys
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( utils.wget(wmsCapabilitiesUrl) )
24wmsCapabilities = WMSCapabilities()
25wmsCapabilities.parseXML(wmsCapabilitiesElement)
26
27# Initialise the convertor and perform the conversion
28wmsLayersConvertor = WMSLayersConvertor(
29    wmsCapabilities.topWmsLayer, wmsRequestConfigElement, outputRootDirectory, serverRootDirectory
30    )
31wmsLayersConvertor.convert()
Note: See TracBrowser for help on using the repository browser.