stephan@208: #!/usr/bin/env python stephan@208: # stephan@208: # (C) 2011, Intevation GmbH, Stephan Holl stephan@208: # stephan@208: # stephan@208: # Generate a HTML-Page based on a recursive folder structure of generated stephan@208: # mapfiles from MXD2map stephan@208: # stephan@208: # stephan@208: # Usage: generateHTML.py > output.html stephan@208: stephan@208: stephan@208: import os stephan@208: stephan@208: # this is intended to run in the folder where the generates mapfiles are stephan@208: # stored: stephan@208: rootdir = os.getcwd() + '/map-test-2' stephan@208: debug = False stephan@208: stephan@208: # adopt for you needs: stephan@208: url = 'http://localhost/cgi-bin/mapserv.exe' stephan@208: getmap = url + '?Request=GetMap&Service=WMS&Version=1.1.1' stephan@208: getmap += '&srs=EPSG:4326&width=800&height=600&format=image/png&styles=' stephan@208: stephan@208: def writeHeader(): stephan@208: print ''' stephan@208: stephan@208: MXD2map-examples stephan@208: stephan@208: stephan@208: stephan@208:

Verfuegbare MXD-Dateien

stephan@208: ''' stephan@208: stephan@208: def writeFooter(): stephan@208: content = "" stephan@208: print content stephan@208: stephan@208: def writeLayers(mapfile, layers, extent): stephan@208: basename = os.path.basename(mapfile) stephan@208: print '''
  • Layer: %s
  • stephan@208:
    stephan@208: Anzahl der Layer: %s stephan@208: ''' % (basename, len(layers)) stephan@208: i = 0 stephan@208: print "" stephan@208: stephan@208: def writeGroups(mapfile,groups): stephan@208: if len(groups) > 1: stephan@208: print "Anzahl der Gruppen: %s" % len(groups) stephan@208: i = 0 stephan@208: print "" stephan@208: stephan@208: def main(): stephan@208: writeHeader() stephan@208: for root, subFolders, files in os.walk(rootdir): stephan@208: for file in files: stephan@208: f = os.path.join(root, file) stephan@208: if os.path.isfile(f): stephan@208: basename, extension = os.path.splitext(f) stephan@208: if extension.lower() == ".map": stephan@208: if "orig" in f: stephan@208: # do not generate links for -orig.map-files stephan@208: continue stephan@208: if debug: stephan@208: print "Bearbeite Dokument %s" % f stephan@208: #read file and search for wms_title stephan@208: layers = [] stephan@208: groups = [] stephan@208: extent = [] stephan@208: for line in open(f): stephan@208: if "wms_title" in line: stephan@208: #print line stephan@208: la = line.strip()[12:].replace('"','') stephan@208: if la != "Layers": stephan@208: layers.append(la) stephan@208: if "GROUP" in line: stephan@208: gr = line.strip()[6:].replace('"','') stephan@208: if gr not in groups: stephan@208: groups.append(gr) stephan@208: if "EXTENT" in line: stephan@208: ext = line[9:].replace('"','').replace(' ', ',') stephan@208: extent.append(ext) stephan@208: stephan@208: print "" stephan@208: stephan@208: # write groups stephan@208: print "" stephan@208: if debug: stephan@208: print "Layer %s hat %s Layer" % (f, len(layers)) stephan@208: print "Layer %s hat %s Gruppen" % (f, len(groups)) stephan@208: stephan@208: writeFooter() stephan@208: stephan@208: main()