-
Notifications
You must be signed in to change notification settings - Fork 11
/
gen_historischebodeminformatie.py
241 lines (193 loc) · 10.4 KB
/
gen_historischebodeminformatie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import re
import random
from generate import block, header, p, q
def slugify(s: str) -> str:
# TODO would be cleaner to convert to NFD, then remove combining chars.
s = s.replace("ë", "e")
return re.sub(r"[^A-Za-z]+", "_", s).strip("_").lower()
layers = [
("Bodemgebruik en obstakels", "Boerderij", "Boerderij", ('#ebdc56', False)), #VLAK zit in 'objecten' tabel
("Bodemgebruik en obstakels", "Defensieterrein", "Defensieterrein", ('#d5587c', False)),
("Bodemgebruik en obstakels", "Fabriek/bedrijventerrein", "Fabriek/bedrijventerrein", ('#a78409', False)),
("Bodemgebruik en obstakels", "Gebouw", "Gebouw", ('#0e6f99', False)),
("Bodemgebruik en obstakels", "Glastuinbouw", "Glastuinbouw", ('#9bca54', False)),
("Bodemgebruik en obstakels", "Object", "Object", ('#03cea2', False)),
("Bodemgebruik en obstakels", "Overig", "Overig", ('#d00ee5', False)),
("Bodemgebruik en obstakels", "Spoorwegemplacement", "Spoorwegemplacement", ('#ae95b9', False)),
("Bodemgebruik en obstakels", "Stookruimte/olietank", "Stookruimte/olietank", ('#713dbe', False)),
("Bodemgebruik en obstakels", "Tram- en busremises", "Tram- en busremises", ('#3a15e1', False)),
("Bodemgebruik en obstakels", "Volkstuinen", "Volkstuinen", ('#06d3f7', False)),
("Lijnvormige obstakels", "Gasbuis", "Gasbuis", ('#bfb479', True)), #LIJN zit in 'kabels en leidingen'
("Lijnvormige obstakels", "Grondkering", "Grondkering", ('#d7650e',False)),
("Lijnvormige obstakels", "Kabel", "Kabel", ('#d67814', True)),
("Lijnvormige obstakels", "Mantelbuis", "Mantelbuis", ('#79e0d4', True)),
("Lijnvormige obstakels", "Persleiding", "Persleiding", ('#20a620', True)),
("Lijnvormige obstakels", "Riool", "Riool", ('#0e5129', True)),
("Lijnvormige obstakels", "Spoorweg", "Spoorweg", ('#232323', True)),
("Lijnvormige obstakels", "Waterleiding", "Waterleiding", ('#3a15e1', True)),
("Dempingen en ophogingen", "Demping", "Demping", ('#e4d62e', False)), #dit zit uiteraard in dempingen en ophogingen
("Dempingen en ophogingen", "Depot/stort", "Depot/stort", ('#ce7263', False)),
("Dempingen en ophogingen", "Dijk", "Dijk", ('#66b2b1', False)),
("Dempingen en ophogingen", "Ophoging", "Ophoging", ('#8c8c8b', False))
]
with block("MAP"):
p("NAME", "historischebodeminformatie")
p("INCLUDE", "header.inc")
# with block("PROJECTION"):
# q("init=epsg:28992")
with block("WEB"):
with block("METADATA"):
q("ows_title", "Historische Bodeminformatie")
q("ows_onlineresource", "MAP_URL_REPLACE/maps/historischebodeminformatie")
q("ows_abstract", "Historische Bodeminformatie",)
for group, layer_name, filter_value, colors in layers:
if group == "Bodemgebruik en obstakels":
with block("LAYER"):
sql = f"geometrie from (SELECT * FROM public.historische_bodeminformatie_bodemgebruik_en_obstakels where categorie = '{filter_value}') as subquery USING srid=28992 USING UNIQUE id"
layer_name_slug = slugify(layer_name)
p("NAME", layer_name_slug)
p("INCLUDE", "connection/dataservices.inc")
p("DATA", sql)
p('GROUP', slugify(group))
p("TYPE POLYGON")
p("TEMPLATE", "fooOnlyForWMSGetFeatureInfo.html")
p("LABELITEM", "beschrijving")
with block("METADATA"):
q("ows_title", layer_name)
q('ows_group_title', group)
q("wms_include_items", "all")
q("ows_abstract", "Bodemgebruik en obstakels")
q("gml_featureid", "id")
q("gml_geometries", "geometry")
q("gml_geometry_type", "polygon")
q("gml_include_items", "all")
q("gml_types", "auto")
with block("CLASS"):
p("NAME", f"{layer_name_slug}")
p("TITLE", f"{layer_name}")
with block("STYLE"):
p(f'COLOR "{colors[0]}"')
p("OPACITY", 40)
with block("STYLE"):
p(f'OUTLINECOLOR "{colors[0]}"')
p("WIDTH ", 2)
with block("LABEL"):
p("MAXSCALEDENOM 5000")
p("COLOR 0 0 0")
p("OUTLINECOLOR 255 255 255")
p("OUTLINEWIDTH 3")
p("FONT", "Ubuntu-M")
p("TYPE truetype")
p("SIZE 8")
p("POSITION AUTO")
p("PARTIALS FALSE")
p("OFFSET -60 10")
if group == "Lijnvormige obstakels":
with block("LAYER"):
sql = f"geometrie from (SELECT * FROM public.historische_bodeminformatie_lijnvormige_obstakels where categorie = '{filter_value}') as subquery USING srid=28992 USING UNIQUE id"
layer_name_slug = slugify(layer_name)
p("NAME", layer_name_slug)
p("INCLUDE", "connection/dataservices.inc")
p("DATA", sql)
p('GROUP', slugify(group))
p("TYPE LINE")
p("TEMPLATE", "fooOnlyForWMSGetFeatureInfo.html")
p("LABELITEM", "beschrijving")
with block("METADATA"):
q("ows_title", layer_name)
q('ows_group_title', group)
q("wms_include_items", "all")
q("ows_abstract", 'Lijnvormige obstakels')
q("gml_featureid", "id")
q("gml_geometries", "geometrie")
q("gml_geometry_type", "linestring")
q("gml_include_items", "all")
q("gml_types", "auto")
with block("CLASS"):
p("NAME", f"{layer_name_slug}")
p("TITLE", f"{layer_name}")
with block("STYLE"):
p(f'COLOR "{colors[0]}"')
p(f'OUTLINECOLOR "{colors[0]}"')
p("WIDTH ", 2)
if colors[1] == True:
with block("PATTERN"):
print ("3 3")
with block("LABEL"):
p("MAXSCALEDENOM 3000")
p("COLOR 0 0 0")
p("OUTLINECOLOR 255 255 255")
p("OUTLINEWIDTH 3")
p("FONT", "Ubuntu-M")
p("TYPE truetype")
p("SIZE 8")
p("POSITION AUTO")
p("PARTIALS FALSE")
p("OFFSET -60 10")
if group == "Dempingen en ophogingen":
with block("LAYER"):
sql = f"geometrie from (SELECT * FROM public.historische_bodeminformatie_dempingen_en_ophogingen where categorie = '{filter_value}') as subquery USING srid=7415 USING UNIQUE id"
layer_name_slug = slugify(layer_name)
p("NAME", layer_name_slug)
p("INCLUDE", "connection/dataservices.inc")
p("DATA", sql)
p('GROUP', slugify(group))
p("TYPE POLYGON")
p("TEMPLATE", "fooOnlyForWMSGetFeatureInfo.html")
with block("METADATA"):
q("ows_title", layer_name)
q('ows_group_title', group)
q("wms_include_items", "all")
q("ows_abstract", 'Dempingen en ophogingen')
q("gml_featureid", "id")
q("gml_geometries", "geometrie")
q("gml_geometry_type", "polygon")
q("gml_include_items", "all")
q("gml_types", "auto")
with block("CLASS"):
p("NAME", f"{layer_name_slug}")
p("TITLE", f"{layer_name}")
with block("STYLE"):
p(f'COLOR "{colors[0]}"')
p("OPACITY", 40)
#tweede style block om te voorkomen dat de randen ook transparant worden.
with block("STYLE"):
p(f'OUTLINECOLOR "{colors[0]}"')
p("WIDTH ", 2)
#ik verdubbel het label omdat er twee opties zijn, ik krijg het simpeler even niet gefixt..
with block("LABEL"):
p("EXPRESSION ([van_minimaal_jaar] = [van_maximaal_jaar])")
p("TEXT '[van_minimaal_jaar]'")
p("MAXSCALEDENOM 3000")
p("COLOR 0 0 0")
p(f'OUTLINECOLOR "{colors[0]}"')
p("OUTLINEWIDTH 1.5")
p("FONT", "Ubuntu-M")
p("TYPE truetype")
p("SIZE 8")
p("POSITION AUTO")
p("PARTIALS FALSE")
with block("LABEL"):
p("EXPRESSION ([van_minimaal_jaar] != [van_maximaal_jaar] AND LENGTH('[van_minimaal_jaar]') > 0 AND LENGTH('[van_maximaal_jaar]') > 0)")
p("TEXT '[van_minimaal_jaar] - [van_maximaal_jaar]'")
p("MAXSCALEDENOM 3000")
p("COLOR 0 0 0")
p(f'OUTLINECOLOR "{colors[0]}"')
p("OUTLINEWIDTH 1.5")
p("FONT", "Ubuntu-M")
p("TYPE truetype")
p("SIZE 8")
p("POSITION AUTO")
p("PARTIALS FALSE")
with block("LABEL"):
p("EXPRESSION (LENGTH('[van_maximaal_jaar]') = 0)")
p("TEXT '[van_minimaal_jaar]'")
p("MAXSCALEDENOM 3000")
p("COLOR 0 0 0")
p(f'OUTLINECOLOR "{colors[0]}"')
p("OUTLINEWIDTH 1.5")
p("FONT", "Ubuntu-M")
p("TYPE truetype")
p("SIZE 8")
p("POSITION AUTO")
p("PARTIALS FALSE")