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

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

changing entry points for python scripts

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