comparison artifacts/doc/conf/meta-data.xml @ 6053:a18aafc1372f

Commit meta-data.xml refactoring This refactoring was done by Sascha Teichmann and Raimund Renkert, changes from r5988 until now were manually integrated in this. The last out change has been left out until it is clear what the proper solution is for this problem.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 21 May 2013 18:00:29 +0200
parents 490b12d070a2
children 5db238b0176e
comparison
equal deleted inserted replaced
6052:799af7909e8d 6053:a18aafc1372f
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage"> 2 <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage">
3 <datacage> 3 <datacage>
4 <dc:comment> 4
5 Statement to load data from wsts. 5 <dc:comment>
6 </dc:comment> 6 User specific part
7 <dc:macro name="SQL-wst_columns_statement"> 7 ------------------
8 <dc:statement> 8 </dc:comment>
9 SELECT wst_columns.id AS prot_column_id, 9 <dc:if test="dc:contains($parameters, 'user-id') and not(dc:contains($artifact-outs, 'floodmap-hws'))">
10 wst_columns.name AS prot_column_name, 10 <dc:call-macro name="load-user"/>
11 wst_columns.position AS prot_rel_pos, 11 </dc:if>
12 wst_columns.description AS info, 12
13 wst_ranges.a AS deffrom, 13 <dc:call-macro name="load-system"/>
14 wst_ranges.b AS defto 14
15 FROM wst_columns JOIN wst_ranges 15 <dc:macro name="load-system">
16 ON wst_columns.id = wst_ranges.wst_column_id 16 <dc:context connection="system">
17 WHERE wst_columns.wst_id = ${prot_id} 17 <dc:statement>
18 AND NOT((${tokm} &lt; wst_ranges.a) OR (${fromkm} &gt; wst_ranges.b)) 18 SELECT id AS river_id, name AS river_name
19 ORDER by wst_columns.position 19 FROM rivers
20 </dc:statement> 20 WHERE lower(name) LIKE lower(${river})
21 </dc:macro>
22
23 <dc:comment>
24 Load user specific distance information from artifact.
25 </dc:comment>
26 <dc:macro name="user-range">
27 <dc:choose>
28 <dc:when test="dc:contains($parameters, 'user-id')">
29 <dc:context connection="user">
30 <dc:statement>
31 SELECT COALESCE(ld_mode, '') AS ldm,
32 COALESCE(ld_locations, '') AS ldl,
33 COALESCE(ld_from, '') AS ldf,
34 COALESCE(ld_to, '') AS ldt
35 FROM master_artifacts_range
36 WHERE gid = CAST(${artifact-id} AS uuid)
37 </dc:statement> 21 </dc:statement>
38 <dc:for-each> 22 <dc:for-each>
39 <dc:variable name="fromkm" type="number" expr="dc:fromValue($ldm, $ldl, $ldf)"/> 23 <dc:call-macro name="generate-system-content"/>
40 <dc:variable name="tokm" type="number" expr="dc:toValue($ldm, $ldl, $ldt)"/> 24 </dc:for-each>
25 </dc:context>
26 </dc:macro>
27
28 <dc:macro name="load-user">
29 <old_calculations>
30 <dc:call-macro name="generate-user-content"/>
31 </old_calculations>
32 </dc:macro>
33
34 <dc:macro name="generate-system-content">
35 <dc:call-macro name="user-range">
36 <dc:call-macro name="km-filtered-wsts">
37 <dc:choose>
38 <dc:when test="dc:contains($parameters, 'recommended')">
39 <dc:comment>
40 Recommendations (client shall load immediately).
41 </dc:comment>
42 <dc:iterate var="out" container="artifact-outs">
43 <dc:choose>
44 <dc:when test="$out = 'w_differences'">
45 <dc:call-macro name="annotations"/>
46 </dc:when>
47 <dc:when test="$out = 'discharge_longitudinal_section'">
48 <dc:call-macro name="annotations"/>
49 </dc:when>
50 <dc:when test="$out = 'historical_discharge_wq'">
51 <dc:call-macro name="mainvalues"/>
52 </dc:when>
53 <dc:when test="$out = 'cross_section'">
54 <dc:call-macro name="cross_sections"/>
55 <dc:call-macro name="hyks"/>
56 </dc:when>
57 <dc:when test="$out = 'discharge_curve'">
58 <dc:call-macro name="mainvalues"/>
59 </dc:when>
60 <dc:when test="$out = 'computed_discharge_curve'">
61 <dc:call-macro name="mainvalues"/>
62 <dc:call-macro name="basedata_2_fixations_wqkms"/>
63 </dc:when>
64 <dc:when test="$out = 'duration_curve'">
65 <dc:call-macro name="mainvalues"/>
66 </dc:when>
67 <dc:when test="$out = 'reference_curve'">
68 <dc:call-macro name="annotations"/>
69 <dc:call-macro name="mainvalues"/>
70 </dc:when>
71 <dc:when test="$out = 'fix_wq_curve'">
72 <dc:call-macro name="mainvalues"/>
73 <dc:call-macro name="qsectors"/>
74 </dc:when>
75 <dc:when test="$out = 'longitudinal_section'">
76 <dc:call-macro name="annotations"/>
77 </dc:when>
78 <dc:when test="$out = 'fix_longitudinal_section_curve'">
79 <dc:call-macro name="annotations"/>
80 </dc:when>
81 <dc:when test="$out = 'bed_difference_epoch'">
82 <dc:call-macro name="annotations"/>
83 </dc:when>
84 <dc:when test="$out = 'bed_difference_year'">
85 <dc:call-macro name="annotations"/>
86 </dc:when>
87 <dc:when test="$out = 'bed_difference_height_year'">
88 <dc:call-macro name="annotations"/>
89 </dc:when>
90 <dc:when test="$out = 'floodmap'">
91 <dc:call-macro name="flood-map-recommended"/>
92 </dc:when>
93 <dc:when test="$out = 'floodmap-hws'">
94 <dc:call-macro name="flood-map-recommended"/>
95 </dc:when>
96 <dc:when test="$out = 'minfo-heights'">
97 <dc:call-macro name="minfo-heights"/>
98 </dc:when>
99 <dc:when test="$out = 'minfo-heights-epoch'">
100 <bedheights>
101 <dc:call-macro name="bed-heights-epoch"/>
102 </bedheights>
103 </dc:when>
104 </dc:choose>
105 </dc:iterate>
106 </dc:when>
107 <dc:otherwise>
108 <dc:comment>
109 Non - Recommendations.
110 </dc:comment>
111 <dc:iterate var="out" container="artifact-outs">
112 <dc:choose>
113 <dc:when test="$out = 'cross_section'">
114 <dc:call-macro name="basedata_0"/>
115 <dc:call-macro name="basedata_1_additionals"/>
116 <dc:call-macro name="basedata_2_fixations"/>
117 <dc:call-macro name="basedata_3_officials"/>
118 <dc:call-macro name="basedata_4_heightmarks-points"/>
119 <dc:call-macro name="cross_sections"/>
120 <dc:call-macro name="hyks"/>
121 </dc:when>
122 <dc:when test="$out = 'longitudinal_section'">
123 <dc:call-macro name="longitudinal-section-prototype"/>
124 </dc:when>
125 <dc:when test="$out = 'w_differences'">
126 <dc:call-macro name="longitudinal-section-prototype"/>
127 </dc:when>
128 <dc:when test="$out = 'discharge_longitudinal_section'">
129 <dc:call-macro name="longitudinal-section-prototype"/>
130 </dc:when>
131 <dc:when test="$out = 'discharge_curve'">
132 <dc:call-macro name="mainvalues"/>
133 </dc:when>
134 <dc:when test="$out = 'duration_curve'">
135 <dc:call-macro name="mainvalues"/>
136 <dc:call-macro name="basedata_2_fixations_relative_point"/>
137 <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
138 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
139 </dc:when>
140 <dc:when test="$out = 'reference_curve'">
141 <dc:call-macro name="mainvalues"/>
142 <dc:call-macro name="annotations"/>
143 <dc:call-macro name="basedata_1_additionals-relative_point"/>
144 <dc:call-macro name="basedata_2_fixations_relative_point"/>
145 <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
146 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
147 </dc:when>
148 <dc:when test="$out = 'fix_wq_curve'">
149 <dc:call-macro name="basedata_0_wq"/>
150 <dc:call-macro name="basedata_1_additionals_marks"/>
151 <dc:call-macro name="basedata_2_fixations_wqkms"/>
152 <dc:call-macro name="basedata_3_officials"/>
153 <dc:call-macro name="basedata_4_heightmarks-points"/>
154 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
155 <dc:call-macro name="discharge_table_gauge"/>
156 <dc:call-macro name="discharge_fix_wq"/>
157 </dc:when>
158 <dc:when test="$out = 'fix_longitudinal_section_curve'">
159 <dc:call-macro name="annotations"/>
160 </dc:when>
161 <dc:when test="$out = 'map'">
162 <dc:call-macro name="flood-map-complete"/>
163 </dc:when>
164 <dc:when test="$out = 'flow_velocity'">
165 <dc:call-macro name="annotations_per_type"/>
166 <dc:call-macro name="flow_velocity_measurements"/>
167 </dc:when>
168 <dc:when test="$out = 'bed_longitudinal_section'">
169 <dc:call-macro name="annotations_per_type"/>
170 </dc:when>
171 <dc:when test="$out = 'sedimentload_ls'">
172 <dc:call-macro name="annotations_per_type"/>
173 <dc:call-macro name="morph_width"/>
174 </dc:when>
175 <dc:when test="$out = 'bedheight_middle'">
176 <dc:call-macro name="sounding-width"/>
177 <dc:call-macro name="basedata_0"/>
178 <dc:call-macro name="basedata_1_additionals"/>
179 <dc:call-macro name="basedata_2_fixations"/>
180 <dc:call-macro name="basedata_3_officials"/>
181 <dc:call-macro name="annotations_per_type"/>
182 </dc:when>
183 <dc:when test="$out = 'bed_difference_year'">
184 <dc:call-macro name="basedata_0"/>
185 <dc:call-macro name="basedata_1_additionals"/>
186 <dc:call-macro name="basedata_2_fixations"/>
187 <dc:call-macro name="basedata_3_officials"/>
188 <dc:call-macro name="annotations_per_type"/>
189 <dc:call-macro name="morph_width"/>
190 </dc:when>
191 <dc:when test="$out = 'bed_difference_epoch'">
192 <dc:call-macro name="basedata_0"/>
193 <dc:call-macro name="basedata_1_additionals"/>
194 <dc:call-macro name="basedata_2_fixations"/>
195 <dc:call-macro name="basedata_3_officials"/>
196 <dc:call-macro name="annotations_per_type"/>
197 <dc:call-macro name="morph_width"/>
198 </dc:when>
199 <dc:when test="$out = 'floodmap'">
200 <dc:choose>
201 <dc:when test="dc:contains($parameters, 'dem')">
202 <dc:call-macro name="flood-map-dem"/>
203 </dc:when>
204 <dc:when test="dc:contains($parameters, 'hws')">
205 <hws>
206 <dc:call-macro name="flood-map-hws-lines"/>
207 <dc:call-macro name="flood-map-hws-points"/>
208 </hws>
209 </dc:when>
210 <dc:otherwise>
211 <dc:call-macro name="flood-map-complete"/>
212 </dc:otherwise>
213 </dc:choose>
214 </dc:when>
215 <dc:when test="$out = 'floodmap-hws'">
216 <dc:choose>
217 <dc:when test="dc:contains($parameters, 'dem')">
218 <dc:call-macro name="flood-map-dem"/>
219 </dc:when>
220 <dc:when test="dc:contains($parameters, 'hws')">
221 <hws>
222 <dc:call-macro name="flood-map-hws-lines"/>
223 <dc:call-macro name="flood-map-hws-points"/>
224 </hws>
225 </dc:when>
226 <dc:otherwise>
227 <dc:call-macro name="flood-map-complete"/>
228 </dc:otherwise>
229 </dc:choose>
230 </dc:when>
231 <dc:when test="$out = 'computed_discharge_curve'">
232 <dc:call-macro name="discharge_computed"/>
233 <dc:call-macro name="basedata_2_fixations_wqkms"/>
234 <dc:call-macro name="basedata_5_flood-protections"/>
235 <dc:call-macro name="basedata_0"/>
236 <dc:call-macro name="basedata_1_additionals"/>
237 <dc:call-macro name="basedata_4_heightmarks-points"/>
238 <computed_discharge_curve>
239 <dc:call-macro name="mainvalues"/>
240 </computed_discharge_curve>
241 </dc:when>
242 <dc:when test="$out = 'minfo-heights'">
243 <dc:call-macro name="minfo-heights"/>
244 <dc:macro name="minfo-heights">
245 <bedheights>
246 <dc:call-macro name="bed-heights-single"/>
247 <dc:call-macro name="bed-heights-epoch"/>
248 </bedheights>
249 </dc:macro>
250 </dc:when>
251 <dc:when test="$out = 'minfo-heights-epoch'">
252 <bedheights>
253 <dc:call-macro name="bed-heights-epoch"/>
254 </bedheights>
255 </dc:when>
256 </dc:choose>
257 </dc:iterate>
258 </dc:otherwise>
259 </dc:choose>
260 </dc:call-macro>
261 </dc:call-macro>
262 </dc:macro>
263
264 <dc:macro name="generate-user-content">
265 <dc:call-macro name="km-filtered-userdata">
266 <dc:iterate var="out" container="artifact-outs">
267 <dc:choose>
268 <dc:when test="$out = 'longitudinal_section'">
269 <dc:call-macro name="longitudinal"/>
270 <dc:call-macro name="differences"/>
271 <dc:call-macro name="officiallines_user"/>
272 </dc:when>
273 <dc:when test="$out = 'discharge_longitudinal_section'">
274 <dc:call-macro name="longitudinal"/>
275 <dc:call-macro name="differences"/>
276 </dc:when>
277 <dc:when test="$out = 'w_differences'">
278 <dc:call-macro name="longitudinal"/>
279 <dc:call-macro name="differences"/>
280 </dc:when>
281 <dc:when test="$out = 'fix_deltawt_curve'">
282 <dc:call-macro name="delta-wt"/>
283 </dc:when>
284 <dc:when test="$out = 'reference_curve'">
285 <dc:call-macro name="reference-curves"/>
286 </dc:when>
287 <dc:when test="$out = 'computed_discharge_curve'">
288 <dc:call-macro name="computed-discharge-curve"/>
289 </dc:when>
290 <dc:when test="$out = 'cross_section'">
291 <dc:call-macro name="waterlevels"/>
292 </dc:when>
293 <dc:when test="$out = 'fix_longitudinal_section_curve'">
294 <dc:call-macro name="longitudinal-section"/>
295 </dc:when>
296 <dc:when test="$out = 'fix_derivate_curve'">
297 <dc:call-macro name="fix-derivate-curve"/>
298 </dc:when>
299 <dc:when test="$out = 'fix_wq_curve'">
300 <dc:call-macro name="fix-wq-curve"/>
301 </dc:when>
302 <dc:when test="$out = 'duration_curve'">
303 <dc:call-macro name="duration-curve"/>
304 </dc:when>
305 <dc:when test="$out = 'waterlevels'">
306 <dc:call-macro name="basedata_0"/>
307 <dc:call-macro name="basedata_1_additionals"/>
308 <dc:call-macro name="basedata_2_fixations"/>
309 <dc:call-macro name="basedata_4_heightmarks-points"/>
310 <dc:call-macro name="basedata_5_flood-protections"/>
311 <dc:call-macro name="waterlevels-fix"/>
312 </dc:when>
313 <dc:when test="$out = 'fix_wq_curve'">
314 <dc:call-macro name="waterlevels-fix"/>
315 </dc:when>
316 <dc:when test="$out = 'floodmap'">
317 <dc:call-macro name="flood-map"/>
318 </dc:when>
319 <dc:when test="$out = 'map'">
320 <dc:call-macro name="flood-map"/>
321 </dc:when>
322 <dc:when test="$out = 'bedheight_middle'">
323 <dc:call-macro name="waterlevels-discharge"/>
324 <dc:call-macro name="waterlevels-fix"/>
325 </dc:when>
326 <dc:when test="$out = 'floodmap-hws'">
327 <dc:call-macro name="floodmap-hws-user"/>
328 </dc:when>
329 <dc:when test="$out = 'flow_velocity'">
330 <dc:call-macro name="bedquality-bed"/>
331 <dc:call-macro name="bedquality-load"/>
332 </dc:when>
333 <dc:when test="$out = 'bed_longitudinal_section'">
334 <dc:call-macro name="bedquality-bed"/>
335 <dc:call-macro name="bedquality-load"/>
336 <dc:call-macro name="bedquality-density"/>
337 <dc:call-macro name="bedquality-porosity"/>
338 </dc:when>
339 <dc:when test="$out = 'sedimentload_ls'">
340 <dc:call-macro name="differences"/>
341 <dc:call-macro name="bedheight-differences"/>
342 <dc:call-macro name="flow-velocity"/>
343 <dc:call-macro name="sediment-load"/>
344 </dc:when>
345 <dc:when test="$out = 'bed_difference_year'">
346 <dc:call-macro name="waterlevels-discharge"/>
347 <dc:call-macro name="bedheight-differences"/>
348 <dc:call-macro name="differences"/>
349 <dc:call-macro name="waterlevels-fix"/>
350 <dc:call-macro name="delta-wt-ls"/>
351 </dc:when>
352 <dc:when test="$out = 'bed_difference_epoch'">
353 <dc:call-macro name="waterlevels-discharge"/>
354 <dc:call-macro name="bedheight-differences"/>
355 <dc:call-macro name="differences"/>
356 <dc:call-macro name="waterlevels-fix"/>
357 <dc:call-macro name="delta-wt-ls"/>
358 </dc:when>
359 </dc:choose>
360 </dc:iterate>
361 </dc:call-macro>
362 </dc:macro>
363
364 <!-- Macros to load user data -->
365
366 <dc:macro name="select-facets">
367 <dc:context>
368 <dc:statement>
369 SELECT a.gid AS aid,
370 f.id AS fid,
371 f.name AS facet_name,
372 f.num AS facet_num,
373 f.description AS facet_description
374 FROM artifacts a
375 JOIN outs o ON o.artifact_id = a.id
376 JOIN facets f ON f.out_id = o.id
377 WHERE a.id = ${a_id}
378 AND f.name = ${facet_type}
379 </dc:statement>
380 <dc:if test="dc:has-result()">
41 <dc:macro-body/> 381 <dc:macro-body/>
382 </dc:if>
383 </dc:context>
384 </dc:macro>
385
386 <dc:macro name="differences">
387 <dc:variable name="facet_type" value="w_differences"/>
388 <dc:call-macro name="select-facets">
389 <differences>
390 <dc:for-each>
391 <w_differences
392 description="{$facet_description}"
393 factory="winfo"
394 artifact-id="{$aid}"
395 ids="{$aid}"
396 out="w_differences"/>
397 </dc:for-each>
398 </differences>
399 </dc:call-macro>
400 </dc:macro>
401
402 <dc:macro name="reference-curves">
403 <dc:variable name="facet_type" value="reference_curve"/>
404 <dc:call-macro name="select-facets">
405 <reference_curves>
406 <dc:for-each>
407 <dc:element name="${facet_name}">
408 <dc:attribute name="description" value="${facet_description}"/>
409 <dc:attribute name="factory" value="winfo"/>
410 <dc:attribute name="artifact-id" value="${aid}"/>
411 <dc:attribute name="ids" value="${aid}"/>
412 <dc:attribute name="out" value="reference_curve"/>
413 </dc:element>
414 </dc:for-each>
415 </reference_curves>
416 </dc:call-macro>
417 </dc:macro>
418
419 <dc:macro name="computed-discharge-curve">
420 <dc:variable name="facet_type" value="computed_discharge_curve.q"/>
421 <dc:call-macro name="select-facets">
422 <computed_discharge_curves>
423 <dc:for-each>
424 <dc:element name="${facet_name}">
425 <dc:attribute name="description" value="${facet_description}"/>
426 <dc:attribute name="factory" value="winfo"/>
427 <dc:attribute name="artifact-id" value="${aid}"/>
428 <dc:attribute name="ids" value="${aid}"/>
429 <dc:attribute name="out" value="computed_discharge_curve"/>
430 </dc:element>
431 </dc:for-each>
432 </computed_discharge_curves>
433 </dc:call-macro>
434 </dc:macro>
435
436 <dc:macro name="flood-map">
437 <dc:variable name="facet_type" value="floodmap.wsplgen"/>
438 <dc:call-macro name="select-facets">
439 <floodmap>
440 <dc:for-each>
441 <dc:element name="${facet_name}">
442 <dc:attribute name="description" value="${facet_description}"/>
443 <dc:attribute name="factory" value="winfo"/>
444 <dc:attribute name="artifact-id" value="${aid}"/>
445 <dc:attribute name="ids" value="${aid}"/>
446 <dc:attribute name="out" value="floodmap"/>
447 </dc:element>
448 </dc:for-each>
449 </floodmap>
450 </dc:call-macro>
451 </dc:macro>
452
453 <dc:macro name="waterlevels">
454 <dc:context>
455 <dc:statement>
456 SELECT id AS out_id
457 FROM outs
458 WHERE artifact_id = ${a_id} AND name = 'cross_section'
459 </dc:statement>
460 <dc:if test="dc:has-result()">
461 <waterlevels>
462 <dc:for-each>
463 <dc:context>
464 <dc:statement>
465 SELECT name AS facet_name, num AS facet_num, description AS facet_description
466 FROM facets
467 WHERE out_id = ${out_id}
468 ORDER BY num ASC, name DESC
469 </dc:statement>
470 <longitudinal_section_columns description="{$river} {$a_creation}">
471 <dc:for-each>
472 <dc:element name="${facet_name}">
473 <dc:attribute name="description" value="${facet_description}"/>
474 <dc:attribute name="ids" value="${facet_num}"/>
475 <dc:attribute name="factory" value="winfo"/>
476 <dc:attribute name="artifact-id" value="${a_gid}"/>
477 <dc:attribute name="out" value="cross_section"/>
478 </dc:element>
479 </dc:for-each>
480 </longitudinal_section_columns>
481 </dc:context>
482 </dc:for-each>
483 </waterlevels>
484 </dc:if>
485 </dc:context>
486 </dc:macro>
487
488 <dc:macro name="longitudinal">
489 <dc:context>
490 <dc:statement>
491 SELECT id AS out_id
492 FROM outs
493 WHERE artifact_id = ${a_id}
494 AND name = 'longitudinal_section'
495 </dc:statement>
496 <dc:if test="dc:has-result()">
497 <waterlevels>
498 <dc:for-each>
499 <dc:context>
500 <dc:statement>
501 SELECT name AS facet_name,
502 num AS facet_num,
503 description AS facet_description
504 FROM facets
505 WHERE out_id = ${out_id}
506 ORDER BY num ASC, name DESC
507 </dc:statement>
508 <longitudinal_section_columns description="{$river} {$a_creation}">
509 <dc:for-each>
510 <dc:element name="${facet_name}">
511 <dc:attribute name="description" value="${facet_description}"/>
512 <dc:attribute name="ids" value="${facet_num}"/>
513 <dc:attribute name="factory" value="winfo"/>
514 <dc:attribute name="artifact-id" value="${a_gid}"/>
515 <dc:attribute name="out" value="longitudinal_section"/>
516 </dc:element>
517 </dc:for-each>
518 </longitudinal_section_columns>
519 </dc:context>
520 </dc:for-each>
521 </waterlevels>
522 </dc:if>
523 </dc:context>
524 </dc:macro>
525
526 <dc:macro name="longitudinal-section">
527 <dc:context>
528 <dc:statement>
529 SELECT id AS out_id
530 FROM outs
531 WHERE artifact_id = ${a_id}
532 AND name = 'fix_longitudinal_section_curve'
533 </dc:statement>
534 <dc:if test="dc:has-result()">
535 <waterlevels>
536 <dc:for-each>
537 <dc:context>
538 <dc:statement>
539 SELECT name AS facet_name,
540 num AS facet_num,
541 description AS facet_description
542 FROM facets
543 WHERE out_id = ${out_id} AND (
544 name LIKE 'fix_deviation_ls%' OR
545 name LIKE 'fix_sector_average_ls%' OR
546 name LIKE 'fix_analysis_events_ls%' OR
547 name LIKE 'fix_reference_events_ls%')
548 ORDER BY num ASC, name DESC
549 </dc:statement>
550 <waterlevels description="{$river} {$a_creation} {$collection_name}">
551 <dc:for-each>
552 <dc:element name="${facet_name}">
553 <dc:attribute name="description" value="${facet_description}"/>
554 <dc:attribute name="ids" value="${facet_num}"/>
555 <dc:attribute name="factory" value="fixanalysis"/>
556 <dc:attribute name="artifact-id" value="${a_gid}"/>
557 <dc:attribute name="out" value="fix_longitudinal_section_curve"/>
558 </dc:element>
559 </dc:for-each>
560 </waterlevels>
561 </dc:context>
562 </dc:for-each>
563 </waterlevels>
564 </dc:if>
565 </dc:context>
566 </dc:macro>
567
568 <dc:macro name="delta-wt">
569 <dc:context>
570 <dc:statement>
571 SELECT id AS out_id
572 FROM outs
573 WHERE artifact_id = ${a_id}
574 AND name = 'fix_deltawt_curve'
575 </dc:statement>
576 <dc:if test="dc:has-result()">
577 <waterlevels>
578 <dc:for-each>
579 <dc:context>
580 <dc:statement>
581 SELECT name AS facet_name,
582 num AS facet_num,
583 description AS facet_description
584 FROM facets
585 WHERE out_id = ${out_id} and (
586 name LIKE 'fix_sector_average_dwt%' OR
587 name LIKE 'fix_deviation_dwt%' OR
588 name = 'fix_analysis_events_dwt' OR
589 name = 'fix_reference_events_dwt' OR
590 name = 'fix_analysis_periods_dwt')
591 ORDER BY num ASC, name DESC
592 </dc:statement>
593 <waterlevels description="{$river} {$a_creation} {$collection_name}">
594 <dc:for-each>
595 <dc:element name="${facet_name}">
596 <dc:attribute name="description" value="${facet_description}"/>
597 <dc:attribute name="ids" value="${facet_num}"/>
598 <dc:attribute name="factory" value="fixanalysis"/>
599 <dc:attribute name="artifact-id" value="${a_gid}"/>
600 <dc:attribute name="out" value="fix_deltawt_curve"/>
601 </dc:element>
602 </dc:for-each>
603 </waterlevels>
604 </dc:context>
605 </dc:for-each>
606 </waterlevels>
607 </dc:if>
608 </dc:context>
609 </dc:macro>
610
611 <dc:macro name="delta-wt-ls">
612 <dc:context>
613 <dc:statement>
614 SELECT id AS out_id
615 FROM outs
616 WHERE artifact_id = ${a_id} AND name = 'fix_deltawt_curve'
617 </dc:statement>
618 <dc:if test="dc:has-result()">
619 <waterlevels>
620 <dc:for-each>
621 <dc:context>
622 <dc:statement>
623 SELECT name AS facet_name, num AS facet_num, description AS facet_description
624 FROM facets
625 WHERE out_id = ${out_id} and (
626 name LIKE 'fix_sector_average_dwt%' OR
627 name LIKE 'fix_deviation_dwt%')
628 ORDER BY num ASC, name DESC
629 </dc:statement>
630 <waterlevels description="{$river} {$a_creation} {$collection_name}">
631 <dc:for-each>
632 <dc:element name="${facet_name}">
633 <dc:attribute name="description" value="${facet_description}"/>
634 <dc:attribute name="ids" value="${facet_num}"/>
635 <dc:attribute name="factory" value="fixanalysis"/>
636 <dc:attribute name="artifact-id" value="${a_gid}"/>
637 <dc:attribute name="out" value="fix_deltawt_curve"/>
638 </dc:element>
639 </dc:for-each>
640 </waterlevels>
641 </dc:context>
642 </dc:for-each>
643 </waterlevels>
644 </dc:if>
645 </dc:context>
646 </dc:macro>
647
648 <dc:macro name="fix-derivate-curve">
649 <dc:context>
650 <dc:statement>
651 SELECT id AS out_id
652 FROM outs
653 WHERE artifact_id = ${a_id} AND name = 'fix_derivate_curve'
654 </dc:statement>
655 <dc:if test="dc:has-result()">
656 <waterlevels>
657 <dc:for-each>
658 <dc:context>
659 <dc:statement>
660 SELECT name AS facet_name, num AS facet_num, description AS facet_description
661 FROM facets
662 WHERE out_id = ${out_id} and name = 'fix_derivate_curve'
663 ORDER BY num ASC, name DESC
664 </dc:statement>
665 <waterlevels description="{$river} {$a_creation} {$collection_name}">
666 <dc:for-each>
667 <dc:element name="${facet_name}">
668 <dc:attribute name="description" value="${facet_description}"/>
669 <dc:attribute name="ids" value="${facet_num}"/>
670 <dc:attribute name="factory" value="fixanalysis"/>
671 <dc:attribute name="artifact-id" value="${a_gid}"/>
672 <dc:attribute name="out" value="fix_derivate_curve"/>
673 </dc:element>
674 </dc:for-each>
675 </waterlevels>
676 </dc:context>
677 </dc:for-each>
678 </waterlevels>
679 </dc:if>
680 </dc:context>
681 </dc:macro>
682
683 <dc:macro name="fix-wq-curve">
684 <dc:context>
685 <dc:statement>
686 SELECT id AS out_id
687 FROM outs
688 WHERE artifact_id = ${a_id} AND name = 'fix_wq_curve'
689 </dc:statement>
690 <dc:if test="dc:has-result()">
691 <waterlevels>
692 <dc:for-each>
693 <dc:context>
694 <dc:statement>
695 SELECT name AS facet_name, num AS facet_num, description AS facet_description
696 FROM facets
697 WHERE out_id = ${out_id} and (
698 name LIKE 'fix_sector_average_wq%' OR
699 name = 'fix_wq_curve' OR
700 name LIKE 'fix_analysis_events_wq%' OR
701 name LIKE 'fix_reference_events_wq%' )
702 ORDER BY num ASC, name DESC
703 </dc:statement>
704 <waterlevels description="{$river} {$a_creation} {$collection_name}">
705 <dc:for-each>
706 <dc:element name="${facet_name}">
707 <dc:attribute name="description" value="${facet_description}"/>
708 <dc:attribute name="ids" value="${facet_num}"/>
709 <dc:attribute name="factory" value="fixanalysis"/>
710 <dc:attribute name="artifact-id" value="${a_gid}"/>
711 <dc:attribute name="out" value="fix_wq_curve"/>
712 </dc:element>
713 </dc:for-each>
714 </waterlevels>
715 </dc:context>
716 </dc:for-each>
717 </waterlevels>
718 </dc:if>
719 </dc:context>
720 </dc:macro>
721
722 <dc:macro name="duration-curve">
723 <dc:context>
724 <dc:statement>
725 SELECT a.gid AS aid,
726 f.id AS fid,
727 f.name AS facet_name,
728 f.num AS facet_num,
729 f.description AS facet_description
730 FROM outs AS o, facets AS f, artifacts AS a
731 WHERE
732 (f.name = 'duration_curve.q' OR f.name = 'duration_curve.w') AND
733 f.out_id = o.id AND
734 o.artifact_id = ${a_id} AND
735 a.id = ${a_id}
736 </dc:statement>
737 <dc:if test="dc:has-result()">
738 <computed_discharge_curves>
739 <dc:for-each>
740 <dc:element name="${facet_name}">
741 <dc:attribute name="description" value="${facet_description}"/>
742 <dc:attribute name="factory" value="winfo"/>
743 <dc:attribute name="artifact-id" value="${aid}"/>
744 <dc:attribute name="ids" value="${aid}"/>
745 <dc:attribute name="out" value="duration_curve"/>
746 </dc:element>
747 </dc:for-each>
748 </computed_discharge_curves>
749 </dc:if>
750 </dc:context>
751 </dc:macro>
752
753 <dc:comment>TODO doesnt work nicely for fix/wq-diags.</dc:comment>
754 <dc:macro name="waterlevels-fix">
755 <dc:context>
756 <dc:statement>
757 SELECT id AS out_id
758 FROM outs
759 WHERE artifact_id = ${a_id} AND name = 'longitudinal_section'
760 </dc:statement>
761 <dc:if test="dc:has-result()">
762 <waterlevels>
763 <dc:for-each>
764 <dc:context>
765 <dc:statement>
766 SELECT name AS facet_name, num AS facet_num, description AS facet_description
767 FROM facets
768 WHERE out_id = ${out_id} and name = 'longitudinal_section.w'
769 ORDER BY num ASC, name DESC
770 </dc:statement>
771 <waterlevels description="{$river} {$a_creation} {$collection_name}">
772 <dc:for-each>
773 <dc:element name="${facet_name}">
774 <dc:attribute name="description" value="${facet_description}"/>
775 <dc:attribute name="ids" value="${facet_num}"/>
776 <dc:attribute name="factory" value="winfo"/>
777 <dc:attribute name="artifact-id" value="${a_gid}"/>
778 <dc:attribute name="out" value="longitudinal_section"/>
779 </dc:element>
780 </dc:for-each>
781 </waterlevels>
782 </dc:context>
783 </dc:for-each>
784 </waterlevels>
785 </dc:if>
786 </dc:context>
787 </dc:macro>
788
789 <dc:macro name="floodmap-hws-user">
790 <dc:context>
791 <dc:statement>
792 SELECT id AS out_id
793 FROM outs
794 WHERE artifact_id = ${a_id} AND name = 'floodmap'
795 </dc:statement>
796 <dc:for-each>
797 <dc:context>
798 <dc:statement>
799 SELECT name AS facet_name,
800 num AS facet_num,
801 description AS facet_description
802 FROM facets
803 WHERE out_id = ${out_id} AND name = 'floodmap.usershape'
804 ORDER BY num ASC, name DESC
805 </dc:statement>
806 <own-hws>
807 <dc:for-each>
808 <dc:element name="${facet_name}">
809 <dc:attribute name="description" value="${facet_description}"/>
810 <dc:attribute name="ids" value="${facet_num}"/>
811 <dc:attribute name="factory" value="winfo"/>
812 <dc:attribute name="artifact-id" value="${a_gid}"/>
813 <dc:attribute name="out" value="floodmap"/>
814 </dc:element>
815 </dc:for-each>
816 </own-hws>
817 </dc:context>
42 </dc:for-each> 818 </dc:for-each>
819 </dc:context>
820 </dc:macro>
821
822 <dc:macro name="bedquality-bed">
823 <dc:context>
824 <dc:statement>
825 SELECT id AS oid
826 FROM outs AS o
827 WHERE
828 o.artifact_id = ${a_id} AND
829 o.name='bed_longitudinal_section'
830 </dc:statement>
831 <dc:if test="dc:has-result()">
832 <bed_quality_bed>
833 <dc:for-each>
834 <quality-bed description="{$river} {$a_creation} {$collection_name}">
835 <dc:context>
836 <dc:statement>
837 SELECT a.gid AS aid,
838 f.id AS fid,
839 f.name AS facet_name,
840 f.num AS facet_num,
841 f.description AS facet_description
842 FROM outs AS o, facets AS f, artifacts AS a
843 WHERE
844 (f.name = 'bed_longitudinal_section.bed_diameter_toplayer'
845 OR f.name = 'bed_longitudinal_section.bed_diameter_sublayer') AND
846 f.out_id = o.id AND
847 o.artifact_id = ${a_id} AND
848 a.id = ${a_id}
849 </dc:statement>
850 <dc:for-each>
851 <dc:element name="${facet_name}">
852 <dc:attribute name="factory" value="minfo"/>
853 <dc:attribute name="description" value="${facet_description}"/>
854 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
855 <dc:attribute name="artifact-id" value="${aid}"/>
856 <dc:attribute name="out" value="bed_longitudinal_section"/>
857 </dc:element>
858 </dc:for-each>
859 </dc:context>
860 </quality-bed>
861 </dc:for-each>
862 </bed_quality_bed>
863 </dc:if>
864 </dc:context>
865 </dc:macro>
866
867 <dc:macro name="bedquality-load">
868 <dc:context>
869 <dc:statement>
870 SELECT id AS oid
871 FROM outs AS o
872 WHERE
873 o.artifact_id = ${a_id} AND
874 o.name='bed_longitudinal_section'
875 </dc:statement>
876 <dc:if test="dc:has-result()">
877 <bed_quality_load>
878 <dc:for-each>
879 <quality-load description="{$river} {$a_creation} {$collection_name}">
880 <dc:context>
881 <dc:statement>
882 SELECT a.gid AS aid,
883 f.id AS fid,
884 f.name AS facet_name,
885 f.num AS facet_num,
886 f.description AS facet_description
887 FROM outs AS o, facets AS f, artifacts AS a
888 WHERE
889 f.name = 'bed_longitudinal_section.bedload_diameter' AND
890 f.out_id = o.id AND
891 o.artifact_id = ${a_id} AND
892 a.id = ${a_id}
893 </dc:statement>
894 <dc:for-each>
895 <dc:element name="${facet_name}">
896 <dc:attribute name="factory" value="minfo"/>
897 <dc:attribute name="description" value="${facet_description}"/>
898 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
899 <dc:attribute name="artifact-id" value="${aid}"/>
900 <dc:attribute name="out" value="bed_longitudinal_section"/>
901 </dc:element>
902 </dc:for-each>
903 </dc:context>
904 </quality-load>
905 </dc:for-each>
906 </bed_quality_load>
907 </dc:if>
908 </dc:context>
909 </dc:macro>
910
911 <dc:macro name="bedquality-density">
912 <dc:context>
913 <dc:statement>
914 SELECT id AS oid
915 FROM outs AS o
916 WHERE
917 o.artifact_id = ${a_id} AND
918 o.name='bed_longitudinal_section'
919 </dc:statement>
920 <dc:if test="dc:has-result()">
921 <bed_quality_density>
922 <dc:for-each>
923 <density description="{$river} {$a_creation} {$collection_name}">
924 <dc:context>
925 <dc:statement>
926 SELECT a.gid AS aid,
927 f.id AS fid,
928 f.name AS facet_name,
929 f.num AS facet_num,
930 f.description AS facet_description
931 FROM outs AS o, facets AS f, artifacts AS a
932 WHERE
933 (f.name = 'bed_longitudinal_section.sediment_density_toplayer' OR
934 f.name = 'bed_longitudinal_section.sediment_density_sublayer') AND
935 f.out_id = o.id AND
936 o.artifact_id = ${a_id} AND
937 a.id = ${a_id}
938 </dc:statement>
939 <dc:for-each>
940 <dc:element name="${facet_name}">
941 <dc:attribute name="factory" value="minfo"/>
942 <dc:attribute name="description" value="${facet_description}"/>
943 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
944 <dc:attribute name="artifact-id" value="${aid}"/>
945 <dc:attribute name="out" value="bed_longitudinal_section"/>
946 </dc:element>
947 </dc:for-each>
948 </dc:context>
949 </density>
950 </dc:for-each>
951 </bed_quality_density>
952 </dc:if>
953 </dc:context>
954 </dc:macro>
955
956 <dc:macro name="bedquality-porosity">
957 <dc:context>
958 <dc:statement>
959 SELECT id AS oid
960 FROM outs AS o
961 WHERE
962 o.artifact_id = ${a_id} AND
963 o.name='bed_longitudinal_section'
964 </dc:statement>
965 <dc:if test="dc:has-result()">
966 <bed_quality_porosity>
967 <dc:for-each>
968 <porosity description="{$river} {$a_creation} {$collection_name}">
969 <dc:context>
970 <dc:statement>
971 SELECT a.gid AS aid,
972 f.id AS fid,
973 f.name AS facet_name,
974 f.num AS facet_num,
975 f.description AS facet_description
976 FROM outs AS o, facets AS f, artifacts AS a
977 WHERE
978 (f.name = 'bed_longitudinal_section.porosity_toplayer' OR
979 f.name = 'bed_longitudinal_section.porosity_sublayer') AND
980 f.out_id = o.id AND
981 o.artifact_id = ${a_id} AND
982 a.id = ${a_id}
983 </dc:statement>
984 <dc:for-each>
985 <dc:element name="${facet_name}">
986 <dc:attribute name="factory" value="minfo"/>
987 <dc:attribute name="description" value="${facet_description}"/>
988 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
989 <dc:attribute name="artifact-id" value="${aid}"/>
990 <dc:attribute name="out" value="bed_longitudinal_section"/>
991 </dc:element>
992 </dc:for-each>
993 </dc:context>
994 </porosity>
995 </dc:for-each>
996 </bed_quality_porosity>
997 </dc:if>
998 </dc:context>
999 </dc:macro>
1000
1001 <dc:macro name="flow-velocity">
1002 <dc:context>
1003 <dc:statement>
1004 SELECT id AS oid
1005 FROM outs AS o
1006 WHERE
1007 o.artifact_id = ${a_id} and o.name='flow_velocity'
1008 </dc:statement>
1009 <dc:if test="dc:has-result()">
1010 <flow-velocity>
1011 <dc:for-each>
1012 <flow description="{$river} {$a_creation} {$collection_name}">
1013 <dc:context>
1014 <dc:statement>
1015 SELECT a.gid AS aid,
1016 f.id AS fid,
1017 f.name AS facet_name,
1018 f.num AS facet_num,
1019 f.description AS facet_description
1020 FROM outs AS o, facets AS f, artifacts AS a
1021 WHERE
1022 (f.name = 'flow_velocity.totalchannel' OR
1023 f.name = 'flow_velocity.mainchannel' OR
1024 f.name = 'flow_velocity.totalchannel.filtered' OR
1025 f.name = 'flow_velocity.mainchannel.filtered') AND
1026 f.out_id = o.id AND
1027 o.artifact_id = ${a_id} AND
1028 a.id = ${a_id}
1029 </dc:statement>
1030 <dc:for-each>
1031 <dc:element name="${facet_name}">
1032 <dc:attribute name="factory" value="minfo"/>
1033 <dc:attribute name="description" value="${facet_description}"/>
1034 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
1035 <dc:attribute name="artifact-id" value="${aid}"/>
1036 <dc:attribute name="out" value="flow_velocity"/>
1037 </dc:element>
1038 </dc:for-each>
1039 </dc:context>
1040 </flow>
1041 </dc:for-each>
1042 </flow-velocity>
1043 </dc:if>
1044 </dc:context>
1045 </dc:macro>
1046
1047 <dc:macro name="sediment-load">
1048 <dc:context>
1049 <dc:statement>
1050 SELECT id AS oid
1051 FROM outs AS o
1052 WHERE
1053 o.artifact_id = ${a_id} and o.name='sedimentload_ls'
1054 </dc:statement>
1055 <dc:if test="dc:has-result()">
1056 <sediment-load>
1057 <dc:for-each>
1058 <load description="{$river} {$a_creation} {$collection_name}">
1059 <dc:context>
1060 <dc:statement>
1061 SELECT a.gid AS aid,
1062 f.id AS fid,
1063 f.name AS facet_name,
1064 f.num AS facet_num,
1065 f.description AS facet_description
1066 FROM outs AS o, facets AS f, artifacts AS a
1067 WHERE f.name LIKE 'sedimentload%' AND
1068 f.out_id = o.id AND
1069 o.artifact_id = ${a_id} AND
1070 a.id = ${a_id}
1071 </dc:statement>
1072 <dc:for-each>
1073 <dc:element name="${facet_name}">
1074 <dc:attribute name="factory" value="minfo"/>
1075 <dc:attribute name="description" value="${facet_description}"/>
1076 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
1077 <dc:attribute name="artifact-id" value="${aid}"/>
1078 <dc:attribute name="out" value="sedimentload_ls"/>
1079 </dc:element>
1080 </dc:for-each>
1081 </dc:context>
1082 </load>
1083 </dc:for-each>
1084 </sediment-load>
1085 </dc:if>
1086 </dc:context>
1087 </dc:macro>
1088
1089 <dc:macro name="bedheight-differences">
1090 <dc:context>
1091 <dc:statement>
1092 SELECT id AS oid,
1093 name AS o_name
1094 FROM outs AS o
1095 WHERE
1096 o.artifact_id = ${a_id} AND
1097 (o.name = 'bed_difference_year' OR
1098 o.name = 'bed_differnece_epoch')
1099 </dc:statement>
1100 <dc:if test="dc:has-result()">
1101 <bedheight-differences>
1102 <dc:for-each>
1103 <difference description="{$river} {$a_creation} {$collection_name}">
1104 <dc:context>
1105 <dc:statement>
1106 SELECT a.gid AS aid,
1107 f.id AS fid,
1108 f.name AS facet_name,
1109 f.num AS facet_num,
1110 f.description AS facet_description
1111 FROM outs AS o, facets AS f, artifacts AS a
1112 WHERE (f.name LIKE 'bedheight_difference.year%' OR
1113 f.name LIKE 'bedheight_difference.epoch%') AND
1114 f.out_id = o.id AND
1115 o.artifact_id = ${a_id} AND
1116 a.id = ${a_id}
1117 </dc:statement>
1118 <dc:for-each>
1119 <dc:element name="${facet_name}">
1120 <dc:attribute name="factory" value="minfo"/>
1121 <dc:attribute name="description" value="${facet_description}"/>
1122 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
1123 <dc:attribute name="artifact-id" value="${aid}"/>
1124 <dc:choose>
1125 <dc:when test="dc:contains($o_name, 'bed_difference_year')">
1126 <dc:attribute name="out" value="bed_difference_year"/>
1127 </dc:when>
1128 <dc:otherwise>
1129 <dc:attribute name="out" value="bed_difference_epoch"/>
1130 </dc:otherwise>
1131 </dc:choose>
1132 </dc:element>
1133 </dc:for-each>
1134 </dc:context>
1135 </difference>
1136 </dc:for-each>
1137 </bedheight-differences>
1138 </dc:if>
1139 </dc:context>
1140 </dc:macro>
1141
1142 <dc:macro name="waterlevels-discharge">
1143 <dc:context>
1144 <dc:statement>
1145 SELECT id AS oid
1146 FROM outs AS o
1147 WHERE
1148 o.artifact_id = ${a_id} AND
1149 o.name = 'discharge_longitudinal_section'
1150 </dc:statement>
1151 <dc:if test="dc:has-result()">
1152 <waterlevels-discharge>
1153 <dc:for-each>
1154 <discharge description="{$oid} {$river} {$a_id} {$a_creation} {$collection_name}">
1155 <dc:context>
1156 <dc:statement>
1157 SELECT a.gid AS aid,
1158 f.id AS fid,
1159 f.name AS facet_name,
1160 f.num AS facet_num,
1161 f.description AS facet_description
1162 FROM outs AS o, facets AS f, artifacts AS a
1163 WHERE f.name = 'discharge_longitudinal_section.w' AND
1164 f.out_id = o.id AND
1165 o.artifact_id = ${a_id} AND
1166 a.id = ${a_id}
1167 </dc:statement>
1168 <dc:for-each>
1169 <dc:element name="${facet_name}">
1170 <dc:attribute name="factory" value="winfo"/>
1171 <dc:attribute name="description" value="${facet_description}"/>
1172 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
1173 <dc:attribute name="artifact-id" value="${aid}"/>
1174 <dc:attribute name="out" value="longitudinal_section"/>
1175 </dc:element>
1176 </dc:for-each>
1177 </dc:context>
1178 </discharge>
1179 </dc:for-each>
1180 </waterlevels-discharge>
1181 </dc:if>
1182 </dc:context>
1183 </dc:macro>
1184 <!-- Macros to load system data -->
1185
1186 <dc:macro name="annotations">
1187 <annotation factory="annotations" ids="{$river_id}"/>
1188 </dc:macro>
1189
1190 <dc:macro name="mainvalues">
1191 <wmainvalue factory="mainvalue" ids="{$river_id}:w"/>
1192 <qmainvalue factory="mainvalue" ids="{$river_id}:q"/>
1193 </dc:macro>
1194
1195 <dc:macro name="cross_sections">
1196 <cross_sections id="flood-protections-{$river_id}">
1197 <dc:context connection="system">
1198 <dc:statement>
1199 SELECT DISTINCT
1200 cs.id AS prot_id,
1201 cs.description AS prot_description
1202 FROM cross_sections cs
1203 JOIN cross_section_lines csl ON csl.cross_section_id = cs.id
1204 WHERE cs.river_id = ${river_id}
1205 AND csl.km BETWEEN ${fromkm} AND ${tokm}
1206 </dc:statement>
1207 <dc:for-each>
1208 <cross_section name="{$prot_description}"
1209 ids="{$prot_id}"
1210 factory="crosssections"/>
1211 </dc:for-each>
43 </dc:context> 1212 </dc:context>
44 </dc:when> 1213 </cross_sections>
45 <dc:otherwise> 1214 </dc:macro>
46 <dc:variable name="fromkm" type="number" expr="dc:fromValue('', '', '')"/> 1215
47 <dc:variable name="tokm" type="number" expr="dc:toValue('', '', '')"/> 1216 <dc:macro name="hyks">
48 <dc:macro-body/> 1217 <hyks id="hyk-{$river_id}">
49 </dc:otherwise> 1218 <dc:context connection="system">
50 </dc:choose> 1219 <dc:statement>
51 </dc:macro> 1220 SELECT DISTINCT
52 1221 h.id AS hyk_id,
53 <dc:comment> 1222 h.description AS hyk_description
54 System part. Load data for the given river. 1223 FROM hyks h
55 </dc:comment> 1224 JOIN hyk_entries he ON he.hyk_id = h.id
56 <dc:macro name="load-system"> 1225 WHERE river_id = ${river_id}
57 <dc:context connection="system"> 1226 AND he.km BETWEEN ${fromkm} AND ${tokm}
58 <dc:statement> 1227 </dc:statement>
59 SELECT id AS river_id, name AS river_name FROM rivers 1228 <dc:for-each>
60 WHERE lower(name) LIKE lower(${river}) 1229 <hyk name="{$hyk_description}"
61 </dc:statement> 1230 ids="{$hyk_id}"
62 <dc:for-each> 1231 factory="hyk"/>
63 1232 </dc:for-each>
64 <dc:comment> 1233 </dc:context>
65 Base-data macros (mostly data imported from wst-files). 1234 </hyks>
66 </dc:comment> 1235 </dc:macro>
67 <dc:macro name="basedata_0"> 1236
68 <dc:call-macro name="user-range"> 1237 <dc:macro name="fixings-macro">
69 <dc:comment comment=" BASEDATA ---------------------------"/> 1238 <dc:filter expr="$kind=2">
70 <basedata> 1239 <dc:if test="dc:has-result()">
71 <dc:context connection="system"> 1240 <fixations>
1241 <dc:group expr="dc:replace($wst_description, 'Fixierungen/', '')">
1242 <fixation name="{dc:group-key()}">
1243 <dc:for-each>
1244 <dc:macro-body/>
1245 </dc:for-each>
1246 </fixation>
1247 </dc:group>
1248 </fixations>
1249 </dc:if>
1250 </dc:filter>
1251 </dc:macro>
1252
1253 <dc:macro name="basedata_2_fixations_wqkms">
1254 <dc:call-macro name="fixings-macro">
1255 <column name="{$wst_column_name}"
1256 ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
1257 factory="wqinterpol"
1258 info="{$info} [km {$deffrom} - {$defto}]"/>
1259 </dc:call-macro>
1260 </dc:macro>
1261
1262 <dc:macro name="basedata_2_fixations">
1263 <dc:call-macro name="fixings-macro">
1264 <column name="{$wst_column_name}"
1265 ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
1266 factory="staticwqkms"
1267 info="{$info} [km {$deffrom} - {$defto}]"/>
1268 </dc:call-macro>
1269 </dc:macro>
1270
1271 <dc:macro name="basedata_3_officials">
1272 <dc:filter expr="$kind=3">
1273 <dc:if test="dc:has-result()">
1274 <officiallines>
1275 <dc:group expr="$wst_description">
1276 <official name="{dc:group-key()}">
1277 <dc:for-each>
1278 <column name="{$wst_column_name}"
1279 ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
1280 factory="staticwqkms"
1281 info="{$info} [km {$deffrom} - {$defto}]"/>
1282 </dc:for-each>
1283 </official>
1284 </dc:group>
1285 </officiallines>
1286 </dc:if>
1287 </dc:filter>
1288 </dc:macro>
1289
1290 <dc:macro name="basedata_4_heightmarks-points">
1291 <dc:filter expr="$kind=4">
1292 <dc:if test="dc:has-result()">
1293 <heightmarks>
1294 <dc:group expr="{dc:replace($wst_description, 'HW-Marken/', '')}">
1295 <heightmark name="dc:group-key()">
1296 <dc:for-each>
1297 <column name="{$wst_column_name}"
1298 ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}"
1299 factory="staticwkms"
1300 info="{$info} [km {$deffrom} - {$defto}]"/>
1301 </dc:for-each>
1302 </heightmark>
1303 </dc:group>
1304 </heightmarks>
1305 </dc:if>
1306 </dc:filter>
1307 </dc:macro>
1308
1309 <dc:macro name="basedata_4_heightmarks-points-relative_points">
1310 <dc:filter expr="$kind=4">
1311 <dc:if test="dc:has-result()">
1312 <heightmarks>
1313 <dc:group expr="{dc:replace($wst_description, 'HW-Marken/', '')}">
1314 <relativepoint name="dc:group-key()">
1315 <dc:for-each>
1316 <column name="{$wst_column_name}"
1317 ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}"
1318 factory="staticwkms"
1319 info="{$info} [km {$deffrom} - {$defto}]"/>
1320 </dc:for-each>
1321 </relativepoint>
1322 </dc:group>
1323 </heightmarks>
1324 </dc:if>
1325 </dc:filter>
1326 </dc:macro>
1327
1328 <dc:macro name="longitudinal-section-prototype">
1329 <dc:call-macro name="basedata_0"/>
1330 <dc:call-macro name="basedata_1_additionals"/>
1331 <dc:call-macro name="basedata_2_fixations"/>
1332 <dc:call-macro name="basedata_4_heightmarks-points"/>
1333 <dc:call-macro name="basedata_3_officials"/>
1334 <dc:call-macro name="basedata_5_flood-protections"/>
1335 <dc:call-macro name="annotations_per_type"/>
1336 </dc:macro>
1337
1338 <dc:macro name="basedata_5_flood-protections">
1339 <dc:filter expr="$kind=5">
1340 <dc:if test="dc:has-result()">
1341 <flood_protections>
1342 <dc:group expr="dc:replace($wst_description, 'HW-Schutzanlagen/', '')">
1343 <flood_protection name="{dc:group-key()}">
1344 <dc:for-each>
1345 <column name="{$wst_column_name}"
1346 ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}"
1347 factory="staticwkms"
1348 info="{$info} [km {$deffrom} - {$defto}]"/>
1349 </dc:for-each>
1350 </flood_protection>
1351 </dc:group>
1352 </flood_protections>
1353 </dc:if>
1354 </dc:filter>
1355 </dc:macro>
1356
1357 <dc:macro name="annotations_per_type">
1358 <annotations>
1359 <dc:context>
1360 <all_annotations factory="annotations" ids="{$river_id}"/>
1361 <dc:statement>
1362 SELECT id AS anno_id,
1363 name AS anno_description
1364 FROM annotation_types
1365 </dc:statement>
1366 <dc:for-each>
1367 <annotation name="{$anno_description}"
1368 factory="annotations"
1369 ids="{$river_id}:{$anno_description}"/>
1370 </dc:for-each>
1371 </dc:context>
1372 </annotations>
1373 </dc:macro>
1374
1375 <dc:macro name="basedata_2_fixations_relative_point">
1376 <dc:filter expr="$kind=2">
1377 <dc:if test="dc:has-result()">
1378 <fixations>
1379 <dc:group expr="dc:replace($wst_description, 'Fixierungen/', '')">
1380 <relativepoint name="{dc:group-key()}">
1381 <dc:for-each>
1382 <column name="{$wst_column_name}"
1383 ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
1384 factory="staticwkms"
1385 info="{$info} [km {$deffrom} - {$defto}]"/>
1386 </dc:for-each>
1387 </relativepoint>
1388 </dc:group>
1389 </fixations>
1390 </dc:if>
1391 </dc:filter>
1392 </dc:macro>
1393
1394 <dc:macro name="basedata_5_flood-protections_relative_points">
1395 <dc:filter expr="$kind=5">
1396 <dc:if test="dc:has-result()">
1397 <flood_protections>
1398 <dc:group expr="$wst_description">
1399 <relativepoint name="{dc:group-key()}">
1400 <dc:for-each>
1401 <column name="{$wst_column_name}"
1402 ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}"
1403 factory="staticwkms"
1404 info="{$info} [km {$deffrom} - {$defto}]"/>
1405 </dc:for-each>
1406 </relativepoint>
1407 </dc:group>
1408 </flood_protections>
1409 </dc:if>
1410 </dc:filter>
1411 </dc:macro>
1412
1413 <dc:macro name="basedata_1_additionals-relative_point">
1414 <dc:filter expr="$kind=1">
1415 <dc:if test="dc:has-result()">
1416 <additionals>
1417 <dc:group expr="$wst_description">
1418 <relativepoint name="{dc:group-key()}">
1419 <dc:for-each>
1420 <column name="{$wst_column_name}"
1421 ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
1422 factory="staticwkms"
1423 info="{$info} [km {$deffrom} - {$defto}]"/>
1424 </dc:for-each>
1425 </relativepoint>
1426 </dc:group>
1427 </additionals>
1428 </dc:if>
1429 </dc:filter>
1430 </dc:macro>
1431
1432 <dc:macro name="discharge_table_gauge">
1433 <dc:context>
1434 <dc:statement>
1435 SELECT id AS gauge_id,
1436 name AS gauge_name
1437 FROM gauges WHERE river_id = ${river_id}
1438 </dc:statement>
1439 <dc:if test="dc:has-result()">
1440 <discharge_table_nn>
1441 <discharge_table_gauge>
1442 <dc:for-each>
1443 <gauge name="{$gauge_name}"
1444 factory="gaugedischarge"
1445 from="{$g_start}"
1446 to="{$g_stop}"
1447 ids="{$gauge_name}"/>
1448 </dc:for-each>
1449 </discharge_table_gauge>
1450 </discharge_table_nn>
1451 </dc:if>
1452 </dc:context>
1453 </dc:macro>
1454
1455 <dc:comment>TODO: Why is this just a copy of the discharge_table_gauge?</dc:comment>
1456 <dc:macro name="discharge_computed">
1457 <dc:call-macro name="discharge_table_gauge"/>
1458 </dc:macro>
1459
1460 <dc:comment>TODO: Why is this just a copy of the discharge_table_gauge?</dc:comment>
1461 <dc:macro name="discharge_fix_wq">
1462 <dc:call-macro name="discharge_table_gauge"/>
1463 </dc:macro>
1464
1465 <dc:macro name="qsectors">
1466 <qsector factory="qsectors" ids="{$river_id}"/>
1467 </dc:macro>
1468
1469 <dc:macro name="flood-map-recommended">
1470 <kilometrage>
1471 <riveraxis factory="riveraxis" ids="{$river_id}"/>
1472 </kilometrage>
1473 <rastermap>
1474 <background factory="wmsbackground" ids="{$river_id}"/>
1475 </rastermap>
1476 </dc:macro>
1477
1478 <dc:macro name="minfo-heights">
1479 <bedheights>
1480 <dc:call-macro name="bed-heights-single"/>
1481 <dc:call-macro name="bed-heights-epoch"/>
1482 </bedheights>
1483 </dc:macro>
1484
1485 <dc:macro name="bed-heights-single">
1486 <single>
1487 <dc:context>
1488 <dc:statement>
1489 SELECT id AS bedh_id,
1490 year AS bedh_year,
1491 description AS bedh_descr
1492 FROM bed_height_single WHERE river_id = ${river_id}
1493 </dc:statement>
1494 <dc:for-each>
1495 <height factory="bedheight"
1496 ids="bedheight-single-{$bedh_id}-{$bedh_year}"
1497 description="{$bedh_descr}"/>
1498 </dc:for-each>
1499 </dc:context>
1500 </single>
1501 </dc:macro>
1502
1503 <dc:macro name="bed-heights-epoch">
1504 <epoch>
1505 <dc:context>
1506 <dc:statement>
1507 SELECT id AS bedh_id,
1508 time_interval_id AS bedh_interval_id,
1509 description AS bedh_descr
1510 FROM bed_height_epoch WHERE river_id = ${river_id}
1511 </dc:statement>
1512 <dc:for-each>
1513 <height factory="bedheight"
1514 ids="bedheight-epoch-{$bedh_id}-{$bedh_interval_id}"
1515 description="{$bedh_descr}"/>
1516 </dc:for-each>
1517 </dc:context>
1518 </epoch>
1519 </dc:macro>
1520
1521 <dc:macro name="flow_velocity_measurements">
1522 <dc:context>
1523 <dc:statement>
1524 SELECT id AS fvmid,
1525 description AS fvmd
1526 FROM flow_velocity_measurements WHERE river_id = ${river_id}
1527 </dc:statement>
1528 <dc:if test="dc:has-result()">
1529 <flowvelocitymeasurement>
1530 <dc:for-each>
1531 <dc:comment>TODO: Why has this an id and factory?</dc:comment>
1532 <flow_velocity_measurement name="{$fvmd}"
1533 ids="{$fvmid}"
1534 factory="flowvelocity">
1535 <dc:context>
1536 <dc:statement>
1537 SELECT id, description, station, datetime, v, w, q
1538 FROM flow_velocity_measure_values
1539 WHERE measurements_id = ${fvmid}
1540 AND station BETWEEN ${fromkm} AND ${tokm}
1541 </dc:statement>
1542 <dc:for-each>
1543 <measurement_value name="{$description} - {$station} - {$datetime}"
1544 ids="{$id}"
1545 factory="flowvelocity"/>
1546 </dc:for-each>
1547 </dc:context>
1548 </flow_velocity_measurement>
1549 </dc:for-each>
1550 </flowvelocitymeasurement>
1551 </dc:if>
1552 </dc:context>
1553 </dc:macro>
1554
1555 <dc:macro name="morph_width">
1556 <dc:context>
1557 <dc:statement>
1558 SELECT id AS width_id
1559 FROM morphologic_width
1560 WHERE river_id = ${river_id}
1561 </dc:statement>
1562 <dc:if test="dc:has-result()">
1563 <morph_width>
1564 <dc:for-each>
1565 <dc:context>
72 <dc:statement> 1566 <dc:statement>
73 SELECT id AS prot_id, 1567 SELECT min(station) AS from_station,
74 description AS prot_description 1568 max(station) AS to_station
75 FROM wsts WHERE kind = 0 AND river_id = ${river_id} 1569 FROM morphologic_width_values
1570 WHERE morphologic_width_id = ${width_id}
76 </dc:statement> 1571 </dc:statement>
77 <dc:for-each> 1572 <dc:for-each>
78 <basedata name="{$prot_description}"> 1573 <morphologic-width name="{$from_station} - {$to_station}"
79 <dc:context> 1574 ids="{$width_id}"
80 <dc:call-macro name="SQL-wst_columns_statement"/> 1575 factory="morph-width"/>
81 <dc:for-each>
82 <column name="{$prot_column_name}"
83 ids="base_data-wstv-{$prot_rel_pos}-{$prot_id}"
84 factory="staticwqkms" out="{$OUT}"
85 info="{$info} [km {$deffrom} - {$defto}]"/>
86 </dc:for-each>
87 </dc:context>
88 </basedata>
89 </dc:for-each> 1576 </dc:for-each>
90 </dc:context> 1577 </dc:context>
1578 </dc:for-each>
1579 </morph_width>
1580 </dc:if>
1581 </dc:context>
1582 </dc:macro>
1583
1584 <dc:macro name="sounding-width">
1585 <dc:context>
1586 <dc:statement>
1587 SELECT id AS bedh_id,
1588 year AS bedh_year,
1589 description AS bedh_descr
1590 FROM bed_height_single WHERE river_id = ${river_id}
1591 </dc:statement>
1592 <dc:if test="dc:has-result()">
1593 <soundings_width>
1594 <dc:for-each>
1595 <height factory="bedheight"
1596 ids="bedheight-singlevalues-{$bedh_id}-{$bedh_year}"
1597 description="{$bedh_descr}"/>
1598 </dc:for-each>
1599 </soundings_width>
1600 </dc:if>
1601 </dc:context>
1602 </dc:macro>
1603
1604 <dc:macro name="basedata_0_macro">
1605 <basedata>
1606 <dc:filter expr="$kind = 0">
1607 <dc:group expr="$wst_description">
1608 <basedata name="{dc:group-key()}">
1609 <dc:for-each>
1610 <dc:macro-body/>
1611 </dc:for-each>
91 </basedata> 1612 </basedata>
92 </dc:call-macro> 1613 </dc:group>
1614 </dc:filter>
1615 </basedata>
1616 </dc:macro>
1617
1618 <dc:macro name="basedata_0">
1619 <dc:call-macro name="basedata_0_macro">
1620 <column name="{$wst_column_name}"
1621 ids="base_data-wstv-{$wst_column_position}-{$wst_id}"
1622 factory="staticwqkms"
1623 info="{$info} [km {$deffrom} - {$defto}]"/>
1624 </dc:call-macro>
1625 </dc:macro>
1626
1627 <dc:macro name="basedata_0_wq">
1628 <dc:call-macro name="basedata_0_macro">
1629 <column name="{$wst_column_name}"
1630 ids="base_data-wstv-{$wst_column_position}-{$wst_id}"
1631 factory="wqinterpol"
1632 info="{$info} [km {$deffrom} - {$defto}]"/>
1633 </dc:call-macro>
1634 </dc:macro>
1635
1636 <dc:macro name="basedata_1_additionals_macro">
1637 <additionals>
1638 <dc:filter expr="$kind=1">
1639 <dc:group expr="dc:replace($wst_description, 'Zus.Längsschnitte/', '')">
1640 <additional name="{dc:group-key()}">
1641 <dc:macro-body/>
1642 </additional>
1643 </dc:group>
1644 </dc:filter>
1645 </additionals>
1646 </dc:macro>
1647
1648 <dc:macro name="basedata_1_additionals">
1649 <dc:call-macro name="basedata_1_additionals_macro">
1650 <column name="{$wst_column_name}"
1651 ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
1652 factory="staticwqkms"
1653 info="{$info} [km {$deffrom} - {$defto}]"/>
1654 </dc:call-macro>
1655 </dc:macro>
1656
1657 <dc:macro name="basedata_1_additionals_marks">
1658 <dc:call-macro name="basedata_1_additionals_macro">
1659 <column name="{$wst_column_name}"
1660 ids="additionalsmarks-wstv-{$wst_column_position}-{$wst_id}"
1661 factory="staticwkms"
1662 info="{$info} [km {$deffrom} - {$defto}]"/>
1663 </dc:call-macro>
1664 </dc:macro>
1665
1666 <!-- Floodmap part -->
1667 <dc:macro name="flood-map-complete">
1668 <dc:call-macro name="flood-map-buildings"/>
1669 <dc:call-macro name="catchments"/>
1670 <dc:call-macro name="floodmarks"/>
1671 <hws>
1672 <dc:call-macro name="hwslines"/>
1673 <dc:call-macro name="hwspoints"/>
1674 </hws>
1675 <dc:call-macro name="flood-map-routing"/>
1676 <hydrboundaries>
1677 <dc:call-macro name="flood-map-floodplain"/>
1678 <dc:call-macro name="flood-map-hydr-boundaries"/>
1679 </hydrboundaries>
1680 <dc:call-macro name="flood-map-uesk"/>
1681 </dc:macro>
1682
1683 <dc:macro name="flood-map-routing">
1684 <route_data>
1685 <dc:call-macro name="flood-map-qps"/>
1686 <dc:call-macro name="flood-map-fixpoints"/>
1687 <dc:call-macro name="flood-map-km"/>
1688 <dc:call-macro name="flood-map-riveraxis"/>
1689 </route_data>
1690 </dc:macro>
1691
1692 <dc:macro name="flood-map-hydr-boundaries">
1693 <bfg_model>
1694 <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
1695 <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
1696 </bfg_model>
1697 <dc:call-macro name="flood-map-hydr-boundaries-state"/>
1698 </dc:macro>
1699
1700 <dc:macro name="flood-map-recommended">
1701 <dc:comment>
1702 FIXME: Following two macros look identical to me.
1703 </dc:comment>
1704 <kilometrage>
1705 <riveraxis factory="riveraxis" ids="{$river_id}"/>
1706 </kilometrage>
1707 <rastermap>
1708 <background factory="wmsbackground" ids="{$river_id}"/>
1709 </rastermap>
1710 </dc:macro>
1711
1712 <dc:macro name="flood-map-dem">
1713 <dems>
1714 <dc:context>
1715 <dc:statement>
1716 SELECT d.id AS dem_id,
1717 r.a AS dem_lower,
1718 r.b AS dem_upper,
1719 d.name AS name,
1720 t.start_time AS start_time,
1721 t.stop_time AS stop_time,
1722 'Projektion: ' || d.projection || '$' ||
1723 'Rasterweite: ' || d.resolution || 'm$' ||
1724 'Format: ' || d.format || '$' ||
1725 'Zeitraum: '
1726 AS info
1727 FROM dem d
1728 JOIN ranges r ON d.range_id = r.id
1729 LEFT JOIN time_intervals t ON d.time_interval_id = t.id
1730 WHERE d.river_id = ${river_id}
1731 </dc:statement>
1732 <dc:for-each>
1733 <dem factory="demfactory"
1734 ids="{$dem_id}"
1735 name="{$name}"
1736 info="{dc:replace($info, '$', '&lt;BR&gt;')}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
1737 </dc:for-each>
1738 </dc:context>
1739 </dems>
1740 </dc:macro>
1741
1742 <dc:macro name="filter_hws_ddg">
1743 <dc:macro name="durchlass_damm_graben">
1744 <dc:macro name="ddg_factory">
1745 <dc:for-each>
1746 <hws factory="hwsfactory" name="{$hws_name}"/>
1747 </dc:for-each>
93 </dc:macro> 1748 </dc:macro>
94 1749
95 <dc:macro name="basedata_0_wq"> 1750 <dc:filter expr="$hws_kind=1">
96 <dc:call-macro name="user-range"> 1751 <dc:if test="dc:has-result()">
97 <dc:comment comment=" BASEDATA ---------------------------"/> 1752 <Durchlass><dc:call-macro name="ddg_factory"/></Durchlass>
98 <basedata> 1753 </dc:if>
99 <dc:context connection="system"> 1754 </dc:filter>
100 <dc:statement> 1755
101 SELECT id AS prot_id, 1756 <dc:filter expr="$hws_kind=2">
102 description AS prot_description 1757 <dc:if test="dc:has-result()">
103 FROM wsts WHERE kind = 0 AND river_id = ${river_id} 1758 <Damm><dc:call-macro name="ddg_factory"/></Damm>
104 </dc:statement> 1759 </dc:if>
105 <dc:for-each> 1760 </dc:filter>
106 <basedata name="{$prot_description}"> 1761
107 <dc:context> 1762 <dc:filter expr="$hws_kind=3">
108 <dc:call-macro name="SQL-wst_columns_statement"/> 1763 <dc:if test="dc:has-result()">
109 <dc:for-each> 1764 <Graben><dc:call-macro name="ddg_factory"/></Graben>
110 <column name="{$prot_column_name}" 1765 </dc:if>
111 ids="base_data-wstv-{$prot_rel_pos}-{$prot_id}" 1766 </dc:filter>
112 factory="wqinterpol" out="{$OUT}" 1767 </dc:macro>
113 info="{$info} [km {$deffrom} - {$defto}]"/> 1768
114 </dc:for-each> 1769 <dc:filter expr="$hws_official=1">
115 </dc:context> 1770 <dc:if test="dc:has-result()">
116 </basedata> 1771 <official>
117 </dc:for-each> 1772 <dc:call-macro name="durchlass_damm_graben"/>
118 </dc:context> 1773 </official>
119 </basedata> 1774 </dc:if>
120 </dc:call-macro> 1775 </dc:filter>
121 </dc:macro> 1776
122 1777 <dc:filter expr="$hws_official=0">
123 <dc:macro name="basedata_1_additionals_marks"> 1778 <dc:if test="dc:has-result()">
124 <dc:call-macro name="user-range"> 1779 <inofficial>
125 <dc:comment comment=".ZUS -------------------------------"/> 1780 <dc:call-macro name="durchlass_damm_graben"/>
126 <additionals> 1781 </inofficial>
127 <dc:context connection="system"> 1782 </dc:if>
128 <dc:statement> 1783 </dc:filter>
129 SELECT id AS prot_id, 1784 </dc:macro>
130 description AS prot_description 1785
131 FROM wsts WHERE kind = 1 AND river_id = ${river_id} 1786 <dc:macro name="flood-map-hydr-boundaries-state">
132 </dc:statement> 1787 <federal>
133 <dc:for-each> 1788 <dc:context>
134 <additional name="{$prot_description}"> 1789 <dc:statement>
135 <dc:context> 1790 SELECT DISTINCT
136 <dc:call-macro name="SQL-wst_columns_statement"/> 1791 name
137 <dc:for-each> 1792 FROM hydr_boundaries
138 <column name="{$prot_column_name}" 1793 WHERE river_id = ${river_id}
139 ids="additionalsmarks-wstv-{$prot_rel_pos}-{$prot_id}" 1794 AND kind = 2
140 factory="staticwkms" out="{$OUT}" 1795 </dc:statement>
141 info="{$info} [km {$deffrom} - {$defto}]"/> 1796 <dc:for-each>
142 </dc:for-each> 1797 <line factory="wmshydrboundariesfactory"
143 </dc:context></additional> 1798 ids="{$river_id};{$name};2"
144 </dc:for-each> 1799 name="{$name}"/>
145 </dc:context> 1800 </dc:for-each>
146 </additionals> 1801 </dc:context>
147 </dc:call-macro> 1802 <dc:context>
148 </dc:macro> 1803 <dc:statement>
149 1804 SELECT DISTINCT
150 <dc:macro name="basedata_1_additionals"> 1805 name
151 <dc:call-macro name="user-range"> 1806 FROM hydr_boundaries_poly
152 <dc:comment comment=".ZUS -------------------------------"/> 1807 WHERE river_id = ${river_id}
153 <additionals> 1808 AND kind = 2
154 <dc:context connection="system"> 1809 </dc:statement>
155 <dc:statement> 1810 <dc:for-each>
156 SELECT id AS prot_id, 1811 <line factory="wmshydrboundariespolyfactory"
157 description AS prot_description 1812 ids="{$river_id};{$name};2"
158 FROM wsts WHERE kind = 1 AND river_id = ${river_id} 1813 name="{$name}"/>
159 </dc:statement> 1814 </dc:for-each>
160 <dc:for-each> 1815 </dc:context>
161 <additional name="{dc:replace($prot_description, 'Zus.Längsschnitte/', '')}"> 1816 </federal>
162 <dc:context> 1817 </dc:macro>
163 <dc:call-macro name="SQL-wst_columns_statement"/> 1818
164 <dc:for-each> 1819 <dc:macro name="flood-map-hydr-boundaries-lines">
165 <column name="{$prot_column_name}" 1820 <dc:context>
166 ids="additionals-wstv-{$prot_rel_pos}-{$prot_id}" 1821 <dc:statement>
167 factory="staticwqkms" out="{$OUT}" 1822 SELECT DISTINCT
168 info="{$info} [km {$deffrom} - {$defto}]"/> 1823 name
169 </dc:for-each> 1824 FROM hydr_boundaries
170 </dc:context> 1825 WHERE river_id = ${river_id}
171 </additional> 1826 AND kind = 1
172 </dc:for-each> 1827 </dc:statement>
173 </dc:context> 1828 <dc:comment> What about all other line kinds?</dc:comment>
174 </additionals> 1829 <dc:if test="dc:has-result()">
175 </dc:call-macro> 1830 <lines>
176 </dc:macro> 1831 <dc:for-each>
177 1832 <line factory="wmshydrboundariesfactory"
178 <dc:macro name="basedata_1_additionals-relative_point"> 1833 ids="{$river_id};{$name};1"
179 <dc:call-macro name="user-range"> 1834 name="{$name}"/>
180 <dc:comment comment=".ZUS -------------------------------"/> 1835 </dc:for-each>
181 <additionals> 1836 </lines>
182 <dc:context connection="system"> 1837 </dc:if>
183 <dc:statement> 1838 </dc:context>
184 SELECT id AS prot_id, 1839 </dc:macro>
185 description AS prot_description 1840
186 FROM wsts WHERE kind = 1 AND river_id = ${river_id} 1841 <dc:macro name="flood-map-hydr-boundaries-poly">
187 </dc:statement> 1842 <areas>
188 <dc:for-each> 1843 <dc:context>
189 <relativepoint name="{$prot_description}"> 1844 <dc:statement>
190 <dc:context> 1845 SELECT DISTINCT
191 <dc:call-macro name="SQL-wst_columns_statement"/> 1846 b.sectie AS sectie_id,
192 <dc:for-each> 1847 sk.name AS sectie
193 <column name="{$prot_column_name}" 1848 FROM hydr_boundaries_poly b
194 ids="additionals-wstv-{$prot_rel_pos}-{$prot_id}" 1849 JOIN sectie_kinds sk ON b.sectie = sk.id
195 factory="staticwkms" out="{$OUT}" 1850 WHERE b.river_id = ${river_id}
196 info="{$info} [km {$deffrom} - {$defto}]"/> 1851 AND b.kind = 1
197 </dc:for-each> 1852 </dc:statement>
198 </dc:context> 1853 <dc:if test="dc:has-result()">
199 </relativepoint> 1854 <sobek_areas>
200 </dc:for-each>
201 </dc:context>
202 </additionals>
203 </dc:call-macro>
204 </dc:macro>
205
206 <dc:macro name="basedata_2_fixations_wqkms">
207 <dc:call-macro name="user-range">
208 <fixations>
209 <dc:context connection="system">
210 <dc:statement>
211 SELECT id AS prot_id,
212 description AS prot_description
213 FROM wsts WHERE kind = 2 AND river_id = ${river_id}
214 ORDER BY prot_description
215 </dc:statement>
216 <dc:for-each>
217 <fixation name="{dc:replace($prot_description, 'Fixierungen/', '')}">
218 <dc:context>
219 <dc:call-macro name="SQL-wst_columns_statement"/>
220 <dc:for-each>
221 <column name="{$prot_column_name}"
222 ids="fixations-wstv-{$prot_rel_pos}-{$prot_id}"
223 factory="wqinterpol" out="{$OUT}"
224 info="{$info} [km {$deffrom} - {$defto}]"/>
225 </dc:for-each>
226 </dc:context>
227 </fixation>
228 </dc:for-each>
229 </dc:context>
230 </fixations>
231 </dc:call-macro>
232 </dc:macro>
233
234 <dc:macro name="basedata_2_fixations">
235 <dc:call-macro name="user-range">
236 <fixations>
237 <dc:context connection="system">
238 <dc:statement>
239 SELECT id AS prot_id,
240 description AS prot_description
241 FROM wsts WHERE kind = 2 AND river_id = ${river_id}
242 ORDER BY prot_description
243 </dc:statement>
244 <dc:for-each>
245 <fixation name="{dc:replace($prot_description, 'Fixierungen/', '')}">
246 <dc:context>
247 <dc:call-macro name="SQL-wst_columns_statement"/>
248 <dc:for-each>
249 <column name="{$prot_column_name}"
250 ids="fixations-wstv-{$prot_rel_pos}-{$prot_id}"
251 factory="staticwqkms" out="{$OUT}"
252 info="{$info} [km {$deffrom} - {$defto}]"/>
253 </dc:for-each>
254 </dc:context>
255 </fixation>
256 </dc:for-each>
257 </dc:context>
258 </fixations>
259 </dc:call-macro>
260 </dc:macro>
261
262 <dc:macro name="basedata_2_fixations_relative_point">
263 <dc:call-macro name="user-range">
264 <fixations>
265 <dc:context connection="system">
266 <dc:statement>
267 SELECT id AS prot_id,
268 description AS prot_description
269 FROM wsts WHERE kind = 2 AND river_id = ${river_id}
270 ORDER BY prot_description
271 </dc:statement>
272 <dc:for-each>
273 <relativepoint name="{dc:replace($prot_description, 'Fixierungen/', '')}">
274 <dc:context>
275 <dc:call-macro name="SQL-wst_columns_statement"/>
276 <dc:for-each>
277 <column name="{$prot_column_name}"
278 ids="fixations-wstv-{$prot_rel_pos}-{$prot_id}"
279 factory="staticwkms" out="{$OUT}"
280 info="{$info} [km {$deffrom} - {$defto}]"/>
281 </dc:for-each>
282 </dc:context>
283 </relativepoint>
284 </dc:for-each>
285 </dc:context>
286 </fixations>
287 </dc:call-macro>
288 </dc:macro>
289
290 <dc:macro name="basedata_3_officials">
291 <dc:call-macro name="user-range">
292 <dc:comment comment=".wst -------------------------------"/>
293 <officiallines>
294 <dc:context connection="system">
295 <dc:statement>
296 SELECT id AS prot_id,
297 description AS prot_description
298 FROM wsts WHERE kind = 3 AND river_id = ${river_id}
299 </dc:statement>
300 <dc:for-each>
301 <official name="{$prot_description}">
302 <dc:context>
303 <dc:call-macro name="SQL-wst_columns_statement"/>
304 <dc:for-each>
305 <column name="{$prot_column_name}"
306 ids="additionals-wstv-{$prot_rel_pos}-{$prot_id}"
307 factory="staticwqkms" out="{$OUT}"
308 info="{$info} [km {$deffrom} - {$defto}]"/>
309 </dc:for-each>
310 </dc:context>
311 </official>
312 </dc:for-each>
313 </dc:context>
314 </officiallines>
315 </dc:call-macro>
316 </dc:macro>
317
318 <dc:macro name="basedata_4_heightmarks-points-relative_points">
319 <dc:call-macro name="user-range">
320 <heightmarks>
321 <dc:context connection="system">
322 <dc:statement>
323 SELECT id AS prot_id,
324 description AS prot_description
325 FROM wsts WHERE kind = 4 AND river_id = ${river_id}
326 </dc:statement>
327 <dc:for-each>
328 <relativepoint name="{$prot_description}">
329 <dc:context>
330 <dc:call-macro name="SQL-wst_columns_statement"/>
331 <dc:for-each>
332 <column name="{$prot_column_name}"
333 ids="heightmarks_points-wstv-{$prot_rel_pos}-{$prot_id}"
334 factory="staticwkms" out="{$OUT}"
335 info="{$info} [km {$deffrom} - {$defto}]"/>
336 </dc:for-each>
337 </dc:context>
338 </relativepoint>
339 </dc:for-each>
340 </dc:context>
341 </heightmarks>
342 </dc:call-macro>
343 </dc:macro>
344
345 <dc:macro name="basedata_4_heightmarks-points">
346 <dc:call-macro name="user-range">
347 <heightmarks>
348 <dc:context connection="system">
349 <dc:statement>
350 SELECT id AS prot_id,
351 description AS prot_description
352 FROM wsts WHERE kind = 4 AND river_id = ${river_id}
353 </dc:statement>
354 <dc:for-each>
355 <heightmark name="{dc:replace($prot_description, 'HW-Marken/', '')}">
356 <dc:context>
357 <dc:call-macro name="SQL-wst_columns_statement"/>
358 <dc:for-each>
359 <column name="{$prot_column_name}"
360 ids="heightmarks_points-wstv-{$prot_rel_pos}-{$prot_id}"
361 factory="staticwkms" out="{$OUT}"
362 info="{$info} [km {$deffrom} - {$defto}]"/>
363 </dc:for-each>
364 </dc:context>
365 </heightmark>
366 </dc:for-each>
367 </dc:context>
368 </heightmarks>
369 </dc:call-macro>
370 </dc:macro>
371
372 <dc:macro name="basedata_5_flood-protections_relative_points">
373 <dc:call-macro name="user-range">
374 <flood_protections id="flood-protections-{$river_id}">
375 <dc:context connection="system">
376 <dc:statement>
377 SELECT id AS prot_id,
378 description AS prot_description
379 FROM wsts WHERE kind = 5 AND river_id = ${river_id}
380 </dc:statement>
381 <dc:for-each>
382 <relativepoint name="{$prot_description}"
383 db-id="{$prot_id}"
384 factory="staticwkms" out="{$OUT}">
385 <columns>
386 <dc:context>
387 <dc:call-macro name="SQL-wst_columns_statement"/>
388 <dc:for-each>
389 <column name="{$prot_column_name}"
390 ids="flood_protection-wstv-{$prot_rel_pos}-{$prot_id}"
391 factory="staticwkms" out="{$OUT}"
392 info="{$info} [km {$deffrom} - {$defto}]"/>
393 </dc:for-each>
394 </dc:context>
395 </columns>
396 </relativepoint>
397 </dc:for-each>
398 </dc:context></flood_protections>
399 </dc:call-macro>
400 </dc:macro>
401
402 <dc:macro name="basedata_5_flood-protections">
403 <dc:call-macro name="user-range">
404 <flood_protections id="flood-protections-{$river_id}">
405 <dc:context connection="system">
406 <dc:statement>
407 SELECT id AS prot_id,
408 description AS prot_description
409 FROM wsts WHERE kind = 5 AND river_id = ${river_id}
410 </dc:statement>
411 <dc:for-each>
412 <flood_protection name="{dc:replace($prot_description, 'HW-Schutzanlagen/', '')}"
413 db-id="{$prot_id}"
414 factory="staticwkms" out="{$OUT}">
415 <dc:context>
416 <dc:call-macro name="SQL-wst_columns_statement"/>
417 <dc:for-each>
418 <column name="{$prot_column_name}"
419 ids="flood_protection-wstv-{$prot_rel_pos}-{$prot_id}"
420 factory="staticwkms" out="{$OUT}"
421 info="{$info} [km {$deffrom} - {$defto}]"/>
422 </dc:for-each>
423 </dc:context>
424 </flood_protection>
425 </dc:for-each>
426 </dc:context>
427 </flood_protections>
428 </dc:call-macro>
429 </dc:macro>
430
431 <dc:macro name="mainvalues">
432 <wmainvalue factory="mainvalue" out="{$OUT}" ids="{$river_id}:w"/>
433 <qmainvalue factory="mainvalue" out="{$OUT}" ids="{$river_id}:q"/>
434 </dc:macro>
435
436 <dc:macro name="qsectors">
437 <qsector factory="qsectors" out="{$OUT}" ids="{$river_id}"/>
438 </dc:macro>
439
440 <dc:macro name="annotations">
441 <annotation factory="annotations" out="{$OUT}" ids="{$river_id}"/>
442 </dc:macro>
443
444 <dc:macro name="annotations_per_type">
445 <annotations>
446 <dc:context>
447 <all_annotations factory="annotations" out="{$OUT}" ids="{$river_id}"/>
448 <dc:statement>
449 SELECT id AS anno_id,
450 name AS anno_description
451 FROM annotation_types
452 </dc:statement>
453 <dc:for-each> 1855 <dc:for-each>
454 <annotation name="{$anno_description}" 1856 <boundary name="{$sectie}"
455 factory="annotations" out="{$OUT}" 1857 factory="wmshydrboundariespolyfactory"
456 ids="{$river_id}:{$anno_description}"/> 1858 ids="{$river_id};{$sectie};1;{$sectie_id};-1"/>
457 </dc:for-each> 1859 </dc:for-each>
458 </dc:context> 1860 </sobek_areas>
459 </annotations> 1861 </dc:if>
460 </dc:macro> 1862 </dc:context>
461 1863 <dc:context>
462 <dc:macro name="cross_sections"> 1864 <dc:statement>
463 <dc:call-macro name="user-range"> 1865 SELECT DISTINCT
464 <cross_sections id="flood-protections-{$river_id}"> 1866 b.sobek AS sobek_id,
465 <dc:context connection="system"> 1867 sk.name AS sobek
466 <dc:statement> 1868 FROM hydr_boundaries_poly b
467 SELECT DISTINCT 1869 JOIN sobek_kinds sk ON b.sobek = sk.id
468 cs.id AS prot_id, 1870 WHERE b.river_id = ${river_id}
469 cs.description AS prot_description 1871 AND b.kind = 1
470 FROM cross_sections cs 1872 </dc:statement>
471 JOIN cross_section_lines csl ON csl.cross_section_id = cs.id 1873 <dc:if test="dc:has-result()">
472 WHERE cs.river_id = ${river_id} 1874 <sobek_flooded>
473 AND csl.km BETWEEN ${fromkm} AND ${tokm} 1875 <dc:for-each>
474 </dc:statement> 1876 <boundary name="{$sobek}"
475 <dc:for-each> 1877 factory="wmshydrboundariespolyfactory"
476 <cross_section name="{$prot_description}" 1878 ids="{$river_id};{$sobek};1;-1;{$sobek_id}"/>
477 ids="{$prot_id}" 1879 </dc:for-each>
478 factory="crosssections" out="{$OUT}"/> 1880 </sobek_flooded>
479 </dc:for-each> 1881 </dc:if>
480 </dc:context> 1882 </dc:context>
481 </cross_sections> 1883 <dc:context>
482 </dc:call-macro> 1884 <dc:statement>
483 </dc:macro> 1885 SELECT DISTINCT
484 1886 b.name AS name
485 <dc:macro name="hyks"> 1887 FROM hydr_boundaries_poly b
486 <dc:call-macro name="user-range"> 1888 WHERE b.river_id = ${river_id}
487 <hyks id="hyk-{$river_id}"> 1889 AND b.kind = 1
488 <dc:context connection="system"> 1890 AND b.sobek IS NULL
489 <dc:statement> 1891 AND b.sectie is NULL
490 SELECT DISTINCT 1892 </dc:statement>
491 h.id AS hyk_id, 1893 <dc:for-each>
492 h.description AS hyk_description 1894 <boundary name="{$name}"
493 FROM hyks h 1895 factory="wmshydrboundariespolyfactory"
494 JOIN hyk_entries he ON he.hyk_id = h.id 1896 ids="{$river_id};{$name}"/>
495 WHERE river_id = ${river_id} 1897 </dc:for-each>
496 AND he.km BETWEEN ${fromkm} AND ${tokm} 1898 </dc:context>
497 </dc:statement> 1899 </areas>
498 <dc:for-each> 1900 </dc:macro>
499 <hyk name="{$hyk_description}" 1901
500 ids="{$hyk_id}" 1902 <dc:macro name="flood-map-uesk">
501 factory="hyk" out="{$OUT}"/> 1903 <dc:context>
502 </dc:for-each> 1904 <dc:statement>
503 </dc:context></hyks> 1905 SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
504 </dc:call-macro> 1906 </dc:statement>
505 </dc:macro> 1907 <dc:if test="dc:has-result()">
506 1908 <uesk>
507 <dc:macro name="flow_velocity_measurements"> 1909 <calculations>
508 <dc:call-macro name="user-range">
509 <flowvelocitymeasurement>
510 <dc:context connection="system">
511 <dc:statement>
512 SELECT id AS fvmid,
513 description AS fvmd
514 FROM flow_velocity_measurements WHERE river_id = ${river_id}
515 </dc:statement>
516 <dc:for-each>
517 <flow_velocity_measurement name="{$fvmd}"
518 ids="{$fvmid}"
519 factory="flowvelocity" out="{$OUT}">
520 <dc:context>
521 <dc:statement>
522 SELECT id, description, station, datetime, v, w, q
523 FROM flow_velocity_measure_values
524 WHERE measurements_id = ${fvmid}
525 AND station BETWEEN ${fromkm} AND ${tokm}
526 </dc:statement>
527 <dc:for-each>
528 <measurement_value name="{$description} - {$station} - {$datetime}"
529 ids="{$id}"
530 factory="flowvelocity" out="{$OUT}"/>
531 </dc:for-each>
532 </dc:context>
533 </flow_velocity_measurement>
534 </dc:for-each>
535 </dc:context>
536 </flowvelocitymeasurement>
537 </dc:call-macro>
538 </dc:macro>
539
540 <dc:macro name="sounding-width">
541 <soundings_width>
542 <dc:context> 1910 <dc:context>
543 <dc:statement> 1911 <dc:statement>
544 SELECT id AS bedh_id, 1912 SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
545 year AS bedh_year, 1913 AND (kind = 112 OR kind = 111)
546 description AS bedh_descr
547 FROM bed_height_single WHERE river_id = ${river_id}
548 </dc:statement>
549 <dc:for-each>
550 <height factory="bedheight" out="{$OUT}"
551 ids="bedheight-singlevalues-{$bedh_id}-{$bedh_year}"
552 description="{$bedh_descr}"/>
553 </dc:for-each>
554 </dc:context>
555 </soundings_width>
556 </dc:macro>
557
558 <dc:macro name="morph_width">
559 <morph_width>
560 <dc:context>
561 <dc:statement>
562 SELECT id AS width_id
563 FROM morphologic_width
564 WHERE river_id = ${river_id}
565 </dc:statement>
566 <dc:for-each>
567 <dc:context>
568 <dc:statement>
569 SELECT min(station) AS from_station,
570 max(station) AS to_station
571 FROM morphologic_width_values
572 WHERE morphologic_width_id = ${width_id}
573 </dc:statement>
574 <dc:for-each>
575 <morphologic-width name="{$from_station} - {$to_station}"
576 ids="{$width_id}"
577 factory="morph-width"/>
578 </dc:for-each>
579 </dc:context>
580 </dc:for-each>
581 </dc:context>
582 </morph_width>
583 </dc:macro>
584
585 <dc:macro name="longitudinal-section-prototype">
586 <dc:call-macro name="basedata_0"/>
587 <dc:call-macro name="basedata_1_additionals"/>
588 <dc:comment comment=" FIXATIONS ---------------------------"/>
589 <dc:call-macro name="basedata_2_fixations"/>
590 <dc:comment comment=" HOEHENMARKEN ---------------------------"/>
591 <dc:call-macro name="basedata_4_heightmarks-points"/>
592 <dc:comment comment=" AMTL LINIEN ---------------------------"/>
593 <dc:call-macro name="basedata_3_officials"/>
594 <dc:call-macro name="basedata_5_flood-protections"/>
595 <dc:call-macro name="annotations_per_type"/>
596 </dc:macro>
597
598 <dc:macro name="discharge_table_gauge">
599 <discharge_table_nn>
600 <discharge_table_gauge>
601 <dc:context>
602 <dc:statement>
603 SELECT id AS gauge_id,
604 name AS gauge_name
605 FROM gauges WHERE river_id = ${river_id}
606 </dc:statement>
607 <dc:for-each>
608 <gauge name="{$gauge_name}"
609 db-id="{$gauge_id}"
610 factory="gaugedischarge" out="{$OUT}"
611 from="{$g_start}"
612 to="{$g_stop}"
613 ids="{$gauge_name}"/>
614 </dc:for-each>
615 </dc:context>
616 </discharge_table_gauge>
617 </discharge_table_nn>
618 </dc:macro>
619
620 <dc:macro name="discharge_computed">
621 <discharge_table_nn>
622 <discharge_table_gauge>
623 <dc:context>
624 <dc:statement>
625 SELECT id AS gauge_id,
626 name AS gauge_name
627 FROM gauges WHERE river_id = ${river_id}
628 </dc:statement>
629 <dc:for-each>
630 <gauge name="{$gauge_name}"
631 db-id="{$gauge_id}"
632 factory="gaugedischarge" out="{$OUT}"
633 from="{$g_start}"
634 to="{$g_stop}"
635 ids="{$gauge_name}"/>
636 <dc:comment>
637 <!--
638 <gauge>
639 <dc:attribute name="name" value="${gauge_name}"/>
640 <dc:attribute name="db-id" value="${gauge_id}"/>
641 <dc:context>
642 <dc:statement>
643 SELECT description AS gauge_desc,
644 d.id AS discharge_id,
645 ti.start_time AS g_start,
646 ti.stop_time AS g_stop
647 FROM discharge_tables d JOIN time_intervals ti
648 ON d.time_interval_id = ti.id
649 WHERE d.gauge_id = ${gauge_id} AND d.kind = 1
650 </dc:statement>
651 <dc:for-each>
652 <historical>
653 <dc:attribute name="name" value="${gauge_desc}"/>
654 <dc:attribute name="factory" value="gaugedischarge"/>
655 <dc:attribute name="out" value="${out}"/>
656 <dc:attribute name="from" value="${g_start}"/>
657 <dc:attribute name="to" value="${g_stop}"/>
658 <dc:attribute name="ids" value="${discharge_id}-${g_start}-${g_stop}"/>
659 </historical>
660 </dc:for-each>
661 </dc:context>
662 </gauge>
663 -->
664 </dc:comment>
665 </dc:for-each>
666 </dc:context>
667 </discharge_table_gauge>
668 </discharge_table_nn>
669 </dc:macro>
670
671 <dc:macro name="discharge_fix_wq">
672 <discharge_table_nn>
673 <discharge_table_gauge>
674 <dc:context>
675 <dc:statement>
676 SELECT id AS gauge_id,
677 name AS gauge_name
678 FROM gauges WHERE river_id = ${river_id}
679 </dc:statement>
680 <dc:for-each>
681 <gauge name="{$gauge_name}"
682 db-id="{$gauge_id}"
683 factory="gaugedischarge" out="{$OUT}"
684 from="{$g_start}"
685 to="{$g_stop}"
686 ids="{$gauge_name}"/>
687 </dc:for-each>
688 </dc:context>
689 </discharge_table_gauge>
690 </discharge_table_nn>
691 </dc:macro>
692
693 <dc:choose>
694 <dc:when test="dc:contains($parameters, 'recommended')">
695 <dc:comment>
696 Recommendations (client shall load immediately).
697 </dc:comment>
698 <dc:iterate var="out" container="artifact-outs">
699 <dc:choose>
700 <dc:when test="$out = 'w_differences'">
701 <dc:call-macro name="annotations"/>
702 </dc:when>
703 <dc:when test="$out = 'discharge_longitudinal_section'">
704 <dc:call-macro name="annotations"/>
705 </dc:when>
706 <dc:when test="$out = 'historical_discharge_wq'">
707 <dc:call-macro name="mainvalues"/>
708 </dc:when>
709 <dc:when test="$out = 'cross_section'">
710 <dc:call-macro name="cross_sections"/>
711 <dc:call-macro name="hyks"/>
712 </dc:when>
713 <dc:when test="$out = 'discharge_curve'">
714 <dc:call-macro name="mainvalues"/>
715 </dc:when>
716 <dc:when test="$out = 'computed_discharge_curve'">
717 <dc:call-macro name="mainvalues"/>
718 <dc:call-macro name="basedata_2_fixations_wqkms"/>
719 </dc:when>
720 <dc:when test="$out = 'duration_curve'">
721 <dc:call-macro name="mainvalues"/>
722 </dc:when>
723 <dc:when test="$out = 'reference_curve'">
724 <dc:call-macro name="annotations"/>
725 <dc:call-macro name="mainvalues"/>
726 </dc:when>
727 <dc:when test="$out = 'fix_wq_curve'">
728 <dc:call-macro name="mainvalues"/>
729 <dc:call-macro name="qsectors"/>
730 </dc:when>
731 <dc:when test="$out = 'longitudinal_section'">
732 <dc:call-macro name="annotations"/>
733 </dc:when>
734 <dc:when test="$out = 'fix_longitudinal_section_curve'">
735 <dc:call-macro name="annotations"/>
736 </dc:when>
737 <dc:when test="$out = 'bed_difference_epoch'">
738 <dc:call-macro name="annotations"/>
739 </dc:when>
740 <dc:when test="$out = 'bed_difference_year'">
741 <dc:call-macro name="annotations"/>
742 </dc:when>
743 <dc:when test="$out = 'bed_difference_height_year'">
744 <dc:call-macro name="annotations"/>
745 </dc:when>
746 <dc:when test="$out = 'floodmap'">
747 <dc:call-macro name="flood-map-recommended"/>
748 </dc:when>
749 <dc:when test="$out = 'floodmap-hws'">
750 <dc:call-macro name="flood-map-recommended"/>
751 </dc:when>
752 <dc:when test="$out = 'minfo-heights'">
753 <dc:call-macro name="minfo-heights"/>
754 <dc:macro name="minfo-heights">
755 <bedheights>
756 <dc:call-macro name="bed-heights-single"/>
757 <dc:call-macro name="bed-heights-epoch"/>
758 </bedheights>
759 </dc:macro>
760 </dc:when>
761 <dc:when test="$out = 'minfo-heights-epoch'">
762 <bedheights>
763 <dc:call-macro name="bed-heights-epoch"/>
764 </bedheights>
765 </dc:when>
766 </dc:choose>
767 </dc:iterate>
768 </dc:when>
769 <dc:otherwise>
770 <dc:comment>
771 Non - Recommendations.
772 </dc:comment>
773 <dc:iterate var="out" container="artifact-outs">
774 <dc:choose>
775 <dc:when test="$out = 'cross_section'">
776 <dc:call-macro name="basedata_0"/>
777 <dc:call-macro name="basedata_1_additionals"/>
778 <dc:call-macro name="basedata_2_fixations"/>
779 <dc:call-macro name="basedata_3_officials"/>
780 <dc:call-macro name="basedata_4_heightmarks-points"/>
781 <dc:call-macro name="cross_sections"/>
782 <dc:call-macro name="hyks"/>
783 </dc:when>
784 <dc:when test="$out = 'longitudinal_section'">
785 <dc:call-macro name="longitudinal-section-prototype"/>
786 </dc:when>
787 <dc:when test="$out = 'w_differences'">
788 <dc:call-macro name="longitudinal-section-prototype"/>
789 </dc:when>
790 <dc:when test="$out = 'discharge_longitudinal_section'">
791 <dc:call-macro name="longitudinal-section-prototype"/>
792 </dc:when>
793 <dc:when test="$out = 'discharge_curve'">
794 <dc:call-macro name="mainvalues"/>
795 </dc:when>
796 <dc:when test="$out = 'duration_curve'">
797 <dc:call-macro name="mainvalues"/>
798 <dc:call-macro name="basedata_2_fixations_relative_point"/>
799 <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
800 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
801 </dc:when>
802 <dc:when test="$out = 'reference_curve'">
803 <dc:call-macro name="mainvalues"/>
804 <dc:call-macro name="annotations"/>
805 <dc:call-macro name="basedata_1_additionals-relative_point"/>
806 <dc:comment comment=" FIXATIONS ---------------------------"/>
807 <dc:call-macro name="basedata_2_fixations_relative_point"/>
808 <dc:comment comment=" HOEHENMARKEN ---------------------------"/>
809 <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
810 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
811 </dc:when>
812 <dc:when test="$out = 'fix_wq_curve'">
813 <dc:call-macro name="basedata_0_wq"/>
814 <dc:call-macro name="basedata_1_additionals_marks"/>
815 <dc:call-macro name="basedata_2_fixations_wqkms"/>
816 <dc:call-macro name="basedata_3_officials"/>
817 <dc:call-macro name="basedata_4_heightmarks-points"/>
818 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
819 <dc:call-macro name="discharge_table_gauge"/>
820 <dc:call-macro name="discharge_fix_wq"/>
821 </dc:when>
822 <dc:when test="$out = 'fix_deltawt_curve'">
823 </dc:when>
824 <dc:when test="$out = 'fix_longitudinal_section_curve'">
825 <dc:call-macro name="annotations"/>
826 </dc:when>
827 <dc:when test="$out = 'map'">
828 <dc:call-macro name="flood-map-complete"/>
829 </dc:when>
830 <dc:when test="$out = 'flow_velocity'">
831 <dc:call-macro name="annotations_per_type"/>
832 <dc:call-macro name="flow_velocity_measurements"/>
833 </dc:when>
834 <dc:when test="$out = 'bed_longitudinal_section'">
835 <dc:call-macro name="annotations_per_type"/>
836 </dc:when>
837 <dc:when test="$out = 'sedimentload_ls'">
838 <dc:call-macro name="annotations_per_type"/>
839 <dc:call-macro name="morph_width"/>
840 </dc:when>
841 <dc:comment>
842 MINFO bedheight middle
843 </dc:comment>
844 <dc:when test="$out = 'bedheight_middle'">
845 <dc:call-macro name="sounding-width"/>
846 <dc:call-macro name="basedata_0"/>
847 <dc:call-macro name="basedata_1_additionals"/>
848 <dc:call-macro name="basedata_2_fixations"/>
849 <dc:call-macro name="basedata_3_officials"/>
850 <dc:call-macro name="annotations_per_type"/>
851 </dc:when>
852 <dc:when test="$out = 'bed_difference_year'">
853 <dc:call-macro name="basedata_0"/>
854 <dc:call-macro name="basedata_1_additionals"/>
855 <dc:call-macro name="basedata_2_fixations"/>
856 <dc:call-macro name="basedata_3_officials"/>
857 <dc:call-macro name="annotations_per_type"/>
858 <dc:call-macro name="morph_width"/>
859 </dc:when>
860 <dc:when test="$out = 'bed_difference_epoch'">
861 <dc:call-macro name="basedata_0"/>
862 <dc:call-macro name="basedata_1_additionals"/>
863 <dc:call-macro name="basedata_2_fixations"/>
864 <dc:call-macro name="basedata_3_officials"/>
865 <dc:call-macro name="annotations_per_type"/>
866 <dc:call-macro name="morph_width"/>
867 </dc:when>
868 <dc:when test="$out = 'floodmap'">
869 <dc:choose>
870 <dc:when test="dc:contains($parameters, 'dem')">
871 <dc:call-macro name="flood-map-dem"/>
872 </dc:when>
873 <dc:when test="dc:contains($parameters, 'hws')">
874 <hws>
875 <dc:call-macro name="flood-map-hws-lines"/>
876 <dc:call-macro name="flood-map-hws-points"/>
877 </hws>
878 </dc:when>
879 <dc:otherwise>
880 <dc:call-macro name="flood-map-complete"/>
881 </dc:otherwise>
882 </dc:choose>
883 </dc:when>
884 <dc:when test="$out = 'floodmap-hws'">
885 <dc:choose>
886 <dc:when test="dc:contains($parameters, 'dem')">
887 <dc:call-macro name="flood-map-dem"/>
888 </dc:when>
889 <dc:when test="dc:contains($parameters, 'hws')">
890 <hws>
891 <dc:call-macro name="flood-map-hws-lines"/>
892 <dc:call-macro name="flood-map-hws-points"/>
893 </hws>
894 </dc:when>
895 <dc:otherwise>
896 <dc:call-macro name="flood-map-complete"/>
897 </dc:otherwise>
898 </dc:choose>
899 </dc:when>
900 <dc:when test="$out = 'computed_discharge_curve'">
901 <dc:call-macro name="discharge_computed"/>
902 <dc:call-macro name="basedata_2_fixations_wqkms"/>
903
904 <dc:call-macro name="basedata_5_flood-protections"/>
905
906 <!-- former waterlevels -->
907 <dc:call-macro name="basedata_0"/>
908
909 <dc:call-macro name="basedata_1_additionals"/>
910
911 <!-- former flood-water-marks -->
912 <dc:call-macro name="basedata_4_heightmarks-points"/>
913 <computed_discharge_curve>
914 <dc:call-macro name="mainvalues"/>
915 </computed_discharge_curve>
916 </dc:when>
917 <dc:when test="$out = 'minfo-heights'">
918 <dc:call-macro name="minfo-heights"/>
919 <dc:macro name="minfo-heights">
920 <bedheights>
921 <dc:call-macro name="bed-heights-single"/>
922 <dc:call-macro name="bed-heights-epoch"/>
923 </bedheights>
924 </dc:macro>
925 </dc:when>
926 <dc:when test="$out = 'minfo-heights-epoch'">
927 <bedheights>
928 <dc:call-macro name="bed-heights-epoch"/>
929 </bedheights>
930 </dc:when>
931 </dc:choose>
932 </dc:iterate>
933 </dc:otherwise>
934 </dc:choose>
935
936
937 <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'floodmap-hws')">
938 <dc:macro name="flood-map-recommended">
939 <dc:comment>
940 FIXME: Following two macros look identical to me.
941 </dc:comment>
942 <kilometrage>
943 <riveraxis factory="riveraxis" out="{$OUT}" ids="{$river_id}"/>
944 </kilometrage>
945 <rastermap>
946 <background factory="wmsbackground" out="{$OUT}" ids="{$river_id}"/>
947 </rastermap>
948 </dc:macro>
949
950 <dc:macro name="flood-map-dem">
951 <dems>
952 <dc:context>
953 <dc:statement>
954 SELECT d.id AS dem_id,
955 r.a AS dem_lower,
956 r.b AS dem_upper,
957 d.name AS name,
958 t.start_time AS start_time,
959 t.stop_time AS stop_time,
960 'Projektion: ' || d.projection || '$' ||
961 'Rasterweite: ' || d.resolution || 'm$' ||
962 'Format: ' || d.format || '$' ||
963 'Zeitraum: '
964 AS info
965 FROM dem d
966 JOIN ranges r ON d.range_id = r.id
967 LEFT JOIN time_intervals t ON d.time_interval_id = t.id
968 WHERE d.river_id = ${river_id}
969 </dc:statement>
970 <dc:for-each>
971 <dem factory="demfactory" out="{$OUT}"
972 ids="{$dem_id}"
973 name="{$name}"
974 info="{dc:replace($info, '$', '&lt;BR&gt;')}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
975 </dc:for-each>
976 </dc:context>
977 </dems>
978 </dc:macro>
979
980 <dc:macro name="filter_hws_ddg">
981 <dc:macro name="durchlass_damm_graben">
982 <dc:macro name="ddg_factory">
983 <dc:for-each>
984 <hws factory="hwsfactory" out="{$OUT}" name="{$hws_name}"/>
985 </dc:for-each>
986 </dc:macro>
987
988 <dc:filter expr="$hws_kind=1">
989 <dc:if test="dc:has-result()">
990 <Durchlass><dc:call-macro name="ddg_factory"/></Durchlass>
991 </dc:if>
992 </dc:filter>
993
994 <dc:filter expr="$hws_kind=2">
995 <dc:if test="dc:has-result()">
996 <Damm><dc:call-macro name="ddg_factory"/></Damm>
997 </dc:if>
998 </dc:filter>
999
1000 <dc:filter expr="$hws_kind=3">
1001 <dc:if test="dc:has-result()">
1002 <Graben><dc:call-macro name="ddg_factory"/></Graben>
1003 </dc:if>
1004 </dc:filter>
1005 </dc:macro>
1006
1007 <dc:filter expr="$hws_official=1">
1008 <dc:if test="dc:has-result()">
1009 <official>
1010 <dc:call-macro name="durchlass_damm_graben"/>
1011 </official>
1012 </dc:if>
1013 </dc:filter>
1014
1015 <dc:filter expr="$hws_official=0">
1016 <dc:if test="dc:has-result()">
1017 <inofficial>
1018 <dc:call-macro name="durchlass_damm_graben"/>
1019 </inofficial>
1020 </dc:if>
1021 </dc:filter>
1022 </dc:macro>
1023
1024 <dc:macro name="flood-map-hws-lines">
1025 <dc:context>
1026 <dc:statement>
1027 SELECT DISTINCT
1028 name AS hws_name,
1029 official AS hws_official,
1030 kind_id AS hws_kind
1031 FROM hws_lines
1032 WHERE river_id = ${river_id}
1033 </dc:statement> 1914 </dc:statement>
1034 <dc:if test="dc:has-result()"> 1915 <dc:if test="dc:has-result()">
1035 <lines> 1916 <current>
1036 <dc:call-macro name="filter_hws_ddg"/> 1917 <dc:context>
1037 </lines> 1918 <dc:statement>
1038 </dc:if> 1919 SELECT DISTINCT name AS name
1039 </dc:context> 1920 FROM floodmaps
1040 </dc:macro> 1921 WHERE river_id = ${river_id} AND kind = 111
1041 1922 </dc:statement>
1042 <dc:macro name="flood-map-hws-points"> 1923 <dc:if test="dc:has-result()">
1043 <dc:context> 1924 <bfg>
1044 <dc:statement> 1925 <dc:for-each>
1045 SELECT DISTINCT 1926 <floodmaps factory="wmsfloodmapsfactory"
1046 name AS hws_name, 1927 ids="{$river_id};{$name}"
1047 official AS hws_official, 1928 name="{$name}"/>
1048 kind_id AS hws_kind 1929 </dc:for-each>
1049 FROM hws_points 1930 </bfg>
1050 WHERE river_id = ${river_id} 1931 </dc:if>
1051 </dc:statement> 1932 </dc:context>
1052 <dc:if test="dc:has-result()"> 1933 <dc:context>
1053 <points> 1934 <dc:statement>
1054 <dc:call-macro name="filter_hws_ddg"/> 1935 SELECT DISTINCT name AS name
1055 </points> 1936 FROM floodmaps
1056 </dc:if> 1937 WHERE river_id = ${river_id} AND kind = 112
1057 </dc:context> 1938 </dc:statement>
1058 </dc:macro> 1939 <dc:if test="dc:has-result()">
1059 1940 <federal>
1060 <dc:macro name="flood-map-km"> 1941 <dc:for-each>
1061 <dc:context> 1942 <floodmaps factory="wmsfloodmapsfactory"
1062 <dc:statement> 1943 ids="{$river_id};{$name}"
1063 SELECT DISTINCT 1 FROM river_axes_km WHERE river_id = ${river_id} 1944 name="{$name}"/>
1064 </dc:statement> 1945 </dc:for-each>
1065 <dc:for-each> 1946 </federal>
1066 <kilometrage factory="wmskmfactory" out="{$OUT}" ids="{$river_id}"/> 1947 </dc:if>
1067 </dc:for-each> 1948 </dc:context>
1068 </dc:context> 1949 </current>
1069 </dc:macro>
1070
1071 <dc:macro name="flood-map-qps">
1072 <dc:context>
1073 <dc:comment>Grab only the actual first</dc:comment>
1074 <dc:statement>
1075 SELECT DISTINCT
1076 cs.kind_id AS kind_id,
1077 ck.name AS kind_name
1078 FROM cross_section_tracks cs
1079 JOIN cross_section_track_kinds ck on cs.kind_id = ck.id
1080 WHERE river_id = ${river_id}
1081 AND kind_id=1
1082 </dc:statement>
1083 <dc:if test="dc:has-result()">
1084 <dc:for-each>
1085 <actual description="{$kind_name}"
1086 factory="wmsqpsfactory" out="{$OUT}"
1087 ids="{$river_id};{$kind_name};{$kind_id}"/>
1088 </dc:for-each>
1089 </dc:if>
1090 </dc:context>
1091 <dc:context>
1092 <dc:comment>Now the other tracks</dc:comment>
1093 <dc:statement>
1094 SELECT DISTINCT
1095 cs.kind_id AS kind_id,
1096 ck.name AS kind_name,
1097 cs.name AS layer_name
1098 FROM cross_section_tracks cs
1099 JOIN cross_section_track_kinds ck on cs.kind_id = ck.id
1100 WHERE river_id = ${river_id}
1101 AND kind_id=0
1102 </dc:statement>
1103 <dc:if test="dc:has-result()">
1104 <other>
1105 <dc:for-each>
1106 <misc-qps description="{$layer_name}"
1107 factory="wmsqpsfactory" out="{$OUT}"
1108 ids="{$river_id};{$layer_name};{$kind_id}"/>
1109 </dc:for-each>
1110 </other>
1111 </dc:if>
1112 </dc:context>
1113 </dc:macro>
1114
1115 <dc:macro name="flood-map-riveraxis">
1116 <dc:context>
1117 <dc:statement>
1118 SELECT DISTINCT
1119 ax.kind_id AS kind_id,
1120 ak.name AS kind_name
1121 FROM river_axes ax
1122 JOIN axis_kinds ak on ax.kind_id = ak.id
1123 WHERE river_id = ${river_id}
1124 AND kind_id=1
1125 </dc:statement>
1126 <dc:if test="dc:has-result()">
1127 <dc:for-each>
1128 <actual description="{$kind_name}"
1129 ids="{$river_id};{$kind_name};{$kind_id}"
1130 factory="riveraxis" out="{$OUT}"/>
1131 </dc:for-each>
1132 </dc:if> 1950 </dc:if>
1133 </dc:context> 1951 </dc:context>
1134 <dc:context> 1952 <dc:context>
1135 <dc:statement> 1953 <dc:statement>
1136 SELECT DISTINCT 1954 SELECT DISTINCT 1 from floodmaps where river_id = ${river_id}
1137 ak.name AS kind_name, 1955 AND (kind = 122 OR kind = 121)
1138 ax.kind_id AS kind_id,
1139 ax.name AS layer_name
1140 FROM river_axes ax
1141 JOIN axis_kinds ak on ax.kind_id = ak.id
1142 WHERE river_id = ${river_id}
1143 AND kind_id &lt;&gt; 1
1144 </dc:statement> 1956 </dc:statement>
1145 <dc:if test="dc:has-result()"> 1957 <dc:if test="dc:has-result()">
1146 <other> 1958 <potential>
1147 <dc:for-each>
1148 <misc-axis description="{$layer_name}"
1149 ids="{$river_id};{$layer_name};{$kind_id}"
1150 factory="riveraxis" out="{$OUT}"/>
1151 </dc:for-each>
1152 </other>
1153 </dc:if>
1154 </dc:context>
1155 </dc:macro>
1156
1157 <dc:macro name="flood-map-hydr-boundaries-state">
1158 <dc:context>
1159 <dc:statement>
1160 SELECT DISTINCT
1161 name
1162 FROM hydr_boundaries
1163 WHERE river_id = ${river_id}
1164 AND kind = 2
1165 </dc:statement>
1166 <dc:for-each>
1167 <line factory="wmshydrboundariesfactory" out="{$OUT}"
1168 ids="{$river_id};{$name};2"
1169 name="{$name}"/>
1170 </dc:for-each>
1171 </dc:context>
1172 <dc:context>
1173 <dc:statement>
1174 SELECT DISTINCT
1175 name
1176 FROM hydr_boundaries_poly
1177 WHERE river_id = ${river_id}
1178 AND kind = 2
1179 </dc:statement>
1180 <dc:for-each>
1181 <line factory="wmshydrboundariespolyfactory" out="{$OUT}"
1182 ids="{$river_id};{$name};2"
1183 name="{$name}"/>
1184 </dc:for-each>
1185 </dc:context>
1186 </dc:macro>
1187
1188 <dc:macro name="flood-map-hydr-boundaries-lines">
1189 <dc:context>
1190 <dc:statement>
1191 SELECT DISTINCT
1192 name
1193 FROM hydr_boundaries
1194 WHERE river_id = ${river_id}
1195 AND kind = 1
1196 </dc:statement>
1197 <dc:comment> What about all other line kinds?</dc:comment>
1198 <dc:if test="dc:has-result()">
1199 <lines>
1200 <dc:for-each>
1201 <line factory="wmshydrboundariesfactory" out="{$OUT}"
1202 ids="{$river_id};{$name};1"
1203 name="{$name}"/>
1204 </dc:for-each>
1205 </lines>
1206 </dc:if>
1207 </dc:context>
1208 </dc:macro>
1209
1210 <dc:macro name="flood-map-hydr-boundaries-poly">
1211 <dc:context>
1212 <dc:statement>
1213 SELECT DISTINCT
1214 b.sectie AS sectie_id,
1215 sk.name AS sectie
1216 FROM hydr_boundaries_poly b
1217 JOIN sectie_kinds sk ON b.sectie = sk.id
1218 WHERE b.river_id = ${river_id}
1219 AND b.kind = 1
1220 </dc:statement>
1221 <dc:if test="dc:has-result()">
1222 <sobek_areas>
1223 <dc:for-each>
1224 <boundary name="{$sectie}"
1225 factory="wmshydrboundariespolyfactory" out="{$OUT}"
1226 ids="{$river_id};{$sectie};1;{$sectie_id};-1"/>
1227 </dc:for-each>
1228 </sobek_areas>
1229 </dc:if>
1230 </dc:context>
1231 <dc:context>
1232 <dc:statement>
1233 SELECT DISTINCT
1234 b.sobek AS sobek_id,
1235 sk.name AS sobek
1236 FROM hydr_boundaries_poly b
1237 JOIN sobek_kinds sk ON b.sobek = sk.id
1238 WHERE b.river_id = ${river_id}
1239 AND b.kind = 1
1240 </dc:statement>
1241 <dc:if test="dc:has-result()">
1242 <sobek_flooded>
1243 <dc:for-each>
1244 <boundary name="{$sobek}"
1245 factory="wmshydrboundariespolyfactory" out="{$OUT}"
1246 ids="{$river_id};{$sobek};1;-1;{$sobek_id}"/>
1247 </dc:for-each>
1248 </sobek_flooded>
1249 </dc:if>
1250 </dc:context>
1251 <dc:context>
1252 <dc:statement>
1253 SELECT DISTINCT
1254 b.name AS name
1255 FROM hydr_boundaries_poly b
1256 WHERE b.river_id = ${river_id}
1257 AND b.kind = 1
1258 AND b.sobek IS NULL
1259 AND b.sectie is NULL
1260 </dc:statement>
1261 <dc:for-each>
1262 <boundary name="{$name}"
1263 factory="wmshydrboundariespolyfactory" out="{$OUT}"
1264 ids="{$river_id};{$name}"/>
1265 </dc:for-each>
1266 </dc:context>
1267 </dc:macro>
1268
1269 <dc:macro name="flood-map-hydr-boundaries">
1270 <bfg_model>
1271 <areas>
1272 <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
1273 </areas>
1274 <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
1275 </bfg_model>
1276 <federal>
1277 <dc:call-macro name="flood-map-hydr-boundaries-state"/>
1278 </federal>
1279 </dc:macro>
1280
1281 <dc:macro name="flood-map-floodplain">
1282 <floodplain>
1283 <dc:context>
1284 <dc:statement>
1285 SELECT DISTINCT
1286 fp.kind_id AS kind_id,
1287 flk.name AS kind_name
1288 FROM floodplain fp
1289 JOIN floodplain_kinds flk on fp.kind_id = flk.id
1290 WHERE river_id = ${river_id}
1291 AND kind_id=1
1292 </dc:statement>
1293 <dc:if test="dc:has-result()">
1294 <dc:for-each>
1295 <floody factory="wmsfloodplainfactory" out="{$OUT}"
1296 description="{$kind_name}"
1297 ids="{$river_id};{$kind_name};{$kind_id}"/>
1298 </dc:for-each>
1299 </dc:if>
1300 </dc:context>
1301 <dc:context>
1302 <dc:statement>
1303 SELECT DISTINCT
1304 flk.name AS kind_name,
1305 fp.kind_id AS kind_id,
1306 fp.name AS layer_name
1307 FROM floodplain fp
1308 JOIN floodplain_kinds flk on fp.kind_id = flk.id
1309 WHERE river_id = ${river_id}
1310 AND kind_id &lt;&gt; 1
1311 </dc:statement>
1312 <dc:if test="dc:has-result()">
1313 <other>
1314 <dc:for-each>
1315 <floody factory="wmsfloodplainfactory" out="{$OUT}"
1316 description="{$layer_name}"
1317 ids="{$river_id};{$layer_name};{$kind_id}"/>
1318 </dc:for-each>
1319 </other>
1320 </dc:if>
1321 </dc:context>
1322 </floodplain>
1323 </dc:macro>
1324
1325 <dc:macro name="hwslines_by_kind">
1326 <dc:comment>
1327 Call from a context where fed_name hws_kind hws_name and river_id is
1328 availble
1329 </dc:comment>
1330
1331 <dc:macro name="hwslines_by_kind_factory">
1332 <dc:for-each>
1333 <hws factory="wmshwslinesfactory" out="{$OUT}"
1334 ids="{$river_id};{$hws_name}"
1335 name="{$hws_name}"/>
1336 </dc:for-each>
1337 </dc:macro>
1338
1339 <dc:filter expr="$hws_kind=1">
1340 <dc:if test="dc:has-result()">
1341 <Durchlass>
1342 <dc:call-macro name="hwslines_by_kind_factory"/>
1343 </Durchlass>
1344 </dc:if>
1345 </dc:filter>
1346
1347 <dc:filter expr="$hws_kind=2">
1348 <dc:if test="dc:has-result()">
1349 <Damm>
1350 <dc:call-macro name="hwslines_by_kind_factory"/>
1351 </Damm>
1352 </dc:if>
1353 </dc:filter>
1354
1355 <dc:filter expr="$hws_kind=3">
1356 <dc:if test="dc:has-result()">
1357 <Graben>
1358 <dc:call-macro name="hwslines_by_kind_factory"/>
1359 </Graben>
1360 </dc:if>
1361 </dc:filter>
1362 </dc:macro>
1363
1364 <dc:macro name="hwslines">
1365 <hws_lines>
1366 <official>
1367 <dc:context>
1368 <dc:statement>
1369 SELECT DISTINCT
1370 fs.name AS fed_name,
1371 fs.id AS fed_id
1372 FROM hws_lines hws
1373 JOIN fed_states fs ON hws.fed_state_id = fs.id
1374 WHERE river_id = ${river_id}
1375 AND hws.official=1
1376 </dc:statement>
1377 <dc:for-each>
1378 <dc:context>
1379 <dc:statement>
1380 SELECT DISTINCT
1381 name AS hws_name,
1382 kind_id AS hws_kind
1383 FROM hws_lines
1384 WHERE river_id = ${river_id}
1385 AND official=1
1386 AND fed_state_id = ${fed_id} ORDER BY name
1387 </dc:statement>
1388 <fedstate description="{$fed_name}">
1389 <dc:call-macro name="hwslines_by_kind"/>
1390 </fedstate>
1391 </dc:context>
1392 </dc:for-each>
1393 </dc:context>
1394 <dc:context>
1395 <dc:statement>
1396 SELECT distinct
1397 name AS hws_name,
1398 kind_id AS hws_kind
1399 FROM hws_lines
1400 WHERE river_id = ${river_id}
1401 AND official=1
1402 AND fed_state_id IS NULL
1403 ORDER BY name
1404 </dc:statement>
1405 <hws_fed_unknown>
1406 <dc:call-macro name="hwslines_by_kind"/>
1407 </hws_fed_unknown>
1408 </dc:context>
1409 </official>
1410 <inofficial>
1411 <dc:context>
1412 <dc:statement>
1413 SELECT DISTINCT
1414 fs.name AS fed_name,
1415 fs.id AS fed_id
1416 FROM hws_lines hws
1417 JOIN fed_states fs ON hws.fed_state_id = fs.id
1418 WHERE river_id = ${river_id}
1419 AND hws.official=0
1420 </dc:statement>
1421 <dc:for-each>
1422 <dc:context>
1423 <dc:statement>
1424 SELECT DISTINCT
1425 name AS hws_name,
1426 kind_id AS hws_kind
1427 FROM hws_lines
1428 WHERE river_id = ${river_id}
1429 AND official=0
1430 AND fed_state_id = ${fed_id} ORDER BY name
1431 </dc:statement>
1432 <fedstate description="{$fed_name}">
1433 <dc:call-macro name="hwslines_by_kind"/>
1434 </fedstate>
1435 </dc:context>
1436 </dc:for-each>
1437 </dc:context>
1438 <dc:context>
1439 <dc:statement>
1440 SELECT distinct
1441 name AS hws_name,
1442 kind_id AS hws_kind
1443 FROM hws_lines
1444 WHERE river_id = ${river_id}
1445 AND official=0
1446 AND fed_state_id IS NULL ORDER BY name
1447 </dc:statement>
1448 <hws_fed_unknown>
1449 <dc:call-macro name="hwslines_by_kind"/>
1450 </hws_fed_unknown>
1451 </dc:context>
1452 </inofficial>
1453 </hws_lines>
1454 </dc:macro>
1455
1456 <dc:macro name="hwspoints_by_kind">
1457 <dc:comment>
1458 Call from a context where fed_name hws_kind hws_name and river_id is
1459 availble
1460 </dc:comment>
1461
1462 <dc:macro name="hwspoints_by_kind_factory">
1463 <dc:for-each>
1464 <hws factory="wmshwspointsfactory" out="{$OUT}"
1465 ids="{$river_id};{$hws_name}"
1466 name="{$hws_name}"/>
1467 </dc:for-each>
1468 </dc:macro>
1469
1470 <dc:filter expr="$hws_kind=1">
1471 <dc:if test="dc:has-result()">
1472 <Durchlass>
1473 <dc:call-macro name="hwspoints_by_kind_factory"/>
1474 </Durchlass>
1475 </dc:if>
1476 </dc:filter>
1477
1478 <dc:filter expr="$hws_kind=2">
1479 <dc:if test="dc:has-result()">
1480 <Damm>
1481 <dc:call-macro name="hwspoints_by_kind_factory"/>
1482 </Damm>
1483 </dc:if>
1484 </dc:filter>
1485
1486 <dc:filter expr="$hws_kind=3">
1487 <dc:if test="dc:has-result()">
1488 <Graben>
1489 <dc:call-macro name="hwspoints_by_kind_factory"/>
1490 </Graben>
1491 </dc:if>
1492 </dc:filter>
1493 </dc:macro>
1494
1495 <dc:macro name="hwspoints">
1496 <hws_points>
1497 <official>
1498 <dc:context>
1499 <dc:statement>
1500 SELECT DISTINCT
1501 fs.name AS fed_name,
1502 fs.id AS fed_id
1503 FROM hws_points hws
1504 JOIN fed_states fs ON hws.fed_state_id = fs.id
1505 WHERE river_id = ${river_id}
1506 AND hws.official=1
1507 </dc:statement>
1508 <dc:for-each>
1509 <dc:context>
1510 <dc:statement>
1511 SELECT DISTINCT
1512 name AS hws_name,
1513 kind_id AS hws_kind
1514 FROM hws_points
1515 WHERE river_id = ${river_id}
1516 AND official=1
1517 AND fed_state_id = ${fed_id} ORDER BY name
1518 </dc:statement>
1519 <fedstate description="{$fed_name}">
1520 <dc:call-macro name="hwspoints_by_kind"/>
1521 </fedstate>
1522 </dc:context>
1523 </dc:for-each>
1524 </dc:context>
1525 <dc:context>
1526 <dc:statement>
1527 SELECT distinct
1528 name AS hws_name,
1529 kind_id AS hws_kind
1530 FROM hws_points
1531 WHERE river_id = ${river_id}
1532 AND official=1
1533 AND fed_state_id IS NULL
1534 ORDER BY name
1535 </dc:statement>
1536 <hws_fed_unknown>
1537 <dc:call-macro name="hwspoints_by_kind"/>
1538 </hws_fed_unknown>
1539 </dc:context>
1540 </official>
1541 <inofficial>
1542 <dc:context>
1543 <dc:statement>
1544 SELECT DISTINCT
1545 fs.name AS fed_name,
1546 fs.id AS fed_id
1547 FROM hws_points hws
1548 JOIN fed_states fs ON hws.fed_state_id = fs.id
1549 WHERE river_id = ${river_id}
1550 AND hws.official=0
1551 </dc:statement>
1552 <dc:for-each>
1553 <dc:context>
1554 <dc:statement>
1555 SELECT DISTINCT
1556 name AS hws_name,
1557 kind_id AS hws_kind
1558 FROM hws_points
1559 WHERE river_id = ${river_id}
1560 AND official=0
1561 AND fed_state_id = ${fed_id} ORDER BY name
1562 </dc:statement>
1563 <fedstate description="{$fed_name}">
1564 <dc:call-macro name="hwspoints_by_kind"/>
1565 </fedstate>
1566 </dc:context>
1567 </dc:for-each>
1568 </dc:context>
1569 <dc:context>
1570 <dc:statement>
1571 SELECT distinct
1572 name AS hws_name,
1573 kind_id AS hws_kind
1574 FROM hws_points
1575 WHERE river_id = ${river_id}
1576 AND official=0
1577 AND fed_state_id IS NULL ORDER BY name
1578 </dc:statement>
1579 <hws_fed_unknown>
1580 <dc:call-macro name="hwspoints_by_kind"/>
1581 </hws_fed_unknown>
1582 </dc:context>
1583 </inofficial>
1584 </hws_points>
1585 </dc:macro>
1586
1587 <dc:macro name="flood-map-buildings">
1588 <dc:context>
1589 <dc:statement>
1590 SELECT DISTINCT
1591 b.kind_id AS building_kind_id,
1592 bk.name AS building_kind
1593 FROM buildings b
1594 JOIN building_kinds bk ON b.kind_id = bk.id
1595 WHERE b.river_id = ${river_id}
1596 AND b.kind_id &lt;&gt; 0
1597 </dc:statement>
1598 <dc:for-each>
1599 <buildings description="{$building_kind}"
1600 factory="wmsbuildingsfactory" out="{$OUT}"
1601 ids="{$river_id};{$building_kind};{$building_kind_id}"/>
1602 </dc:for-each>
1603 </dc:context>
1604 <dc:context>
1605 <dc:statement>
1606 SELECT DISTINCT
1607 b.name AS building_name,
1608 bk.name AS building_kind,
1609 b.kind_id AS building_kind_id
1610 FROM buildings b
1611 JOIN building_kinds bk ON b.kind_id = bk.id
1612 WHERE river_id = ${river_id}
1613 AND kind_id = 0
1614 </dc:statement>
1615 <dc:if test="dc:has-result()">
1616 <other>
1617 <dc:for-each>
1618 <buildings description="{$building_name}"
1619 factory="wmsbuildingsfactory" out="{$OUT}"
1620 ids="{$river_id};{$building_name}"/>
1621 </dc:for-each>
1622 </other>
1623 </dc:if>
1624 </dc:context>
1625 <dc:context>
1626 <dc:statement>
1627 SELECT DISTINCT
1628 j.kind_id AS jetty_kind_id,
1629 jk.name AS jetty_kind
1630 FROM jetties j
1631 JOIN jetty_kinds jk ON j.kind_id = jk.id
1632 WHERE river_id = ${river_id}
1633 </dc:statement>
1634 <dc:if test="dc:has-result()">
1635 <jetties>
1636 <dc:for-each>
1637 <jetty description="{$jetty_kind}"
1638 factory="wmsjettiesfactory" out="{$OUT}"
1639 ids="{$river_id};{$jetty_kind};{$jetty_kind_id}"/>
1640 </dc:for-each>
1641 </jetties>
1642 </dc:if>
1643 </dc:context>
1644 </dc:macro>
1645
1646 <dc:macro name="flood-map-fixpoints">
1647 <dc:context>
1648 <dc:statement>
1649 SELECT name AS name
1650 FROM fixpoints WHERE river_id = ${river_id} GROUP BY name
1651 </dc:statement>
1652 <dc:for-each>
1653 <fixpoints factory="wmsfixpointsfactory" out="{$OUT}"
1654 ids="{$river_id};{$name}"/>
1655 </dc:for-each>
1656 </dc:context>
1657 </dc:macro>
1658
1659 <dc:macro name="flood-map-gaugelocations">
1660 <gauge_points factory="externalwmsfactory" out="{$OUT}" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelpunkte;Pegelpunkte (WSV)"/>
1661 <gauge_names factory="externalwmsfactory" out="{$OUT}" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelnamen;Pegelnamen (WSV)"/>
1662 <gauge_level factory="externalwmsfactory" out="{$OUT}" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelwasserstand;Aktueller Wasserstand (WSV)"/>
1663 <gauge_tendency factory="externalwmsfactory" out="{$OUT}" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;TendenzWasserstand;Tendenz des Wasserstands (WSV)"/>
1664 </dc:macro>
1665
1666 <dc:macro name="flood-map-uesk">
1667 <dc:context>
1668 <dc:statement>
1669 SELECT DISTINCT 1 from floodmaps where river_id = ${river_id}
1670 </dc:statement>
1671 <dc:if test="dc:has-result()">
1672 <uesk>
1673 <calculations>
1674 <dc:context> 1959 <dc:context>
1675 <dc:statement> 1960 <dc:statement>
1676 SELECT DISTINCT 1 from floodmaps where river_id = ${river_id} 1961 SELECT DISTINCT name AS name
1677 AND (kind = 112 OR kind = 111) 1962 FROM floodmaps
1963 WHERE river_id = ${river_id} AND kind = 121
1678 </dc:statement> 1964 </dc:statement>
1679 <dc:if test="dc:has-result()"> 1965 <dc:if test="dc:has-result()">
1680 <current> 1966 <bfg>
1681 <dc:context> 1967 <dc:for-each>
1682 <dc:statement> 1968 <floodmaps factory="wmsfloodmapsfactory"
1683 SELECT DISTINCT name AS name 1969 ids="{$river_id};{$name}"
1684 FROM floodmaps 1970 name="{$name}"/>
1685 WHERE river_id = ${river_id} AND kind = 111 1971 </dc:for-each>
1686 </dc:statement> 1972 </bfg>
1687 <dc:if test="dc:has-result()">
1688 <bfg>
1689 <dc:for-each>
1690 <floodmaps factory="wmsfloodmapsfactory" out="{$OUT}"
1691 ids="{$river_id};{$name}"
1692 name="{$name}"/>
1693 </dc:for-each>
1694 </bfg>
1695 </dc:if>
1696 </dc:context>
1697 <dc:context>
1698 <dc:statement>
1699 SELECT DISTINCT name AS name
1700 FROM floodmaps
1701 WHERE river_id = ${river_id} AND kind = 112
1702 </dc:statement>
1703 <dc:if test="dc:has-result()">
1704 <federal>
1705 <dc:for-each>
1706 <floodmaps factory="wmsfloodmapsfactory" out="{$OUT}"
1707 ids="{$river_id};{$name}"
1708 name="{$name}"/>
1709 </dc:for-each>
1710 </federal>
1711 </dc:if>
1712 </dc:context>
1713 </current>
1714 </dc:if> 1973 </dc:if>
1715 </dc:context> 1974 </dc:context>
1716 <dc:context> 1975 <dc:context>
1717 <dc:statement> 1976 <dc:statement>
1718 SELECT DISTINCT 1 from floodmaps where river_id = ${river_id} 1977 SELECT DISTINCT
1719 AND (kind = 122 OR kind = 121) 1978 name AS name
1979 FROM floodmaps
1980 WHERE river_id = ${river_id} AND kind = 122
1720 </dc:statement> 1981 </dc:statement>
1721 <dc:if test="dc:has-result()"> 1982 <dc:if test="dc:has-result()">
1722 <potential> 1983 <federal>
1723 <dc:context> 1984 <dc:for-each>
1724 <dc:statement> 1985 <floodmaps factory="wmsfloodmapsfactory"
1725 SELECT DISTINCT name AS name 1986 ids="{$river_id};{$name}"
1726 FROM floodmaps 1987 name="{$name}"/>
1727 WHERE river_id = ${river_id} AND kind = 121 1988 </dc:for-each>
1728 </dc:statement> 1989 </federal>
1729 <dc:if test="dc:has-result()">
1730 <bfg>
1731 <dc:for-each>
1732 <floodmaps factory="wmsfloodmapsfactory" out="{$OUT}"
1733 ids="{$river_id};{$name}"
1734 name="{$name}"/>
1735 </dc:for-each>
1736 </bfg>
1737 </dc:if>
1738 </dc:context>
1739 <dc:context>
1740 <dc:statement>
1741 SELECT DISTINCT
1742 name AS name
1743 FROM floodmaps
1744 WHERE river_id = ${river_id} AND kind = 122
1745 </dc:statement>
1746 <dc:if test="dc:has-result()">
1747 <federal>
1748 <dc:for-each>
1749 <floodmaps factory="wmsfloodmapsfactory" out="{$OUT}"
1750 ids="{$river_id};{$name}"
1751 name="{$name}"/>
1752 </dc:for-each>
1753 </federal>
1754 </dc:if>
1755 </dc:context>
1756 </potential>
1757 </dc:if> 1990 </dc:if>
1758 </dc:context> 1991 </dc:context>
1759 </calculations> 1992 </potential>
1760 <dc:context>
1761 <dc:statement>
1762 SELECT DISTINCT
1763 source AS source
1764 FROM floodmaps
1765 WHERE river_id = ${river_id} AND kind = 200
1766 </dc:statement>
1767 <dc:if test="dc:has-result()">
1768 <measurements>
1769 <dc:for-each>
1770 <year name="{$source}">
1771 <dc:context>
1772 <dc:statement>
1773 SELECT DISTINCT
1774 name AS name
1775 FROM floodmaps
1776 WHERE river_id = ${river_id} AND kind = 200 AND source =
1777 ${source}
1778 </dc:statement>
1779 <dc:for-each>
1780 <floodmaps factory="wmsfloodmapsfactory" out="{$OUT}"
1781 ids="{$river_id};{$name}"
1782 name="{$name}"/>
1783 </dc:for-each>
1784 </dc:context>
1785 </year>
1786 </dc:for-each>
1787 </measurements>
1788 </dc:if>
1789 </dc:context>
1790 </uesk>
1791 </dc:if>
1792 </dc:context>
1793 </dc:macro>
1794
1795 <dc:macro name="flood-map-routing">
1796 <qps>
1797 <dc:call-macro name="flood-map-qps"/>
1798 </qps>
1799 <dc:call-macro name="flood-map-fixpoints"/>
1800 <dc:call-macro name="flood-map-km"/>
1801 <axis>
1802 <dc:call-macro name="flood-map-riveraxis"/>
1803 </axis>
1804 </dc:macro>
1805
1806 <dc:macro name="floodmarks">
1807 <dc:context>
1808 <dc:statement>
1809 SELECT DISTINCT
1810 coalesce(CAST (year AS VARCHAR(64)), 'Unbekanntes Jahr') as year
1811 FROM flood_marks
1812 WHERE river_id = ${river_id}
1813 </dc:statement>
1814 <dc:if test="dc:has-result()">
1815 <floodmarks>
1816 <dc:for-each>
1817 <floodmark name="{$year}"
1818 factory="wmsfloodmarkfactory" out="{$OUT}"
1819 ids="{$river_id};{$year};{$year}"/>
1820 </dc:for-each>
1821 </floodmarks>
1822 </dc:if> 1993 </dc:if>
1823 </dc:context> 1994 </dc:context>
1824 </dc:macro> 1995 </calculations>
1825 1996 <dc:context>
1826 <dc:macro name="flood-map-complete"> 1997 <dc:statement>
1827 <buildings> 1998 SELECT DISTINCT
1828 <dc:call-macro name="flood-map-buildings"/> 1999 source AS source
1829 </buildings> 2000 FROM floodmaps
1830 <catchments> 2001 WHERE river_id = ${river_id} AND kind = 200
1831 <catchment_wms factory="externalwmsfactory" out="{$OUT}" 2002 </dc:statement>
1832 ids="http://geoportal.bafg.de/wmsproxy/INSPIRE/DrainageBasin;HY.PHYSICALWATERS.CATCHMENTS;Einzugsgebiete (WMS)" /> 2003 <dc:if test="dc:has-result()">
1833 <gaugelocations> 2004 <measurements>
1834 <dc:call-macro name="flood-map-gaugelocations"/> 2005 <dc:for-each>
1835 </gaugelocations> 2006 <year name="{$source}">
1836 </catchments> 2007 <dc:context>
1837 <dc:call-macro name="floodmarks"/> 2008 <dc:statement>
1838 <hws> 2009 SELECT DISTINCT
1839 <dc:call-macro name="hwslines"/> 2010 name AS name
1840 <dc:call-macro name="hwspoints"/> 2011 FROM floodmaps
1841 </hws> 2012 WHERE river_id = ${river_id} AND kind = 200 AND source =
1842 <route_data> 2013 ${source}
1843 <dc:call-macro name="flood-map-routing"/> 2014 </dc:statement>
1844 </route_data> 2015 <dc:for-each>
1845 <hydrboundaries> 2016 <floodmaps factory="wmsfloodmapsfactory"
1846 <dc:call-macro name="flood-map-floodplain"/> 2017 ids="{$river_id};{$name}"
1847 <dc:call-macro name="flood-map-hydr-boundaries"/> 2018 name="{$name}"/>
1848 </hydrboundaries> 2019 </dc:for-each>
1849 <dc:call-macro name="flood-map-uesk"/> 2020 </dc:context>
1850 </dc:macro> 2021 </year>
1851 2022 </dc:for-each>
1852 </dc:if> 2023 </measurements>
1853 2024 </dc:if>
1854 <dc:macro name="bed-heights-single"> 2025 </dc:context>
1855 <single> 2026 </uesk>
1856 <dc:context> 2027 </dc:if>
1857 <dc:statement> 2028 </dc:context>
1858 SELECT id AS bedh_id, 2029 </dc:macro>
1859 year AS bedh_year, 2030
1860 description AS bedh_descr 2031 <dc:macro name="flood-map-floodplain">
1861 FROM bed_height_single WHERE river_id = ${river_id} 2032 <dc:context>
1862 </dc:statement> 2033 <dc:statement>
2034 SELECT DISTINCT
2035 fp.kind_id AS kind_id,
2036 flk.name AS kind_name
2037 FROM floodplain fp
2038 JOIN floodplain_kinds flk on fp.kind_id = flk.id
2039 WHERE river_id = ${river_id}
2040 AND kind_id=1
2041 </dc:statement>
2042 <dc:if test="dc:has-result()">
2043 <floodplain>
2044 <dc:filter expr="$kind_id=1">
1863 <dc:for-each> 2045 <dc:for-each>
1864 <height factory="bedheight" out="{$OUT}" 2046 <floody factory="wmsfloodplainfactory"
1865 ids="bedheight-single-{$bedh_id}-{$bedh_year}" 2047 description="{$kind_name}"
1866 description="{$bedh_descr}"/> 2048 ids="{$river_id};{$kind_name};{$kind_id}"/>
1867 </dc:for-each> 2049 </dc:for-each>
1868 </dc:context> 2050 </dc:filter>
1869 </single> 2051 <dc:filter expr="kind_id!=1">
1870 </dc:macro> 2052 <other>
1871 2053 <dc:for-each>
1872 <dc:macro name="bed-heights-epoch"> 2054 <floody factory="wmsfloodplainfactory"
1873 <epoch> 2055 description="{$layer_name}"
1874 <dc:context> 2056 ids="{$river_id};{$layer_name};{$kind_id}"/>
1875 <dc:statement> 2057 </dc:for-each>
1876 SELECT id AS bedh_id, 2058 </other>
1877 time_interval_id AS bedh_interval_id, 2059 </dc:filter>
1878 description AS bedh_descr 2060 </floodplain>
1879 FROM bed_height_epoch WHERE river_id = ${river_id} 2061 </dc:if>
1880 </dc:statement> 2062 </dc:context>
1881 <dc:for-each> 2063 </dc:macro>
1882 <height factory="bedheight" out="{$OUT}" 2064
1883 ids="bedheight-epoch-{$bedh_id}-{$bedh_interval_id}" 2065 <dc:macro name="hwspoints_by_kind">
1884 description="{$bedh_descr}"/> 2066 <dc:comment>
1885 </dc:for-each> 2067 Call from a context where fed_name hws_kind hws_name and river_id is
1886 </dc:context> 2068 availble
1887 </epoch> 2069 </dc:comment>
1888 </dc:macro> 2070
1889 2071 <dc:macro name="hwspoints_by_kind_factory">
1890 </dc:for-each> 2072 <dc:for-each>
1891 </dc:context> 2073 <hws factory="wmshwspointsfactory"
1892 </dc:macro> 2074 ids="{$river_id};{$hws_name}"
1893 2075 name="{$hws_name}"/>
1894 <dc:choose> 2076 </dc:for-each>
1895 <dc:comment> 2077 </dc:macro>
1896 User specific part 2078
1897 ------------------ 2079 <dc:filter expr="$hws_kind=1">
1898 </dc:comment> 2080 <dc:if test="dc:has-result()">
1899 <dc:when test="dc:contains($parameters, 'user-id') and 2081 <Durchlass>
1900 not(dc:contains($artifact-outs, 'floodmap-hws'))"> 2082 <dc:call-macro name="hwspoints_by_kind_factory"/>
1901 2083 </Durchlass>
1902 <old_calculations> 2084 </dc:if>
1903 2085 </dc:filter>
1904 <dc:comment><!-- <dc:macro name="load-user">--></dc:comment> 2086
1905 <dc:call-macro name="user-range"> 2087 <dc:filter expr="$hws_kind=2">
1906 <dc:context connection="user"> 2088 <dc:if test="dc:has-result()">
1907 <dc:comment> Get the user and collection-id. </dc:comment> 2089 <Damm>
2090 <dc:call-macro name="hwspoints_by_kind_factory"/>
2091 </Damm>
2092 </dc:if>
2093 </dc:filter>
2094
2095 <dc:filter expr="$hws_kind=3">
2096 <dc:if test="dc:has-result()">
2097 <Graben>
2098 <dc:call-macro name="hwspoints_by_kind_factory"/>
2099 </Graben>
2100 </dc:if>
2101 </dc:filter>
2102 </dc:macro>
2103
2104 <dc:macro name="hwspoints">
2105 <hws_points>
2106 <official>
2107 <dc:context>
1908 <dc:statement> 2108 <dc:statement>
1909 SELECT u.id AS user_id, c.id AS collection_id, c.name AS collection_name 2109 SELECT DISTINCT
1910 FROM collections c JOIN users u ON c.user_id = u.id 2110 fs.name AS fed_name,
1911 WHERE u.gid = CAST(${user-id} AS uuid) 2111 fs.id AS fed_id
1912 ORDER BY c.creation DESC 2112 FROM hws_points hws
2113 JOIN fed_states fs ON hws.fed_state_id = fs.id
2114 WHERE river_id = ${river_id}
2115 AND hws.official=1
1913 </dc:statement> 2116 </dc:statement>
1914 2117 <dc:for-each>
1915 <dc:macro name="range-filter">
1916 <dc:statement>
1917 SELECT m.id AS a_id,
1918 m.state AS a_state,
1919 m.gid AS a_gid,
1920 m.creation AS a_creation,
1921 COALESCE(ld_mode, '') AS ld_m,
1922 COALESCE(ld_locations, '') AS ld_l,
1923 COALESCE(ld_from, '') AS ld_f,
1924 COALESCE(ld_to, '') AS ld_t
1925 FROM master_artifacts_range m
1926 WHERE m.collection_id = ${collection_id} AND m.gid &lt;&gt; CAST(${artifact-id} AS uuid)
1927 AND EXISTS (
1928 SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river})
1929 </dc:statement>
1930 <dc:for-each>
1931 <dc:variable name="from" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)"/>
1932 <dc:variable name="to" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)"/>
1933 <dc:if test="($from &gt;= $fromkm and $from &lt;= $tokm) or ($to &lt;= $tokm and $to &gt;= $fromkm) or ($from &lt;= $fromkm and $to &gt;= $tokm)">
1934 <dc:macro-body/>
1935 </dc:if>
1936 </dc:for-each>
1937 </dc:macro>
1938
1939 <!-- OFFICIAL LINES -->
1940 <dc:macro name="officiallines_user">
1941 <dc:comment comment=".wst -------------------------------"/>
1942 <officiallines>
1943 <dc:for-each>
1944 <dc:context>
1945 <dc:statement>
1946 SELECT m.id AS a_id,
1947 m.state AS a_state,
1948 m.gid AS a_gid,
1949 m.creation AS a_creation,
1950 ardg.v AS gaugy,
1951 arv.v AS wqsingle
1952 FROM master_artifacts m,
1953 artifact_data ardg,
1954 artifact_data arv
1955 WHERE m.collection_id = ${collection_id}
1956 AND m.gid = CAST(${artifact-id} AS uuid)
1957 AND ardg.artifact_id = m.id
1958 AND ardg.k = 'ld_gaugename'
1959 AND arv.artifact_id = m.id
1960 AND arv.k = 'wq_single'
1961 AND EXISTS (
1962 SELECT id
1963 FROM artifact_data ad
1964 WHERE ad.artifact_id = m.id
1965 AND k = 'river'
1966 AND v = ${river})
1967 </dc:statement>
1968 <dc:for-each>
1969 <dc:context connection="system">
1970 <dc:statement>
1971 SELECT ol.wst_id AS wstid, ol.wst_column_pos AS wstcolpos, ol.name AS olname, ol.value AS oval
1972 FROM official_q_values ol
1973 WHERE ol.value = CAST(${wqsingle} AS NUMERIC(10,2)) AND ol.gauge_name = ${gaugy}
1974 </dc:statement>
1975 <dc:for-each>
1976 <dc:element name="${olname}">
1977 <dc:attribute name="name" value="${olname}"/>
1978 <dc:attribute name="ids" value="additionals-wstv-${wstcolpos}-${wstid}"/>
1979 <dc:attribute name="factory" value="staticwkms"/>
1980 <dc:attribute name="out" value="${out}"/>
1981 </dc:element>
1982 </dc:for-each>
1983 </dc:context>
1984 </dc:for-each>
1985 </dc:context>
1986 </dc:for-each>
1987 </officiallines>
1988 </dc:macro>
1989 <!-- END OFFICIAL LINES -->
1990
1991 <dc:comment>
1992 SHOW W-DIFFERENCES
1993 </dc:comment>
1994
1995 <dc:macro name="differences">
1996 <differences>
1997 <dc:for-each>
1998 <dc:context>
1999 <dc:call-macro name="range-filter">
2000 <dc:context>
2001 <dc:statement>
2002 SELECT a.gid AS aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description AS facet_description
2003 FROM outs AS o, facets AS f, artifacts AS a
2004 WHERE f.name = 'w_differences' and f.out_id = o.id and o.artifact_id = ${a_id} and a.id = ${a_id}
2005 </dc:statement>
2006 <dc:for-each>
2007 <dc:element name="${facet_name}">
2008 <dc:attribute name="description" value="${facet_description}"/>
2009 <dc:attribute name="factory" value="winfo"/>
2010 <!-- <dc:attribute name="out" value="${out}"/>-->
2011 <dc:attribute name="artifact-id" value="${aid}"/>
2012 <dc:attribute name="ids" value="${aid}"/>
2013 <dc:attribute name="out" value="w_differences"/>
2014 </dc:element>
2015 </dc:for-each>
2016 </dc:context>
2017 </dc:call-macro>
2018 </dc:context>
2019 </dc:for-each>
2020 </differences>
2021 </dc:macro>
2022
2023 <dc:comment>
2024 SHOW REFERENCE CURVE
2025 </dc:comment>
2026
2027 <dc:macro name="reference-curves">
2028 <reference_curves>
2029 <dc:for-each>
2030 <dc:context>
2031 <dc:call-macro name="user-range">
2032 <dc:context>
2033 <dc:statement>
2034 SELECT a.gid AS aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description AS facet_description
2035 FROM outs AS o, facets AS f, artifacts AS a
2036 WHERE f.name = 'reference_curve' and f.out_id = o.id and o.artifact_id = ${a_id} and a.id = ${a_id}
2037 </dc:statement>
2038 <dc:for-each>
2039 <dc:element name="${facet_name}">
2040 <dc:attribute name="description" value="${facet_description}"/>
2041 <dc:attribute name="factory" value="winfo"/>
2042 <!-- <dc:attribute name="out" value="${out}"/>-->
2043 <dc:attribute name="artifact-id" value="${aid}"/>
2044 <dc:attribute name="ids" value="${aid}"/>
2045 <dc:attribute name="out" value="reference_curve"/>
2046 </dc:element>
2047 </dc:for-each>
2048 </dc:context>
2049 </dc:call-macro>
2050 </dc:context>
2051 </dc:for-each>
2052 </reference_curves>
2053 </dc:macro>
2054
2055 <dc:comment>
2056 SHOW COMPUTED DISCHARGE CURVES
2057 </dc:comment>
2058
2059 <dc:macro name="computed-discharge-curve">
2060 <computed_discharge_curves>
2061 <dc:for-each>
2062 <dc:context>
2063 <dc:call-macro name="range-filter">
2064 <dc:context>
2065 <dc:statement>
2066 SELECT a.gid AS aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description AS facet_description
2067 FROM outs AS o, facets AS f, artifacts AS a
2068 WHERE f.name = 'computed_discharge_curve.q' and f.out_id = o.id and o.artifact_id = ${a_id} and a.id = ${a_id}
2069 </dc:statement>
2070 <dc:for-each>
2071 <dc:element name="${facet_name}">
2072 <dc:attribute name="description" value="${facet_description}"/>
2073 <dc:attribute name="factory" value="winfo"/>
2074 <!-- <dc:attribute name="out" value="${out}"/>-->
2075 <dc:attribute name="artifact-id" value="${aid}"/>
2076 <dc:attribute name="ids" value="${aid}"/>
2077 <dc:attribute name="out" value="computed_discharge_curve"/>
2078 </dc:element>
2079 </dc:for-each>
2080 </dc:context>
2081 </dc:call-macro>
2082 </dc:context>
2083 </dc:for-each>
2084 </computed_discharge_curves>
2085 </dc:macro>
2086
2087 <dc:comment>
2088 CROSS SECTION
2089 </dc:comment>
2090
2091 <dc:macro name="waterlevels">
2092 <waterlevels>
2093 <dc:for-each>
2094 <dc:context>
2095 <dc:call-macro name="range-filter">
2096 <dc:context>
2097 <dc:statement>
2098 SELECT id AS out_id
2099 FROM outs
2100 WHERE artifact_id = ${a_id} AND name = 'cross_section'
2101 </dc:statement>
2102 <dc:for-each>
2103 <dc:context>
2104 <dc:statement>
2105 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2106 FROM facets
2107 WHERE out_id = ${out_id}
2108 ORDER BY num ASC, name DESC
2109 </dc:statement>
2110 <longitudinal_section_columns description="{$river} {$a_creation}">
2111 <dc:for-each>
2112 <dc:element name="${facet_name}">
2113 <dc:attribute name="description" value="${facet_description}"/>
2114 <dc:attribute name="ids" value="${facet_num}"/>
2115 <dc:attribute name="factory" value="winfo"/>
2116 <!-- <dc:attribute name="out" value="${out}"/>-->
2117 <dc:attribute name="artifact-id" value="${a_gid}"/>
2118 <dc:attribute name="out" value="cross_section"/>
2119 </dc:element>
2120 </dc:for-each>
2121 </longitudinal_section_columns>
2122 </dc:context>
2123 </dc:for-each>
2124 </dc:context>
2125 </dc:call-macro>
2126 </dc:context>
2127 </dc:for-each>
2128 </waterlevels>
2129 </dc:macro>
2130
2131 <dc:macro name="longitudinal">
2132 <waterlevels>
2133 <dc:for-each>
2134 <dc:context>
2135 <dc:call-macro name="range-filter">
2136 <dc:context>
2137 <dc:statement>
2138 SELECT id AS out_id
2139 FROM outs
2140 WHERE artifact_id = ${a_id} AND name = 'longitudinal_section'
2141 </dc:statement>
2142 <dc:for-each>
2143 <dc:context>
2144 <dc:statement>
2145 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2146 FROM facets
2147 WHERE out_id = ${out_id}
2148 ORDER BY num ASC, name DESC
2149 </dc:statement>
2150 <longitudinal_section_columns description="{$river} {$a_creation}">
2151 <dc:for-each>
2152 <dc:element name="${facet_name}">
2153 <dc:attribute name="description" value="${facet_description}"/>
2154 <dc:attribute name="ids" value="${facet_num}"/>
2155 <dc:attribute name="factory" value="winfo"/>
2156 <!-- <dc:attribute name="out" value="${out}"/>-->
2157 <dc:attribute name="artifact-id" value="${a_gid}"/>
2158 <dc:attribute name="out" value="longitudinal_section"/>
2159 </dc:element>
2160 </dc:for-each>
2161 </longitudinal_section_columns>
2162 </dc:context>
2163 </dc:for-each>
2164 </dc:context>
2165 </dc:call-macro>
2166 </dc:context>
2167 </dc:for-each>
2168 </waterlevels>
2169 </dc:macro>
2170
2171 <dc:macro name="longitudinal-section">
2172 <waterlevels>
2173 <dc:for-each>
2174 <dc:context>
2175 <dc:call-macro name="range-filter">
2176 <dc:context>
2177 <dc:statement>
2178 SELECT id AS out_id
2179 FROM outs
2180 WHERE artifact_id = ${a_id} AND name = 'fix_longitudinal_section_curve'
2181 </dc:statement>
2182 <dc:for-each>
2183 <dc:context>
2184 <dc:comment><!-- average und deviation ls_0 . ls_1 ...--></dc:comment>
2185 <dc:statement>
2186 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2187 FROM facets
2188 WHERE out_id = ${out_id} AND (
2189 name LIKE 'fix_deviation_ls%' OR
2190 name LIKE 'fix_sector_average_ls%' OR
2191 name LIKE 'fix_analysis_events_ls%' OR
2192 name LIKE 'fix_reference_events_ls%' )
2193 ORDER BY num ASC, name DESC
2194 </dc:statement>
2195 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2196 <dc:for-each>
2197 <dc:element name="${facet_name}">
2198 <dc:attribute name="description" value="${facet_description}"/>
2199 <dc:attribute name="ids" value="${facet_num}"/>
2200 <dc:attribute name="factory" value="fixanalysis"/>
2201 <!-- <dc:attribute name="out" value="${out}"/>-->
2202 <dc:attribute name="artifact-id" value="${a_gid}"/>
2203 <dc:attribute name="out" value="fix_longitudinal_section_curve"/>
2204 </dc:element>
2205 </dc:for-each>
2206 </waterlevels>
2207 </dc:context>
2208 </dc:for-each>
2209 </dc:context>
2210 </dc:call-macro>
2211 </dc:context>
2212 </dc:for-each>
2213 </waterlevels>
2214 </dc:macro>
2215
2216 <dc:macro name="delta-wt">
2217 <waterlevels>
2218 <dc:for-each>
2219 <dc:context>
2220 <dc:call-macro name="range-filter">
2221 <dc:context>
2222 <dc:statement>
2223 SELECT id AS out_id
2224 FROM outs
2225 WHERE artifact_id = ${a_id} AND name = 'fix_deltawt_curve'
2226 </dc:statement>
2227 <dc:for-each>
2228 <dc:context>
2229 <dc:statement>
2230 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2231 FROM facets
2232 WHERE out_id = ${out_id} and (
2233 name LIKE 'fix_sector_average_dwt%' OR
2234 name LIKE 'fix_deviation_dwt%' OR
2235 name = 'fix_analysis_events_dwt' OR
2236 name = 'fix_reference_events_dwt' OR
2237 name = 'fix_analysis_periods_dwt' )
2238 ORDER BY num ASC, name DESC
2239 </dc:statement>
2240 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2241 <dc:for-each>
2242 <dc:element name="${facet_name}">
2243 <dc:attribute name="description" value="${facet_description}"/>
2244 <dc:attribute name="ids" value="${facet_num}"/>
2245 <dc:attribute name="factory" value="fixanalysis"/>
2246 <!-- <dc:attribute name="out" value="${out}"/>-->
2247 <dc:attribute name="artifact-id" value="${a_gid}"/>
2248 <dc:attribute name="out" value="fix_deltawt_curve"/>
2249 </dc:element>
2250 </dc:for-each>
2251 </waterlevels>
2252 </dc:context>
2253 </dc:for-each>
2254 </dc:context>
2255 </dc:call-macro>
2256 </dc:context>
2257 </dc:for-each>
2258 </waterlevels>
2259 </dc:macro>
2260
2261 <dc:macro name="delta-wt-ls">
2262 <waterlevels>
2263 <dc:for-each>
2264 <dc:context>
2265 <dc:call-macro name="range-filter">
2266 <dc:context>
2267 <dc:statement>
2268 SELECT id AS out_id
2269 FROM outs
2270 WHERE artifact_id = ${a_id} AND name = 'fix_deltawt_curve'
2271 </dc:statement>
2272 <dc:for-each>
2273 <dc:context>
2274 <dc:statement>
2275 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2276 FROM facets
2277 WHERE out_id = ${out_id} and (
2278 name LIKE 'fix_sector_average_dwt%' OR
2279 name LIKE 'fix_deviation_dwt%')
2280 ORDER BY num ASC, name DESC
2281 </dc:statement>
2282 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2283 <dc:for-each>
2284 <dc:element name="${facet_name}">
2285 <dc:attribute name="description" value="${facet_description}"/>
2286 <dc:attribute name="ids" value="${facet_num}"/>
2287 <dc:attribute name="factory" value="fixanalysis"/>
2288 <!-- <dc:attribute name="out" value="${out}"/>-->
2289 <dc:attribute name="artifact-id" value="${a_gid}"/>
2290 <dc:attribute name="out" value="fix_deltawt_curve"/>
2291 </dc:element>
2292 </dc:for-each>
2293 </waterlevels>
2294 </dc:context>
2295 </dc:for-each>
2296 </dc:context>
2297 </dc:call-macro>
2298 </dc:context>
2299 </dc:for-each>
2300 </waterlevels>
2301 </dc:macro>
2302
2303 <dc:macro name="fix-derivate-curve">
2304 <waterlevels>
2305 <dc:for-each>
2306 <dc:context>
2307 <dc:call-macro name="range-filter">
2308 <dc:context>
2309 <dc:statement>
2310 SELECT id AS out_id
2311 FROM outs
2312 WHERE artifact_id = ${a_id} AND name = 'fix_derivate_curve'
2313 </dc:statement>
2314 <dc:for-each>
2315 <dc:context>
2316 <dc:statement>
2317 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2318 FROM facets
2319 WHERE out_id = ${out_id} and name = 'fix_derivate_curve'
2320 ORDER BY num ASC, name DESC
2321 </dc:statement>
2322 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2323 <dc:for-each>
2324 <dc:element name="${facet_name}">
2325 <dc:attribute name="description" value="${facet_description}"/>
2326 <dc:attribute name="ids" value="${facet_num}"/>
2327 <dc:attribute name="factory" value="fixanalysis"/>
2328 <!-- <dc:attribute name="out" value="${out}"/>-->
2329 <dc:attribute name="artifact-id" value="${a_gid}"/>
2330 <dc:attribute name="out" value="fix_derivate_curve"/>
2331 </dc:element>
2332 </dc:for-each>
2333 </waterlevels>
2334 </dc:context>
2335 </dc:for-each>
2336 </dc:context>
2337 </dc:call-macro>
2338 </dc:context>
2339 </dc:for-each>
2340 </waterlevels>
2341 </dc:macro>
2342
2343 <dc:macro name="fix-wq-curve">
2344 <waterlevels>
2345 <dc:for-each>
2346 <dc:context>
2347 <dc:call-macro name="range-filter">
2348 <dc:context>
2349 <dc:statement>
2350 SELECT id AS out_id
2351 FROM outs
2352 WHERE artifact_id = ${a_id} AND name = 'fix_wq_curve'
2353 </dc:statement>
2354 <dc:for-each>
2355 <dc:context>
2356 <dc:statement>
2357 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2358 FROM facets
2359 WHERE out_id = ${out_id} and (
2360 name LIKE 'fix_sector_average_wq%' OR
2361 name = 'fix_wq_curve' OR
2362 name LIKE 'fix_analysis_events_wq%' OR
2363 name LIKE 'fix_reference_events_wq%' )
2364 ORDER BY num ASC, name DESC
2365 </dc:statement>
2366 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2367 <dc:for-each>
2368 <dc:element name="${facet_name}">
2369 <dc:attribute name="description" value="${facet_description}"/>
2370 <dc:attribute name="ids" value="${facet_num}"/>
2371 <dc:attribute name="factory" value="fixanalysis"/>
2372 <!-- <dc:attribute name="out" value="${out}"/>-->
2373 <dc:attribute name="artifact-id" value="${a_gid}"/>
2374 <dc:attribute name="out" value="fix_wq_curve"/>
2375 </dc:element>
2376 </dc:for-each>
2377 </waterlevels>
2378 </dc:context>
2379 </dc:for-each>
2380 </dc:context>
2381 </dc:call-macro>
2382 </dc:context>
2383 </dc:for-each>
2384 </waterlevels>
2385 </dc:macro>
2386
2387 <dc:macro name="duration-curve">
2388 <computed_discharge_curves>
2389 <dc:for-each>
2390 <dc:context>
2391 <dc:call-macro name="range-filter">
2392 <dc:context>
2393 <dc:statement>
2394 SELECT a.gid AS aid,
2395 f.id AS fid,
2396 f.name AS facet_name,
2397 f.num AS facet_num,
2398 f.description AS facet_description
2399 FROM outs AS o, facets AS f, artifacts AS a
2400 WHERE
2401 (f.name = 'duration_curve.q' OR f.name = 'duration_curve.w') AND
2402 f.out_id = o.id AND
2403 o.artifact_id = ${a_id} AND
2404 a.id = ${a_id}
2405 </dc:statement>
2406 <dc:for-each>
2407 <dc:element name="${facet_name}">
2408 <dc:attribute name="description" value="${facet_description}"/>
2409 <dc:attribute name="factory" value="winfo"/>
2410 <!-- <dc:attribute name="out" value="${out}"/>-->
2411 <dc:attribute name="artifact-id" value="${aid}"/>
2412 <dc:attribute name="ids" value="${aid}"/>
2413 <dc:attribute name="out" value="duration_curve"/>
2414 </dc:element>
2415 </dc:for-each>
2416 </dc:context>
2417 </dc:call-macro>
2418 </dc:context>
2419 </dc:for-each>
2420 </computed_discharge_curves>
2421 </dc:macro>
2422
2423 <dc:comment>
2424 WATERLEVELS - ONLY SHOW Ws
2425 </dc:comment>
2426
2427 <dc:comment><!-- TODO doesnt work nicely for fix/wq-diags. --></dc:comment>
2428
2429 <dc:macro name="waterlevels-fix">
2430 <waterlevels>
2431 <dc:for-each>
2432 <dc:context>
2433 <dc:call-macro name="range-filter">
2434 <dc:context>
2435 <dc:statement>
2436 SELECT id AS out_id
2437 FROM outs
2438 WHERE artifact_id = ${a_id} AND name = 'longitudinal_section'
2439 </dc:statement>
2440 <dc:for-each>
2441 <dc:context>
2442 <dc:statement>
2443 SELECT name AS facet_name, num AS facet_num, description AS facet_description
2444 FROM facets
2445 WHERE out_id = ${out_id} and name = 'longitudinal_section.w'
2446 ORDER BY num ASC, name DESC
2447 </dc:statement>
2448 <waterlevels description="{$river} {$a_creation} {$collection_name}">
2449 <dc:for-each>
2450 <dc:element name="${facet_name}">
2451 <dc:attribute name="description" value="${facet_description}"/>
2452 <dc:attribute name="ids" value="${facet_num}"/>
2453 <dc:attribute name="factory" value="winfo"/>
2454 <!-- <dc:attribute name="out" value="${out}"/>-->
2455 <dc:attribute name="artifact-id" value="${a_gid}"/>
2456 <dc:attribute name="out" value="longitudinal_section"/>
2457 </dc:element>
2458 </dc:for-each>
2459 </waterlevels>
2460 </dc:context>
2461 </dc:for-each>
2462 </dc:context>
2463 </dc:call-macro>
2464 </dc:context>
2465 </dc:for-each>
2466 </waterlevels>
2467 </dc:macro>
2468
2469 <dc:comment>
2470 SHOW FLOODMAPS
2471 </dc:comment>
2472
2473 <dc:macro name="flood-map">
2474 <floodmap>
2475 <dc:for-each>
2476 <dc:context>
2477 <dc:call-macro name="range-filter">
2478 <dc:context>
2479 <dc:statement>
2480 SELECT a.gid AS aid,
2481 f.id AS fid,
2482 f.name AS facet_name,
2483 f.num AS facet_num,
2484 f.description AS facet_description
2485 FROM outs AS o, facets AS f, artifacts AS a
2486 WHERE f.name = 'floodmap.wsplgen' AND
2487 f.out_id = o.id AND
2488 o.artifact_id = ${a_id} AND
2489 a.id = ${a_id}
2490 </dc:statement>
2491 <dc:for-each>
2492 <dc:element name="${facet_name}">
2493 <dc:attribute name="description" value="${facet_description}"/>
2494 <dc:attribute name="factory" value="winfo"/>
2495 <!-- <dc:attribute name="out" value="${out}"/>-->
2496 <dc:attribute name="artifact-id" value="${aid}"/>
2497 <dc:attribute name="ids" value="${aid}"/>
2498 <dc:attribute name="out" value="floodmap"/>
2499 </dc:element>
2500 </dc:for-each>
2501 </dc:context>
2502 </dc:call-macro>
2503 </dc:context>
2504 </dc:for-each>
2505 </floodmap>
2506 </dc:macro>
2507
2508 <dc:comment>
2509 MINFO bedheight middle
2510 </dc:comment>
2511
2512 <dc:macro name="floodmap-hws-user">
2513 <dc:context> 2118 <dc:context>
2514 <dc:statement> 2119 <dc:statement>
2515 SELECT id AS out_id 2120 SELECT DISTINCT
2516 FROM outs 2121 name AS hws_name,
2517 WHERE artifact_id = ${a_id} AND name = 'floodmap' 2122 kind_id AS hws_kind
2123 FROM hws_points
2124 WHERE river_id = ${river_id}
2125 AND official=1
2126 AND fed_state_id = ${fed_id} ORDER BY name
2518 </dc:statement> 2127 </dc:statement>
2128 <fedstate description="{$fed_name}">
2129 <dc:call-macro name="hwspoints_by_kind"/>
2130 </fedstate>
2131 </dc:context>
2132 </dc:for-each>
2133 </dc:context>
2134 <dc:context>
2135 <dc:statement>
2136 SELECT distinct
2137 name AS hws_name,
2138 kind_id AS hws_kind
2139 FROM hws_points
2140 WHERE river_id = ${river_id}
2141 AND official=1
2142 AND fed_state_id IS NULL
2143 ORDER BY name
2144 </dc:statement>
2145 <hws_fed_unknown>
2146 <dc:call-macro name="hwspoints_by_kind"/>
2147 </hws_fed_unknown>
2148 </dc:context>
2149 </official>
2150 <inofficial>
2151 <dc:context>
2152 <dc:statement>
2153 SELECT DISTINCT
2154 fs.name AS fed_name,
2155 fs.id AS fed_id
2156 FROM hws_points hws
2157 JOIN fed_states fs ON hws.fed_state_id = fs.id
2158 WHERE river_id = ${river_id}
2159 AND hws.official=0
2160 </dc:statement>
2161 <dc:for-each>
2162 <dc:context>
2163 <dc:statement>
2164 SELECT DISTINCT
2165 name AS hws_name,
2166 kind_id AS hws_kind
2167 FROM hws_points
2168 WHERE river_id = ${river_id}
2169 AND official=0
2170 AND fed_state_id = ${fed_id} ORDER BY name
2171 </dc:statement>
2172 <fedstate description="{$fed_name}">
2173 <dc:call-macro name="hwspoints_by_kind"/>
2174 </fedstate>
2175 </dc:context>
2176 </dc:for-each>
2177 </dc:context>
2178 <dc:context>
2179 <dc:statement>
2180 SELECT distinct
2181 name AS hws_name,
2182 kind_id AS hws_kind
2183 FROM hws_points
2184 WHERE river_id = ${river_id}
2185 AND official=0
2186 AND fed_state_id IS NULL ORDER BY name
2187 </dc:statement>
2188 <hws_fed_unknown>
2189 <dc:call-macro name="hwspoints_by_kind"/>
2190 </hws_fed_unknown>
2191 </dc:context>
2192 </inofficial>
2193 </hws_points>
2194 </dc:macro>
2195
2196 <dc:macro name="hwslines_by_kind">
2197 <dc:comment>
2198 Call from a context where fed_name hws_kind hws_name and river_id is
2199 availble
2200 </dc:comment>
2201
2202 <dc:macro name="hwslines_by_kind_factory">
2203 <dc:for-each>
2204 <hws factory="wmshwslinesfactory"
2205 ids="{$river_id};{$hws_name}"
2206 name="{$hws_name}"/>
2207 </dc:for-each>
2208 </dc:macro>
2209
2210 <dc:filter expr="$hws_kind=1">
2211 <dc:if test="dc:has-result()">
2212 <Durchlass>
2213 <dc:call-macro name="hwslines_by_kind_factory"/>
2214 </Durchlass>
2215 </dc:if>
2216 </dc:filter>
2217
2218 <dc:filter expr="$hws_kind=2">
2219 <dc:if test="dc:has-result()">
2220 <Damm>
2221 <dc:call-macro name="hwslines_by_kind_factory"/>
2222 </Damm>
2223 </dc:if>
2224 </dc:filter>
2225
2226 <dc:filter expr="$hws_kind=3">
2227 <dc:if test="dc:has-result()">
2228 <Graben>
2229 <dc:call-macro name="hwslines_by_kind_factory"/>
2230 </Graben>
2231 </dc:if>
2232 </dc:filter>
2233 </dc:macro>
2234
2235 <dc:macro name="hwslines">
2236 <hws_lines>
2237 <official>
2238 <dc:context>
2239 <dc:statement>
2240 SELECT DISTINCT
2241 fs.name AS fed_name,
2242 fs.id AS fed_id
2243 FROM hws_lines hws
2244 JOIN fed_states fs ON hws.fed_state_id = fs.id
2245 WHERE river_id = ${river_id}
2246 AND hws.official=1
2247 </dc:statement>
2248 <dc:for-each>
2249 <dc:context>
2250 <dc:statement>
2251 SELECT DISTINCT
2252 name AS hws_name,
2253 kind_id AS hws_kind
2254 FROM hws_lines
2255 WHERE river_id = ${river_id}
2256 AND official=1
2257 AND fed_state_id = ${fed_id} ORDER BY name
2258 </dc:statement>
2259 <fedstate description="{$fed_name}">
2260 <dc:call-macro name="hwslines_by_kind"/>
2261 </fedstate>
2262 </dc:context>
2263 </dc:for-each>
2264 </dc:context>
2265 <dc:context>
2266 <dc:statement>
2267 SELECT distinct
2268 name AS hws_name,
2269 kind_id AS hws_kind
2270 FROM hws_lines
2271 WHERE river_id = ${river_id}
2272 AND official=1
2273 AND fed_state_id IS NULL
2274 ORDER BY name
2275 </dc:statement>
2276 <hws_fed_unknown>
2277 <dc:call-macro name="hwslines_by_kind"/>
2278 </hws_fed_unknown>
2279 </dc:context>
2280 </official>
2281 <inofficial>
2282 <dc:context>
2283 <dc:statement>
2284 SELECT DISTINCT
2285 fs.name AS fed_name,
2286 fs.id AS fed_id
2287 FROM hws_lines hws
2288 JOIN fed_states fs ON hws.fed_state_id = fs.id
2289 WHERE river_id = ${river_id}
2290 AND hws.official=0
2291 </dc:statement>
2292 <dc:for-each>
2293 <dc:context>
2294 <dc:statement>
2295 SELECT DISTINCT
2296 name AS hws_name,
2297 kind_id AS hws_kind
2298 FROM hws_lines
2299 WHERE river_id = ${river_id}
2300 AND official=0
2301 AND fed_state_id = ${fed_id} ORDER BY name
2302 </dc:statement>
2303 <fedstate description="{$fed_name}">
2304 <dc:call-macro name="hwslines_by_kind"/>
2305 </fedstate>
2306 </dc:context>
2307 </dc:for-each>
2308 </dc:context>
2309 <dc:context>
2310 <dc:statement>
2311 SELECT distinct
2312 name AS hws_name,
2313 kind_id AS hws_kind
2314 FROM hws_lines
2315 WHERE river_id = ${river_id}
2316 AND official=0
2317 AND fed_state_id IS NULL ORDER BY name
2318 </dc:statement>
2319 <hws_fed_unknown>
2320 <dc:call-macro name="hwslines_by_kind"/>
2321 </hws_fed_unknown>
2322 </dc:context>
2323 </inofficial>
2324 </hws_lines>
2325 </dc:macro>
2326
2327 <dc:macro name="floodmarks">
2328 <dc:context>
2329 <dc:statement>
2330 SELECT DISTINCT
2331 COALESCE(CAST (year AS VARCHAR(64)), 'Unbekanntes Jahr') AS year
2332 FROM flood_marks
2333 WHERE river_id = ${river_id}
2334 </dc:statement>
2335 <dc:if test="dc:has-result()">
2336 <floodmarks>
2337 <dc:for-each>
2338 <floodmark name="{$year}"
2339 factory="wmsfloodmarkfactory"
2340 ids="{$river_id};{$year};{$year}"/>
2341 </dc:for-each>
2342 </floodmarks>
2343 </dc:if>
2344 </dc:context>
2345 </dc:macro>
2346
2347 <dc:macro name="catchments">
2348 <catchments>
2349 <catchment_wms factory="externalwmsfactory"
2350 ids="http://geoportal.bafg.de/wmsproxy/INSPIRE/DrainageBasin;HY.PHYSICALWATERS.CATCHMENTS;Einzugsgebiete (WMS)" />
2351 <dc:call-macro name="flood-map-gaugelocations"/>
2352 </catchments>
2353 </dc:macro>
2354
2355 <dc:macro name="flood-map-gaugelocations">
2356 <gaugelocations>
2357 <gauge_points factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelpunkte;Pegelpunkte (WSV)"/>
2358 <gauge_names factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelnamen;Pegelnamen (WSV)"/>
2359 <gauge_level factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelwasserstand;Aktueller Wasserstand (WSV)"/>
2360 <gauge_tendency factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;TendenzWasserstand;Tendenz des Wasserstands (WSV)"/>
2361 </gaugelocations>
2362 </dc:macro>
2363
2364 <dc:macro name="flood-map-riveraxis">
2365 <dc:context>
2366 <dc:statement>
2367 SELECT DISTINCT
2368 ak.name AS kind_name,
2369 ax.kind_id AS kind_id,
2370 ax.name AS layer_name
2371 FROM river_axes ax
2372 JOIN axis_kinds ak on ax.kind_id = ak.id
2373 WHERE river_id = ${river_id}
2374 </dc:statement>
2375 <dc:if test="dc:has-result()">
2376 <axis>
2377 <dc:filter expr="$kind_id=1">
2378 <dc:for-each>
2379 <actual description="{$kind_name}"
2380 ids="{$river_id};{$kind_name};{$kind_id}"
2381 factory="riveraxis"/>
2382 </dc:for-each>
2383 </dc:filter>
2384 <dc:filter expr="$kind_id!=1">
2385 <other>
2519 <dc:for-each> 2386 <dc:for-each>
2520 <dc:context> 2387 <misc-axis description="{$layer_name}"
2521 <dc:statement> 2388 ids="{$river_id};{$layer_name};{$kind_id}"
2522 SELECT name AS facet_name, 2389 factory="riveraxis"/>
2523 num AS facet_num,
2524 description AS facet_description
2525 FROM facets
2526 WHERE out_id = ${out_id} AND name = 'floodmap.usershape'
2527 ORDER BY num ASC, name DESC
2528 </dc:statement>
2529 <own-hws>
2530 <dc:for-each>
2531 <dc:element name="${facet_name}">
2532 <dc:attribute name="description" value="${facet_description}"/>
2533 <dc:attribute name="ids" value="${facet_num}"/>
2534 <dc:attribute name="factory" value="winfo"/>
2535 <!-- <dc:attribute name="out" value="${out}"/>-->
2536 <dc:attribute name="artifact-id" value="${a_gid}"/>
2537 <dc:attribute name="out" value="floodmap"/>
2538 </dc:element>
2539 </dc:for-each>
2540 </own-hws>
2541 </dc:context>
2542 </dc:for-each> 2390 </dc:for-each>
2543 </dc:context> 2391 </other>
2544 </dc:macro> 2392 </dc:filter>
2545 2393 </axis>
2546 <dc:macro name="bedquality-bed"> 2394 </dc:if>
2547 <bed_quality_bed> 2395 </dc:context>
2396 </dc:macro>
2397
2398 <dc:macro name="flood-map-km">
2399 <dc:context>
2400 <dc:statement>
2401 SELECT DISTINCT 1 FROM river_axes_km WHERE river_id = ${river_id}
2402 </dc:statement>
2403 <dc:for-each>
2404 <kilometrage factory="wmskmfactory" ids="{$river_id}"/>
2405 </dc:for-each>
2406 </dc:context>
2407 </dc:macro>
2408
2409 <dc:macro name="flood-map-fixpoints">
2410 <dc:context>
2411 <dc:statement>
2412 SELECT name AS name
2413 FROM fixpoints
2414 WHERE river_id = ${river_id}
2415 GROUP BY name
2416 </dc:statement>
2417 <dc:for-each>
2418 <fixpoints factory="wmsfixpointsfactory"
2419 ids="{$river_id};{$name}"/>
2420 </dc:for-each>
2421 </dc:context>
2422 </dc:macro>
2423
2424 <dc:macro name="flood-map-qps">
2425 <dc:context>
2426 <dc:statement>
2427 SELECT DISTINCT
2428 cs.kind_id AS kind_id,
2429 cs.name AS layer_name,
2430 ck.name AS kind_name
2431 FROM cross_section_tracks cs
2432 JOIN cross_section_track_kinds ck ON cs.kind_id = ck.id
2433 WHERE river_id = ${river_id}
2434 </dc:statement>
2435 <dc:if test="dc:has-result()">
2436 <qps>
2437 <dc:filter expr="$kind_id=1">
2438 <dc:for-each>
2439 <actual description="{$kind_name}"
2440 factory="wmsqpsfactory"
2441 ids="{$river_id};{$kind_name};{$kind_id}"/>
2442 </dc:for-each>
2443 </dc:filter>
2444 <dc:filter expr="kind_id=0">
2445 <other>
2548 <dc:for-each> 2446 <dc:for-each>
2549 <dc:context> 2447 <misc-qps description="{$layer_name}"
2550 <dc:call-macro name="range-filter"> 2448 factory="wmsqpsfactory"
2551 <dc:context> 2449 ids="{$river_id};{$layer_name};{$kind_id}"/>
2552 <dc:statement>
2553 SELECT id AS oid
2554 FROM outs AS o
2555 WHERE
2556 o.artifact_id = ${a_id} AND
2557 o.name='bed_longitudinal_section'
2558 </dc:statement>
2559 <dc:for-each>
2560 <quality-bed description="{$river} {$a_creation} {$collection_name}">
2561 <dc:context>
2562 <dc:statement>
2563 SELECT a.gid AS aid,
2564 f.id AS fid,
2565 f.name AS facet_name,
2566 f.num AS facet_num,
2567 f.description AS facet_description
2568 FROM outs AS o, facets AS f, artifacts AS a
2569 WHERE
2570 (f.name = 'bed_longitudinal_section.bed_diameter_toplayer'
2571 OR f.name = 'bed_longitudinal_section.bed_diameter_sublayer') AND
2572 f.out_id = o.id AND
2573 o.artifact_id = ${a_id} AND
2574 a.id = ${a_id}
2575 </dc:statement>
2576 <dc:for-each>
2577 <dc:element name="${facet_name}">
2578 <dc:attribute name="factory" value="minfo"/>
2579 <!-- <dc:attribute name="out" value="${out}"/>-->
2580 <dc:attribute name="description" value="${facet_description}"/>
2581 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2582 <dc:attribute name="artifact-id" value="${aid}"/>
2583 <dc:attribute name="out" value="bed_longitudinal_section"/>
2584 </dc:element>
2585 </dc:for-each>
2586 </dc:context>
2587 </quality-bed>
2588 </dc:for-each>
2589 </dc:context>
2590 </dc:call-macro>
2591 </dc:context>
2592 </dc:for-each> 2450 </dc:for-each>
2593 </bed_quality_bed> 2451 </other>
2594 </dc:macro> 2452 </dc:filter>
2595 2453 </qps>
2596 <dc:macro name="bedquality-load"> 2454 </dc:if>
2597 <bed_quality_load> 2455 </dc:context>
2456 </dc:macro>
2457
2458 <dc:macro name="flood-map-buildings">
2459 <buildings>
2460 <dc:context>
2461 <dc:statement>
2462 SELECT DISTINCT
2463 b.name AS building_name,
2464 bk.name AS building_kind,
2465 b.kind_id AS building_kind_id
2466 FROM buildings b
2467 JOIN building_kinds bk ON b.kind_id = bk.id
2468 WHERE river_id = ${river_id}
2469 </dc:statement>
2470 <dc:if test="dc:has-result()">
2471 <dc:filter expr="$building_kind_id!=0">
2472 <dc:for-each>
2473 <buildings description="{$building_kind}"
2474 factory="wmsbuildingsfactory"
2475 ids="{$river_id};{$building_kind};{$building_kind_id}"/>
2476 </dc:for-each>
2477 </dc:filter>
2478 <dc:filter expr="$building_kind_id=0">
2479 <other>
2598 <dc:for-each> 2480 <dc:for-each>
2599 <dc:context> 2481 <buildings description="{$building_name}"
2600 <dc:call-macro name="range-filter"> 2482 factory="wmsbuildingsfactory"
2601 <dc:context> 2483 ids="{$river_id};{$building_name}"/>
2602 <dc:statement>
2603 SELECT id AS oid
2604 FROM outs AS o
2605 WHERE
2606 o.artifact_id = ${a_id} AND
2607 o.name='bed_longitudinal_section'
2608 </dc:statement>
2609 <dc:for-each>
2610 <quality-load description="{$river} {$a_creation} {$collection_name}">
2611 <dc:context>
2612 <dc:statement>
2613 SELECT a.gid AS aid,
2614 f.id AS fid,
2615 f.name AS facet_name,
2616 f.num AS facet_num,
2617 f.description AS facet_description
2618 FROM outs AS o, facets AS f, artifacts AS a
2619 WHERE
2620 f.name = 'bed_longitudinal_section.bedload_diameter' AND
2621 f.out_id = o.id AND
2622 o.artifact_id = ${a_id} AND
2623 a.id = ${a_id}
2624 </dc:statement>
2625 <dc:for-each>
2626 <dc:element name="${facet_name}">
2627 <dc:attribute name="factory" value="minfo"/>
2628 <!-- <dc:attribute name="out" value="${out}"/>-->
2629 <dc:attribute name="description" value="${facet_description}"/>
2630 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2631 <dc:attribute name="artifact-id" value="${aid}"/>
2632 <dc:attribute name="out" value="bed_longitudinal_section"/>
2633 </dc:element>
2634 </dc:for-each>
2635 </dc:context>
2636 </quality-load>
2637 </dc:for-each>
2638 </dc:context>
2639 </dc:call-macro>
2640 </dc:context>
2641 </dc:for-each> 2484 </dc:for-each>
2642 </bed_quality_load> 2485 </other>
2643 </dc:macro> 2486 </dc:filter>
2644 2487 </dc:if>
2645 <dc:macro name="bedquality-density"> 2488 </dc:context>
2646 <bed_quality_density> 2489 <dc:context>
2647 <dc:for-each> 2490 <dc:statement>
2648 <dc:context> 2491 SELECT DISTINCT
2649 <dc:call-macro name="range-filter"> 2492 j.kind_id AS jetty_kind_id,
2650 <dc:context> 2493 jk.name AS jetty_kind
2651 <dc:statement> 2494 FROM jetties j
2652 SELECT id AS oid 2495 JOIN jetty_kinds jk ON j.kind_id = jk.id
2653 FROM outs AS o 2496 WHERE river_id = ${river_id}
2654 WHERE 2497 </dc:statement>
2655 o.artifact_id = ${a_id} AND 2498 <dc:if test="dc:has-result()">
2656 o.name='bed_longitudinal_section' 2499 <jetties>
2657 </dc:statement> 2500 <dc:for-each>
2658 <dc:for-each> 2501 <jetty description="{$jetty_kind}"
2659 <density description="{$river} {$a_creation} {$collection_name}"> 2502 factory="wmsjettiesfactory"
2660 <dc:context> 2503 ids="{$river_id};{$jetty_kind};{$jetty_kind_id}"/>
2661 <dc:statement> 2504 </dc:for-each>
2662 SELECT a.gid AS aid, 2505 </jetties>
2663 f.id AS fid, 2506 </dc:if>
2664 f.name AS facet_name, 2507 </dc:context>
2665 f.num AS facet_num, 2508 </buildings>
2666 f.description AS facet_description 2509 </dc:macro>
2667 FROM outs AS o, facets AS f, artifacts AS a 2510
2668 WHERE 2511 <!-- Common stuff -->
2669 (f.name = 'bed_longitudinal_section.sediment_density_toplayer' OR 2512
2670 f.name = 'bed_longitudinal_section.sediment_density_sublayer') AND 2513 <dc:macro name="km-filtered-wsts">
2671 f.out_id = o.id AND 2514 <dc:context connection="system">
2672 o.artifact_id = ${a_id} AND 2515 <dc:statement>
2673 a.id = ${a_id} 2516 SELECT w.kind AS kind,
2674 </dc:statement> 2517 w.id AS wst_id,
2675 <dc:for-each> 2518 wc.id AS wst_column_id,
2676 <dc:element name="${facet_name}"> 2519 wc.position AS wst_column_position,
2677 <dc:attribute name="factory" value="minfo"/> 2520 wc.description AS info,
2678 <!-- <dc:attribute name="out" value="${out}"/>--> 2521 w.description AS wst_description,
2679 <dc:attribute name="description" value="${facet_description}"/> 2522 wc.name AS wst_column_name,
2680 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/> 2523 wr.a AS deffrom,
2681 <dc:attribute name="artifact-id" value="${aid}"/> 2524 wr.b AS defto
2682 <dc:attribute name="out" value="bed_longitudinal_section"/> 2525 FROM wst_columns wc
2683 </dc:element> 2526 JOIN wsts w ON wc.wst_id = w.id
2684 </dc:for-each> 2527 JOIN wst_ranges wr ON wc.id = wr.wst_column_id
2685 </dc:context> 2528 WHERE w.river_id = ${river_id} AND
2686 </density> 2529 NOT((${tokm} &lt; wr.a) or (${fromkm} &gt; wr.b))
2687 </dc:for-each> 2530 </dc:statement>
2688 </dc:context> 2531 <dc:macro-body/>
2689 </dc:call-macro> 2532 </dc:context>
2690 </dc:context> 2533 </dc:macro>
2691 </dc:for-each> 2534
2692 </bed_quality_density> 2535 <dc:macro name="km-filtered-userdata">
2693 </dc:macro> 2536 <dc:context connection="user">
2694 2537 <dc:statement>
2695 <dc:macro name="bedquality-porosity"> 2538 SELECT c.name AS collection_name,
2696 <bed_quality_porosity> 2539 ma.id AS a_id,
2697 <dc:for-each> 2540 ma.state AS a_state,
2698 <dc:context> 2541 ma.gid AS a_gid,
2699 <dc:call-macro name="range-filter"> 2542 ma.creation AS a_creation,
2700 <dc:context> 2543 COALESCE(ld_mode, '') AS ld_m,
2701 <dc:statement> 2544 COALESCE(ld_locations, '') AS ld_l,
2702 SELECT id AS oid 2545 COALESCE(ld_from, '') AS ld_f,
2703 FROM outs AS o 2546 COALESCE(ld_to, '') AS ld_t
2704 WHERE 2547 FROM users u
2705 o.artifact_id = ${a_id} AND 2548 JOIN collections c ON c.user_id = u.id
2706 o.name='bed_longitudinal_section' 2549 JOIN master_artifacts_range ma ON ma.collection_id = c.id
2707 </dc:statement> 2550 WHERE c.id = ${collection_id}
2708 <dc:for-each> 2551 AND ma.gid &lt;&gt; CAST(${artifact-id} AS uuid)
2709 <porosity description="{$river} {$a_creation} {$collection_name}"> 2552 AND EXISTS (
2710 <dc:context> 2553 SELECT id
2711 <dc:statement> 2554 FROM artifact_data ad
2712 SELECT a.gid AS aid, 2555 WHERE ad.artifact_id = ma.id
2713 f.id AS fid, 2556 AND k = 'river'
2714 f.name AS facet_name, 2557 AND v = ${river})
2715 f.num AS facet_num, 2558 </dc:statement>
2716 f.description AS facet_description 2559 <dc:for-each>
2717 FROM outs AS o, facets AS f, artifacts AS a 2560 <dc:variable name="from" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)"/>
2718 WHERE 2561 <dc:variable name="to" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)"/>
2719 (f.name = 'bed_longitudinal_section.porosity_toplayer' OR 2562 <dc:if test="!(($tokm &lt; $from) or $fromkm &gt; $tokm)">
2720 f.name = 'bed_longitudinal_section.porosity_sublayer') AND 2563 <dc:macro-body/>
2721 f.out_id = o.id AND 2564 </dc:if>
2722 o.artifact_id = ${a_id} AND 2565 </dc:for-each>
2723 a.id = ${a_id} 2566 </dc:context>
2724 </dc:statement> 2567 </dc:macro>
2725 <dc:for-each> 2568
2726 <dc:element name="${facet_name}"> 2569 <dc:macro name="user-range">
2727 <dc:attribute name="factory" value="minfo"/> 2570 <dc:choose>
2728 <!-- <dc:attribute name="out" value="${out}"/>--> 2571 <dc:when test="dc:contains($parameters, 'user-id')">
2729 <dc:attribute name="description" value="${facet_description}"/> 2572 <dc:context connection="user">
2730 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/> 2573 <dc:statement>
2731 <dc:attribute name="artifact-id" value="${aid}"/> 2574 SELECT COALESCE(ld_mode, '') AS ldm,
2732 <dc:attribute name="out" value="bed_longitudinal_section"/> 2575 COALESCE(ld_locations, '') AS ldl,
2733 </dc:element> 2576 COALESCE(ld_from, '') AS ldf,
2734 </dc:for-each> 2577 COALESCE(ld_to, '') AS ldt
2735 </dc:context> 2578 FROM master_artifacts_range
2736 </porosity> 2579 WHERE gid = CAST(${artifact-id} AS uuid)
2737 </dc:for-each> 2580 </dc:statement>
2738 </dc:context> 2581 <dc:for-each>
2739 </dc:call-macro> 2582 <dc:variable name="fromkm" type="number" expr="dc:fromValue($ldm, $ldl, $ldf)"/>
2740 </dc:context> 2583 <dc:variable name="tokm" type="number" expr="dc:toValue($ldm, $ldl, $ldt)"/>
2741 </dc:for-each> 2584 <dc:macro-body/>
2742 </bed_quality_porosity> 2585 </dc:for-each>
2743 </dc:macro>
2744
2745 <dc:macro name="flow-velocity">
2746 <flow-velocity>
2747 <dc:for-each>
2748 <dc:context>
2749 <dc:call-macro name="range-filter">
2750 <dc:context>
2751 <dc:statement>
2752 SELECT id AS oid
2753 FROM outs AS o
2754 WHERE
2755 o.artifact_id = ${a_id} and o.name='flow_velocity'
2756 </dc:statement>
2757 <dc:for-each>
2758 <flow description="{$river} {$a_creation} {$collection_name}">
2759 <dc:context>
2760 <dc:statement>
2761 SELECT a.gid AS aid,
2762 f.id AS fid,
2763 f.name AS facet_name,
2764 f.num AS facet_num,
2765 f.description AS facet_description
2766 FROM outs AS o, facets AS f, artifacts AS a
2767 WHERE
2768 (f.name = 'flow_velocity.totalchannel' OR
2769 f.name = 'flow_velocity.mainchannel' OR
2770 f.name = 'flow_velocity.totalchannel.filtered' OR
2771 f.name = 'flow_velocity.mainchannel.filtered') AND
2772 f.out_id = o.id AND
2773 o.artifact_id = ${a_id} AND
2774 a.id = ${a_id}
2775 </dc:statement>
2776 <dc:for-each>
2777 <dc:element name="${facet_name}">
2778 <dc:attribute name="factory" value="minfo"/>
2779 <!-- <dc:attribute name="out" value="${out}"/>-->
2780 <dc:attribute name="description" value="${facet_description}"/>
2781 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2782 <dc:attribute name="artifact-id" value="${aid}"/>
2783 <dc:attribute name="out" value="flow_velocity"/>
2784 </dc:element>
2785 </dc:for-each>
2786 </dc:context>
2787 </flow>
2788 </dc:for-each>
2789 </dc:context>
2790 </dc:call-macro>
2791 </dc:context>
2792 </dc:for-each>
2793 </flow-velocity>
2794 </dc:macro>
2795
2796 <dc:macro name="sediment-load">
2797 <sediment-load>
2798 <dc:for-each>
2799 <dc:context>
2800 <dc:call-macro name="range-filter">
2801 <dc:context>
2802 <dc:statement>
2803 SELECT id AS oid
2804 FROM outs AS o
2805 WHERE
2806 o.artifact_id = ${a_id} and o.name='sedimentload_ls'
2807 </dc:statement>
2808 <dc:for-each>
2809 <load description="{$river} {$a_creation} {$collection_name}">
2810 <dc:context>
2811 <dc:statement>
2812 SELECT a.gid AS aid,
2813 f.id AS fid,
2814 f.name AS facet_name,
2815 f.num AS facet_num,
2816 f.description AS facet_description
2817 FROM outs AS o, facets AS f, artifacts AS a
2818 WHERE f.name LIKE 'sedimentload%' AND
2819 f.out_id = o.id AND
2820 o.artifact_id = ${a_id} AND
2821 a.id = ${a_id}
2822 </dc:statement>
2823 <dc:for-each>
2824 <dc:element name="${facet_name}">
2825 <dc:attribute name="factory" value="minfo"/>
2826 <!-- <dc:attribute name="out" value="${out}"/>-->
2827 <dc:attribute name="description" value="${facet_description}"/>
2828 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2829 <dc:attribute name="artifact-id" value="${aid}"/>
2830 <dc:attribute name="out" value="sedimentload_ls"/>
2831 </dc:element>
2832 </dc:for-each>
2833 </dc:context>
2834 </load>
2835 </dc:for-each>
2836 </dc:context>
2837 </dc:call-macro>
2838 </dc:context>
2839 </dc:for-each>
2840 </sediment-load>
2841 </dc:macro>
2842
2843 <dc:macro name="bedheight-differences">
2844 <bedheight-differences>
2845 <dc:for-each>
2846 <dc:context>
2847 <dc:call-macro name="range-filter">
2848 <dc:context>
2849 <dc:statement>
2850 SELECT id AS oid,
2851 name AS o_name
2852 FROM outs AS o
2853 WHERE
2854 o.artifact_id = ${a_id} AND
2855 (o.name = 'bed_difference_year' OR
2856 o.name = 'bed_differnece_epoch')
2857 </dc:statement>
2858 <dc:for-each>
2859 <difference description="{$river} {$a_creation} {$collection_name}">
2860 <dc:context>
2861 <dc:statement>
2862 SELECT a.gid AS aid,
2863 f.id AS fid,
2864 f.name AS facet_name,
2865 f.num AS facet_num,
2866 f.description AS facet_description
2867 FROM outs AS o, facets AS f, artifacts AS a
2868 WHERE (f.name LIKE 'bedheight_difference.year%' OR
2869 f.name LIKE 'bedheight_difference.epoch%') AND
2870 f.out_id = o.id AND
2871 o.artifact_id = ${a_id} AND
2872 a.id = ${a_id}
2873 </dc:statement>
2874 <dc:for-each>
2875 <dc:element name="${facet_name}">
2876 <dc:attribute name="factory" value="minfo"/>
2877 <!-- <dc:attribute name="out" value="${out}"/>-->
2878 <dc:attribute name="description" value="${facet_description}"/>
2879 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2880 <dc:attribute name="artifact-id" value="${aid}"/>
2881 <dc:choose>
2882 <dc:when test="dc:contains($o_name, 'bed_difference_year')">
2883 <dc:attribute name="out" value="bed_difference_year"/>
2884 </dc:when>
2885 <dc:otherwise>
2886 <dc:attribute name="out" value="bed_difference_epoch"/>
2887 </dc:otherwise>
2888 </dc:choose>
2889 </dc:element>
2890 </dc:for-each>
2891 </dc:context>
2892 </difference>
2893 </dc:for-each>
2894 </dc:context>
2895 </dc:call-macro>
2896 </dc:context>
2897 </dc:for-each>
2898 </bedheight-differences>
2899 </dc:macro>
2900
2901 <dc:macro name="waterlevels-discharge">
2902 <waterlevels-discharge>
2903 <dc:for-each>
2904 <dc:context>
2905 <dc:call-macro name="range-filter">
2906 <dc:context>
2907 <dc:statement>
2908 SELECT id AS oid
2909 FROM outs AS o
2910 WHERE
2911 o.artifact_id = ${a_id} AND
2912 o.name = 'discharge_longitudinal_section'
2913 </dc:statement>
2914 <dc:for-each>
2915 <discharge description="{$oid} {$river} {$a_id} {$a_creation} {$collection_name}">
2916 <dc:context>
2917 <dc:statement>
2918 SELECT a.gid AS aid,
2919 f.id AS fid,
2920 f.name AS facet_name,
2921 f.num AS facet_num,
2922 f.description AS facet_description
2923 FROM outs AS o, facets AS f, artifacts AS a
2924 WHERE f.name = 'discharge_longitudinal_section.w' AND
2925 f.out_id = o.id AND
2926 o.artifact_id = ${a_id} AND
2927 a.id = ${a_id}
2928 </dc:statement>
2929 <dc:for-each>
2930 <dc:element name="${facet_name}">
2931 <dc:attribute name="factory" value="winfo"/>
2932 <!-- <dc:attribute name="out" value="${out}"/>-->
2933 <dc:attribute name="description" value="${facet_description}"/>
2934 <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
2935 <dc:attribute name="artifact-id" value="${aid}"/>
2936 <dc:attribute name="out" value="longitudinal_section"/>
2937 </dc:element>
2938 </dc:for-each>
2939 </dc:context>
2940 </discharge>
2941 </dc:for-each>
2942 </dc:context>
2943 </dc:call-macro>
2944 </dc:context>
2945 </dc:for-each>
2946 </waterlevels-discharge>
2947 </dc:macro>
2948
2949 <dc:iterate var="out" container="artifact-outs">
2950 <dc:choose>
2951 <dc:when test="$out = 'longitudinal_section'">
2952 <dc:call-macro name="longitudinal"/>
2953 <dc:call-macro name="differences"/>
2954 <dc:call-macro name="officiallines_user"/>
2955 </dc:when>
2956 <dc:when test="$out = 'discharge_longitudinal_section'">
2957 <dc:call-macro name="longitudinal"/>
2958 <dc:call-macro name="differences"/>
2959 </dc:when>
2960 <dc:when test="$out = 'w_differences'">
2961 <dc:call-macro name="longitudinal"/>
2962 <dc:call-macro name="differences"/>
2963 </dc:when>
2964 <dc:when test="$out = 'fix_deltawt_curve'">
2965 <dc:call-macro name="delta-wt"/>
2966 </dc:when>
2967 <dc:when test="$out = 'reference_curve'">
2968 <dc:call-macro name="reference-curves"/>
2969 </dc:when>
2970 <dc:when test="$out = 'computed_discharge_curve'">
2971 <dc:call-macro name="computed-discharge-curve"/>
2972 </dc:when>
2973 <dc:when test="$out = 'cross_section'">
2974 <dc:call-macro name="waterlevels"/>
2975 </dc:when>
2976 <dc:when test="$out = 'fix_longitudinal_section_curve'">
2977 <dc:call-macro name="longitudinal-section"/>
2978 </dc:when>
2979 <dc:when test="$out = 'fix_derivate_curve'">
2980 <dc:call-macro name="fix-derivate-curve"/>
2981 </dc:when>
2982 <dc:when test="$out = 'fix_wq_curve'">
2983 <dc:call-macro name="fix-wq-curve"/>
2984 </dc:when>
2985 <dc:when test="$out = 'duration_curve'">
2986 <dc:call-macro name="duration-curve"/>
2987 </dc:when>
2988 <dc:when test="$out = 'waterlevels'">
2989 <!-- base data -->
2990 <dc:call-macro name="basedata_0"/>
2991 <!-- extra-longitudinal-sections -->
2992 <dc:call-macro name="basedata_1_additionals"/>
2993 <!-- fixations -->
2994 <dc:call-macro name="basedata_2_fixations"/>
2995 <!-- flood water marks-->
2996 <dc:call-macro name="basedata_4_heightmarks-points"/>
2997 <!-- flood protection -->
2998 <dc:call-macro name="basedata_5_flood-protections"/>
2999 <dc:call-macro name="waterlevels-fix"/>
3000 </dc:when>
3001 <dc:when test="$out = 'fix_wq_curve'">
3002 <dc:call-macro name="waterlevels-fix"/>
3003 </dc:when>
3004 <dc:when test="$out = 'floodmap'">
3005 <dc:call-macro name="flood-map"/>
3006 </dc:when>
3007 <dc:when test="$out = 'map'">
3008 <dc:call-macro name="flood-map"/>
3009 </dc:when>
3010 <dc:when test="$out = 'bedheight_middle'">
3011 <dc:call-macro name="waterlevels-discharge"/>
3012 <dc:call-macro name="waterlevels-fix"/>
3013 </dc:when>
3014 <dc:when test="$out = 'floodmap-hws'">
3015 <dc:call-macro name="floodmap-hws-user"/>
3016 </dc:when>
3017 <dc:when test="$out = 'flow_velocity'">
3018 <dc:call-macro name="bedquality-bed"/>
3019 <dc:call-macro name="bedquality-load"/>
3020 </dc:when>
3021 <dc:when test="$out = 'bed_longitudinal_section'">
3022 <dc:call-macro name="bedquality-bed"/>
3023 <dc:call-macro name="bedquality-load"/>
3024 <dc:call-macro name="bedquality-density"/>
3025 <dc:call-macro name="bedquality-porosity"/>
3026 </dc:when>
3027 <dc:when test="$out = 'sedimentload_ls'">
3028 <dc:call-macro name="differences"/>
3029 <dc:call-macro name="bedheight-differences"/>
3030 <dc:call-macro name="flow-velocity"/>
3031 <dc:call-macro name="sediment-load"/>
3032 </dc:when>
3033 <dc:when test="$out = 'bed_difference_year'">
3034 <dc:call-macro name="waterlevels-discharge"/>
3035 <dc:call-macro name="bedheight-differences"/>
3036 <dc:call-macro name="differences"/>
3037 <dc:call-macro name="waterlevels-fix"/>
3038 <dc:call-macro name="delta-wt-ls"/>
3039 </dc:when>
3040 <dc:when test="$out = 'bed_difference_epoch'">
3041 <dc:call-macro name="waterlevels-discharge"/>
3042 <dc:call-macro name="bedheight-differences"/>
3043 <dc:call-macro name="differences"/>
3044 <dc:call-macro name="waterlevels-fix"/>
3045 <dc:call-macro name="delta-wt-ls"/>
3046 </dc:when>
3047 </dc:choose>
3048 </dc:iterate>
3049 </dc:context> 2586 </dc:context>
3050 </dc:call-macro> 2587 </dc:when>
3051 2588 <dc:otherwise>
3052 </old_calculations> 2589 <dc:variable name="fromkm" type="number" expr="dc:fromValue('', '', '')"/>
3053 2590 <dc:variable name="tokm" type="number" expr="dc:toValue('', '', '')"/>
3054 <dc:if test="dc:contains($parameters,'load-system')"> 2591 <dc:macro-body/>
3055 <dc:comment> 2592 </dc:otherwise>
3056 Include System specific part when 'load-system' is in parameters. 2593 </dc:choose>
3057 ----------------------------------------------------------------- 2594 </dc:macro>
3058 </dc:comment> 2595
3059 <dc:call-macro name="load-system"/> 2596 </datacage>
3060 </dc:if>
3061 </dc:when>
3062
3063 <dc:otherwise>
3064 <dc:comment>
3065 Include System specific part only if no user ID is given.
3066 ---------------------------------------------------------
3067 </dc:comment>
3068 <dc:call-macro name="load-system"/>
3069 </dc:otherwise>
3070 </dc:choose>
3071
3072 </datacage>
3073 </dc:template> 2597 </dc:template>

http://dive4elements.wald.intevation.org