Mercurial > mxd2map
annotate contrib/python/generateHTML.py @ 347:02d3c1665a46
Shorten long paths for better pdf representation
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 16 Nov 2012 17:02:33 +0100 |
parents | 4dc2b9aa3c57 |
children |
rev | line source |
---|---|
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
2 # |
256
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
3 # Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
4 # |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
5 # This file is part of MXD2map. |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
6 # |
256
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
7 # This program is free software under the LGPL (>=v2.1) |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
8 # Read the file LICENCE.txt coming with the software for details |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
9 # or visit http://www.gnu.org/licenses/ if it does not exist. |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
10 # |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
11 # MXD2map has been developed on behalf of the |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
12 # Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
13 # by Intevation GmbH. |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
14 # |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
15 # Authors: |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
16 # Raimund Renkert <raimund.renkert@intevation.de> |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
17 # Bjoern Schilberg <bjoern.schilberg@intevation.de> |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
18 # Stephan Holl <stephan.holl@intevation.de> |
4dc2b9aa3c57
Added LGPL header.
raimund renkert <raimund.renkert@intevation.de>
parents:
228
diff
changeset
|
19 |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
20 # |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
21 # Generate a HTML-Page based on a recursive folder structure of generated |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
22 # mapfiles from MXD2map |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
23 # |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
24 # |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
25 # Usage: generateHTML.py > output.html |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
26 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
27 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
28 import os |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
29 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
30 # this is intended to run in the folder where the generates mapfiles are |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
31 # stored: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
32 rootdir = os.getcwd() + '/map-test-2' |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
33 debug = False |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
34 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
35 # adopt for you needs: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
36 url = 'http://localhost/cgi-bin/mapserv.exe' |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
37 getmap = url + '?Request=GetMap&Service=WMS&Version=1.1.1' |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
38 getmap += '&srs=EPSG:4326&width=800&height=600&format=image/png&styles=' |
225
a9a3ce2625a8
Added Link to GetCapabilities
Stephan Holl <stephan.holl@intevation.de>
parents:
224
diff
changeset
|
39 getcaps = url + '?Request=GetCapabilities&Service=WMS&Version=1.1.1' |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
40 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
41 def writeHeader(): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
42 print '''<html> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
43 <head> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
44 <title>MXD2map-examples</title> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
45 <style> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
46 body { |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
47 font-family: arial, sans-serif; |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
48 font-size: 12pt; |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
49 } |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
50 </style> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
51 </head> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
52 <body> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
53 <h1>Verfuegbare MXD-Dateien</h1> |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
54 ''' |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
55 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
56 def writeFooter(): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
57 content = "</body></html>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
58 print content |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
59 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
60 def writeLayers(mapfile, layers, extent): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
61 basename = os.path.basename(mapfile) |
217
13f1cf17f620
[mq]: arcpy_image
Stephan Holl <stephan.holl@intevation.de>
parents:
216
diff
changeset
|
62 png = mapfile.replace(".map", "_arcpy.png") |
227
58d8ac962683
Replaced position of GetCaps-Link
Stephan Holl <stephan.holl@intevation.de>
parents:
226
diff
changeset
|
63 gc = getcaps + '&map=' + mapfile |
228
1cfb92731f48
Added link to the mapfile
Stephan Holl <stephan.holl@intevation.de>
parents:
227
diff
changeset
|
64 print '''<li>Layer: <strong><a target='_mapfile' href='file://%s'>%s</a></strong> | <a target='_getcaps' href='%s'>GetCapabilities</a></li> |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
65 <br> |
221
a44d442577ca
Fixes correct paths for Browser-output, added target for GROUP-output
Stephan Holl <stephan.holl@intevation.de>
parents:
217
diff
changeset
|
66 <a target="bild" href="file://%s"><img witdth="80" height="60" border="" src="file://%s"></a> |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
67 Anzahl der Layer: %s |
228
1cfb92731f48
Added link to the mapfile
Stephan Holl <stephan.holl@intevation.de>
parents:
227
diff
changeset
|
68 ''' % (mapfile, basename, gc, png, png, len(layers)) |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
69 i = 0 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
70 print "<ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
71 while i < len(layers): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
72 urlmapfile = url + '?map=' + mapfile |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
73 urlmapfile += '&template=openlayers&mode=browse&layers=' + layers[i] |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
74 gm = getmap + '&map=' + mapfile + '&layers=' + layers[i] |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
75 if extent: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
76 ext = str(extent).strip('[\'\'\\r\\n]') |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
77 gm += '&bbox='+''.join(ext) |
227
58d8ac962683
Replaced position of GetCaps-Link
Stephan Holl <stephan.holl@intevation.de>
parents:
226
diff
changeset
|
78 print "<li><a target='_new' href='%s'>%s</a> | <a target='_getmap' href='%s'>WMS GetMap</a></li>" % (urlmapfile, layers[i], gm) |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
79 i=i+1 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
80 print "</ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
81 |
216
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
82 def generateArcImage(mapfile): |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
83 basename = os.path.basename(mapfile) |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
84 mxdfile = mapfile.replace(".map",".mxd") |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
85 output = mapfile.replace(".map", "_arcpy.png") |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
86 if debug: |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
87 print "MXDfile: %s\nOutput: %s " % (mxdfile, output) |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
88 |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
89 if not output: |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
90 import arcpy |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
91 mxd = arcpy.mapping.MapDocument(mxdfile) |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
92 df = arcpy.mapping.ListDataFrames(mxd)[0] |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
93 arcpy.mapping.ExportToPNG(mxd, output, df, df_export_width=800, |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
94 df_export_height=600, world_file=True) |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
95 del mxd |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
96 |
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
97 |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
98 def writeGroups(mapfile,groups): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
99 if len(groups) > 1: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
100 print "Anzahl der Gruppen: %s" % len(groups) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
101 i = 0 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
102 print "<ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
103 while i < len(groups): |
222
316a2b3d4126
added switch for replacing backslashes in win32
Stephan Holl <stephan.holl@intevation.de>
parents:
221
diff
changeset
|
104 if os.name == "nt": |
316a2b3d4126
added switch for replacing backslashes in win32
Stephan Holl <stephan.holl@intevation.de>
parents:
221
diff
changeset
|
105 mapfile = mapfile.replace('\\', '/') |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
106 urlmapfile = url + '?map=' + mapfile |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
107 urlmapfile += '&template=openlayers&mode=browse&layers=' + groups[i] |
221
a44d442577ca
Fixes correct paths for Browser-output, added target for GROUP-output
Stephan Holl <stephan.holl@intevation.de>
parents:
217
diff
changeset
|
108 print "<li><a target='_group' href='%s'>%s</a></li>" % (urlmapfile, groups[i]) |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
109 i=i+1 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
110 print "</ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
111 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
112 def main(): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
113 writeHeader() |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
114 for root, subFolders, files in os.walk(rootdir): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
115 for file in files: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
116 f = os.path.join(root, file) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
117 if os.path.isfile(f): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
118 basename, extension = os.path.splitext(f) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
119 if extension.lower() == ".map": |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
120 if "orig" in f: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
121 # do not generate links for -orig.map-files |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
122 continue |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
123 if debug: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
124 print "Bearbeite Dokument %s" % f |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
125 #read file and search for wms_title |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
126 layers = [] |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
127 groups = [] |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
128 extent = [] |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
129 for line in open(f): |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
130 if "wms_title" in line: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
131 #print line |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
132 la = line.strip()[12:].replace('"','') |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
133 if la != "Layers": |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
134 layers.append(la) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
135 if "GROUP" in line: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
136 gr = line.strip()[6:].replace('"','') |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
137 if gr not in groups: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
138 groups.append(gr) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
139 if "EXTENT" in line: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
140 ext = line[9:].replace('"','').replace(' ', ',') |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
141 extent.append(ext) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
142 |
216
d0acdab62b03
imported patch arcpy-erweiterung
Stephan Holl <stephan.holl@intevation.de>
parents:
208
diff
changeset
|
143 generateArcImage(f) |
208
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
144 print "<ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
145 writeLayers(f, layers, extent) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
146 print "</ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
147 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
148 # write groups |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
149 print "<ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
150 writeGroups(f, groups) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
151 print "</ul>" |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
152 if debug: |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
153 print "Layer %s hat %s Layer" % (f, len(layers)) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
154 print "Layer %s hat %s Gruppen" % (f, len(groups)) |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
155 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
156 writeFooter() |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
157 |
0c58db91311c
* contrib/python/generateHTML.py: New. Script for generating a
Stephan Holl <stephan.holl@intevation.de>
parents:
diff
changeset
|
158 main() |