diff artifacts/doc/conf/meta-data.xml @ 8941:a9950a3a71e5

SINFO - tkh, configured result facets and themes Configured datacages
author gernotbelger
date Wed, 07 Mar 2018 17:36:04 +0100
parents 5d5d0051723f
children b0aeed4c97c1
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Tue Mar 06 18:51:18 2018 +0100
+++ b/artifacts/doc/conf/meta-data.xml	Wed Mar 07 17:36:04 2018 +0100
@@ -117,7 +117,7 @@
                   <dc:when test="$out = 'floodmap'">
                     <dc:call-macro name="flood-map-recommended"/>
                   </dc:when>
-                  
+
                   <dc:when test="$out = 'sinfo_flow_depth'">
                     <dc:call-macro name="annotations"/>
                   </dc:when>
@@ -262,12 +262,14 @@
                     <dc:call-macro name="basedata_4_heightmarks-points"/>
                     <dc:call-macro name="basedata_5_flood-protections"/>
                   </dc:when>
-                  
+
                   <dc:when test="$out = 'sinfo_flow_depth'">
-                  <!--  FIXME: chcck -->
                     <dc:call-macro name="longitudinal-section-prototype"/>
-                  </dc:when>                  
+                  </dc:when>
 
+                  <dc:when test="$out = 'sinfo_tkk'">
+                    <dc:call-macro name="longitudinal-section-prototype"/>
+                  </dc:when>
                 </dc:choose>
               </dc:iterate>
             </dc:otherwise>
@@ -351,6 +353,9 @@
                     <dc:when test="$out = 'sinfo_flow_depth'">
                       <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
+                    <dc:when test="$out = 'sinfo_tkk'">
+                      <dc:call-macro name="longitudinal-section-user-prototype"/>
+                    </dc:when>
                     <dc:comment> Discharge curves </dc:comment>
                     <dc:when test="$out = 'computed_discharge_curve'">
                       <dc:call-macro name="discharge-curve-user-prototype"/>
@@ -748,13 +753,11 @@
                 <dc:for-each>
                   <dc:choose>
                     <dc:when test="$ld_m = 'location'">
-                      <dc:variable name="combined_desc"
-                                   expr="concat($facet_description,
+                      <dc:variable name="combined_desc" expr="concat($facet_description,
                                          ' an KM ', $deffrom)"/>
                     </dc:when>
                     <dc:otherwise>
-                      <dc:variable name="combined_desc"
-                                   expr="concat($facet_description, ' von KM ',
+                      <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
                                          $deffrom, ' bis KM ', $defto)"/>
                     </dc:otherwise>
                   </dc:choose>
@@ -774,7 +777,7 @@
       </dc:filter>
     </dc:macro>
 
-    <dc:comment comment="For building differences." />
+    <dc:comment comment="For building differences."/>
     <dc:macro name="differences-fix">
       <dc:comment comment="Vollmer curves need own factory"/>
       <dc:filter expr="$a_state = 'state.fix.vollmer.compute' and $facet_name = 'longitudinal_section.w'">
@@ -791,7 +794,7 @@
                       <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
                         $deffrom, ' bis KM ', $defto)"/>
                     </dc:otherwise>
-                 </dc:choose>
+                  </dc:choose>
                   <dc:element name="${facet_name}">
                     <dc:attribute name="description" value="${combined_desc}"/>
                     <dc:attribute name="ids" value="${facet_num}"/>
@@ -811,27 +814,27 @@
         <dc:if test="dc:has-result()">
           <waterlevels>
             <dc:call-macro name="collection-group">
-                <waterlevels description="{dc:group-key()}">
-                  <dc:for-each>
-                    <dc:choose>
-                      <dc:when test="$ld_m = 'location'">
-                        <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)"/>
-                      </dc:when>
-                      <dc:otherwise>
-                        <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:choose>
+                    <dc:when test="$ld_m = 'location'">
+                      <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)"/>
+                    </dc:when>
+                    <dc:otherwise>
+                      <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
                           $deffrom, ' bis KM ', $defto)"/>
-                      </dc:otherwise>
-                    </dc:choose>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${combined_desc}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="winfo"/>
-                      <dc:attribute name="target_out" value="${out}"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
+                    </dc:otherwise>
+                  </dc:choose>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${combined_desc}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="winfo"/>
+                    <dc:attribute name="target_out" value="${out}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
             </dc:call-macro>
           </waterlevels>
         </dc:if>
@@ -977,7 +980,8 @@
     </dc:macro>
 
     <dc:macro name="sqrelations_user">
-      <dc:filter expr="not(dc:contains($facet_name, 'overview')) and (
+      <dc:filter
+        expr="not(dc:contains($facet_name, 'overview')) and (
         ($out = 'sq_relation_a' and starts-with($facet_name, 'sq_a_')) or
         ($out = 'sq_relation_b' and starts-with($facet_name, 'sq_b_')) or
         ($out = 'sq_relation_c' and starts-with($facet_name, 'sq_c_')) or
@@ -1045,25 +1049,19 @@
     <!-- discharge curves -->
     <dc:macro name="hist_discharge_factory">
       <dc:for-each>
-        <dc:variable name="validity"
-                     expr="concat(
+        <dc:variable name="validity" expr="concat(
                            dc:date-format('dd.MM.yyyy', $start_time),
                            ' - ',
                            dc:date-format('dd.MM.yyyy', $stop_time))"/>
-        <histdis name="{concat($bfg_id, ' ', $validity)}"
-                 description="{concat($bfg_id, ' ', $validity)}"
-                 factory="gaugedischarge" target_out="{$out}"
-                 ids="{$gauge_name};{$dt_id};{concat($bfg_id, ' ',
+        <histdis name="{concat($bfg_id, ' ', $validity)}" description="{concat($bfg_id, ' ', $validity)}" factory="gaugedischarge" target_out="{$out}" ids="{$gauge_name};{$dt_id};{concat($bfg_id, ' ',
                       $gauge_name, ' ', $validity)}"/>
       </dc:for-each>
     </dc:macro>
 
     <dc:macro name="hist_discharge_rec">
-      <dc:variable name="start" type="number"
-                   expr="dc:date-format('yyyyMMdd',
+      <dc:variable name="start" type="number" expr="dc:date-format('yyyyMMdd',
                            number(substring-before($year_range, ';')))"/>
-      <dc:variable name="stop" type="number"
-                   expr="dc:date-format('yyyyMMdd',
+      <dc:variable name="stop" type="number" expr="dc:date-format('yyyyMMdd',
                            number(substring-after($year_range, ';')))"/>
       <dc:call-macro name="discharge_curve_choose_context">
         <dc:filter expr="$kind = 1 and
@@ -1084,8 +1082,7 @@
           <dc:group expr="$gauge_name">
             <gauge name="{dc:group-key()}">
               <dc:for-each>
-                <current_gauge factory="gaugedischarge" target_out="{$out}"
-                               ids="{$gauge_name}"/>
+                <current_gauge factory="gaugedischarge" target_out="{$out}" ids="{$gauge_name}"/>
               </dc:for-each>
             </gauge>
           </dc:group>
@@ -1116,8 +1113,7 @@
           </dc:context>
         </dc:when>
         <dc:otherwise>
-          <dc:variable name="refgauge" type="number"
-                       expr="dc:get('reference_gauge')"/>
+          <dc:variable name="refgauge" type="number" expr="dc:get('reference_gauge')"/>
           <dc:context>
             <dc:call-macro name="discharge_curves_refgauge"/>
             <dc:macro-body/>
@@ -1128,35 +1124,35 @@
 
     <dc:macro name="discharge_curves_km">
       <dc:statement>
-          SELECT g.name AS gauge_name,
-                 dt.id  AS dt_id,
-                 t.start_time AS start_time,
-                 t.stop_time AS stop_time,
-                 dt.bfg_id AS bfg_id,
-                 dt.kind AS kind
-          FROM gauges g
-          JOIN discharge_tables dt ON g.id = dt.gauge_id
-          LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
-          WHERE g.river_id = ${river_id}
-            AND g.station BETWEEN ${fromkm} AND ${tokm}
-          ORDER BY start_time
+        SELECT g.name AS gauge_name,
+        dt.id AS dt_id,
+        t.start_time AS start_time,
+        t.stop_time AS stop_time,
+        dt.bfg_id AS bfg_id,
+        dt.kind AS kind
+        FROM gauges g
+        JOIN discharge_tables dt ON g.id = dt.gauge_id
+        LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
+        WHERE g.river_id = ${river_id}
+        AND g.station BETWEEN ${fromkm} AND ${tokm}
+        ORDER BY start_time
       </dc:statement>
     </dc:macro>
 
     <dc:macro name="discharge_curves_refgauge">
       <dc:statement>
-          SELECT g.name AS gauge_name,
-                 dt.id  AS dt_id,
-                 t.start_time AS start_time,
-                 t.stop_time AS stop_time,
-                 dt.bfg_id AS bfg_id,
-                 dt.kind AS kind
-          FROM gauges g
-          JOIN discharge_tables dt ON g.id = dt.gauge_id
-          LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
-          WHERE g.river_id = ${river_id}
-            AND g.official_number = ${refgauge}
-          ORDER BY start_time
+        SELECT g.name AS gauge_name,
+        dt.id AS dt_id,
+        t.start_time AS start_time,
+        t.stop_time AS stop_time,
+        dt.bfg_id AS bfg_id,
+        dt.kind AS kind
+        FROM gauges g
+        JOIN discharge_tables dt ON g.id = dt.gauge_id
+        LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
+        WHERE g.river_id = ${river_id}
+        AND g.official_number = ${refgauge}
+        ORDER BY start_time
       </dc:statement>
     </dc:macro>
 
@@ -1166,17 +1162,15 @@
         <dc:context connection="system">
           <dc:statement>
             SELECT DISTINCT
-                   cs.id          AS prot_id,
-                   cs.description AS prot_description
+            cs.id AS prot_id,
+            cs.description AS prot_description
             FROM cross_sections cs
-              JOIN cross_section_lines csl ON csl.cross_section_id = cs.id
+            JOIN cross_section_lines csl ON csl.cross_section_id = cs.id
             WHERE cs.river_id = ${river_id}
-              AND csl.km BETWEEN ${fromkm} AND ${tokm}
+            AND csl.km BETWEEN ${fromkm} AND ${tokm}
           </dc:statement>
           <dc:for-each>
-            <cross_section name="{$prot_description}"
-                           ids="{$prot_id}"
-                           factory="crosssections" target_out="{$out}" />
+            <cross_section name="{$prot_description}" ids="{$prot_id}" factory="crosssections" target_out="{$out}"/>
           </dc:for-each>
         </dc:context>
       </cross_sections>
@@ -1187,17 +1181,15 @@
         <dc:context connection="system">
           <dc:statement>
             SELECT DISTINCT
-                   h.id          AS hyk_id,
-                   h.description AS hyk_description
+            h.id AS hyk_id,
+            h.description AS hyk_description
             FROM hyks h
-              JOIN hyk_entries he ON he.hyk_id = h.id
+            JOIN hyk_entries he ON he.hyk_id = h.id
             WHERE river_id = ${river_id}
-              AND he.km BETWEEN ${fromkm} AND ${tokm}
+            AND he.km BETWEEN ${fromkm} AND ${tokm}
           </dc:statement>
           <dc:for-each>
-            <hyk name="{$hyk_description}"
-                 ids="{$hyk_id}"
-                 factory="hyk" target_out="{$out}" />
+            <hyk name="{$hyk_description}" ids="{$hyk_id}" factory="hyk" target_out="{$out}"/>
           </dc:for-each>
         </dc:context>
       </hyks>
@@ -1225,19 +1217,13 @@
 
     <dc:macro name="basedata_0">
       <dc:call-macro name="basedata_0_macro">
-        <column name="{$wst_column_name}"
-                ids="base_data-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwqkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_0_wq">
       <dc:call-macro name="basedata_0_macro">
-        <column name="{$wst_column_name}"
-                ids="base_data-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1260,28 +1246,19 @@
 
     <dc:macro name="basedata_1_additionals">
       <dc:call-macro name="basedata_1_additionals_macro">
-        <column name="{$wst_column_name}"
-                ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwqkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_1_additionals_wq">
       <dc:call-macro name="basedata_1_additionals_macro">
-        <column name="{$wst_column_name}"
-                ids="base_data-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_1_additionals-relative_point">
       <dc:call-macro name="basedata_1_additionals_macro">
-        <column name="{$wst_column_name}"
-                ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1304,28 +1281,19 @@
 
     <dc:macro name="basedata_2_fixations">
       <dc:call-macro name="fixings-macro">
-        <column name="{$wst_column_name}"
-                ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwqkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_2_fixations_wq">
       <dc:call-macro name="fixings-macro">
-        <column name="{$wst_column_name}"
-                ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_2_fixations_relative_point">
       <dc:call-macro name="fixings-macro">
-        <column name="{$wst_column_name}"
-                ids="fixations-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1348,21 +1316,13 @@
 
     <dc:macro name="basedata_3_officials">
       <dc:call-macro name="basedata_3_macro">
-        <column name="{$wst_column_name}"
-                ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwqkms"
-                target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_3_officials_wq">
       <dc:call-macro name="basedata_3_macro">
-        <column name="{$wst_column_name}"
-                ids="officials_wq-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol"
-                target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="officials_wq-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1385,28 +1345,19 @@
 
     <dc:macro name="basedata_4_heightmarks-points">
       <dc:call-macro name="basedata_4_macro">
-        <column name="{$wst_column_name}"
-                ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_4_heightmarks-points_wq">
       <dc:call-macro name="basedata_4_macro">
-        <column name="{$wst_column_name}"
-                ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_4_heightmarks-points-relative_points">
       <dc:call-macro name="basedata_4_macro">
-        <column name="{$wst_column_name}"
-                ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1429,28 +1380,19 @@
 
     <dc:macro name="basedata_5_flood-protections">
       <dc:call-macro name="basedata_5_macro">
-        <column name="{$wst_column_name}"
-                ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_5_flood-protections_wq">
       <dc:call-macro name="basedata_5_macro">
-        <column name="{$wst_column_name}"
-                ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_5_flood-protections_relative_points">
       <dc:call-macro name="basedata_5_macro">
-        <column name="{$wst_column_name}"
-                ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1464,11 +1406,7 @@
                 <dc:group expr="dc:replace($wst_description, 'CSV/', '')">
                   <relativepoint name="{dc:group-key()}">
                     <dc:for-each>
-                      <column name="{$wst_column_name}"
-                              ids="delta_w-wstv-{$wst_column_position}-{$wst_id}"
-                              factory="staticwkms"
-                              target_out="{$out}"
-                              info="{$info} [km {$deffrom} - {$defto}]"/>
+                      <column name="{$wst_column_name}" ids="delta_w-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
                     </dc:for-each>
                   </relativepoint>
                 </dc:group>
@@ -1479,10 +1417,7 @@
                 <dc:group expr="dc:replace($wst_description, 'CSV/', '')">
                   <relativepoint name="{dc:group-key()}">
                     <dc:for-each>
-                      <column name="{$wst_column_name}"
-                              ids="delta_w_cma-wstv-{$wst_column_position}-{$wst_id}"
-                              factory="staticwkms" target_out="{$out}"
-                              info="{$info} [km {$deffrom} - {$defto}]"/>
+                      <column name="{$wst_column_name}" ids="delta_w_cma-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
                     </dc:for-each>
                   </relativepoint>
                 </dc:group>
@@ -1512,19 +1447,13 @@
 
     <dc:macro name="basedata_7_waterlevels">
       <dc:call-macro name="basedata_7_macro">
-        <column name="{$wst_column_name}"
-                ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
-                factory="staticwqkms" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
     <dc:macro name="basedata_7_waterlevels_wq">
       <dc:call-macro name="basedata_7_macro">
-        <column name="{$wst_column_name}"
-                ids="additionals-wstv-{$wst_column_position}-{$wst_id}"
-                factory="wqinterpol" target_out="{$out}"
-                info="{$info} [km {$deffrom} - {$defto}]"/>
+        <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]"/>
       </dc:call-macro>
     </dc:macro>
 
@@ -1532,21 +1461,21 @@
     <!-- prototypes -->
 
     <dc:macro name="discharge-curve-prototype">
-        <computed_discharge_curve>
-          <dc:call-macro name="discharge_table_gauge"/>
-          <dc:call-macro name="mainvalues"/>
-        </computed_discharge_curve>
-        <dc:call-macro name="historical_discharge_curve"/>
-        <dc:call-macro name="basedata_0_wq"/>
-        <dc:call-macro name="basedata_1_additionals_wq"/>
-        <dc:call-macro name="basedata_2_fixations_wq"/>
-        <dc:call-macro name="basedata_3_officials_wq"/>
-        <dc:call-macro name="basedata_4_heightmarks-points_wq"/>
-        <dc:call-macro name="basedata_5_flood-protections_wq"/>
-        <minfo>
-          <dc:call-macro name="sqrelations"/>
-          <dc:call-macro name="basedata_7_waterlevels_wq"/>
-        </minfo>
+      <computed_discharge_curve>
+        <dc:call-macro name="discharge_table_gauge"/>
+        <dc:call-macro name="mainvalues"/>
+      </computed_discharge_curve>
+      <dc:call-macro name="historical_discharge_curve"/>
+      <dc:call-macro name="basedata_0_wq"/>
+      <dc:call-macro name="basedata_1_additionals_wq"/>
+      <dc:call-macro name="basedata_2_fixations_wq"/>
+      <dc:call-macro name="basedata_3_officials_wq"/>
+      <dc:call-macro name="basedata_4_heightmarks-points_wq"/>
+      <dc:call-macro name="basedata_5_flood-protections_wq"/>
+      <minfo>
+        <dc:call-macro name="sqrelations"/>
+        <dc:call-macro name="basedata_7_waterlevels_wq"/>
+      </minfo>
     </dc:macro>
 
     <dc:macro name="discharge-curve-user-prototype">
@@ -1570,20 +1499,20 @@
       <dc:call-macro name="basedata_5_flood-protections"/>
       <dc:call-macro name="annotations_per_type"/>
       <minfo>
-          <fixanalysis>
-            <dc:call-macro name="basedata_6_delta_w"/>
-            <dc:call-macro name="basedata_7_waterlevels"/>
-          </fixanalysis>
-          <dc:call-macro name="sedimentloads"/>
-          <dc:call-macro name="densities"/>
-          <dc:call-macro name="minfo-heights"/>
-          <dc:call-macro name="sounding-width"/>
-          <dc:call-macro name="morph_width"/>
-          <dc:call-macro name="porosities"/>
-          <flow_velocities>
-            <dc:call-macro name="flow_velocity_measurements"/>
-            <dc:call-macro name="flow_velocity_models"/>
-          </flow_velocities>
+        <fixanalysis>
+          <dc:call-macro name="basedata_6_delta_w"/>
+          <dc:call-macro name="basedata_7_waterlevels"/>
+        </fixanalysis>
+        <dc:call-macro name="sedimentloads"/>
+        <dc:call-macro name="densities"/>
+        <dc:call-macro name="minfo-heights"/>
+        <dc:call-macro name="sounding-width"/>
+        <dc:call-macro name="morph_width"/>
+        <dc:call-macro name="porosities"/>
+        <flow_velocities>
+          <dc:call-macro name="flow_velocity_measurements"/>
+          <dc:call-macro name="flow_velocity_models"/>
+        </flow_velocities>
       </minfo>
     </dc:macro>
 
@@ -1600,93 +1529,81 @@
       <dc:call-macro name="bedquality"/>
       <dc:call-macro name="flow-velocity"/>
       <dc:call-macro name="sediment-load"/>
-      
+
       <dc:comment> SINFO </dc:comment>
       <dc:call-macro name="sinfo_flowdepths"/>
       <dc:call-macro name="sinfo_tkh"/>
+
+      <dc:call-macro name="sinfo_tkh_velocity"/>
+      <dc:call-macro name="sinfo_tkh_d50"/>
+      <dc:call-macro name="sinfo_tkh_tau"/>
     </dc:macro>
 
     <!-- porosities -->
     <dc:macro name="porosities">
       <porosities>
-      <dc:context>
-        <dc:statement>
+        <dc:context>
+          <dc:statement>
             SELECT DISTINCT
-                p.id          AS pid,
-                p.description AS description,
-                d.lower        AS depth_lower,
-                d.upper        AS depth_upper,
-                p.description  || '&lt;BR&gt;' ||
-                'Tiefe: ' || d.lower || ' - ' || d.upper
-                    || ' cm &lt;BR&gt;' ||
-                'Zeitraum: ' AS info,
-                t.start_time AS syear,
-                t.stop_time AS eyear
-            FROM     porosity p
-                JOIN depths d ON p.depth_id = d.id
-                JOIN time_intervals t ON p.time_interval_id=t.id
-            WHERE   p.river_id = ${river_id}
+            p.id AS pid,
+            p.description AS description,
+            d.lower AS depth_lower,
+            d.upper AS depth_upper,
+            p.description || '&lt;BR&gt;' ||
+            'Tiefe: ' || d.lower || ' - ' || d.upper
+            || ' cm &lt;BR&gt;' ||
+            'Zeitraum: ' AS info,
+            t.start_time AS syear,
+            t.stop_time AS eyear
+            FROM porosity p
+            JOIN depths d ON p.depth_id = d.id
+            JOIN time_intervals t ON p.time_interval_id=t.id
+            WHERE p.river_id = ${river_id}
             ORDER BY depth_lower, depth_upper
-        </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:for-each>
-                  <porosity description="{$depth_lower}-{$depth_upper} cm"
-                   factory="porosity"
-                   target_out="{$out}"
-                   info="{concat($info, dc:date-format('yyyy', $syear),
-                             ' - ', dc:date-format('yyyy', $eyear))}"
-                   ids="{$pid};{$description}" />
-          </dc:for-each>
-        </dc:if>
-      </dc:context>
+          </dc:statement>
+          <dc:if test="dc:has-result()">
+            <dc:for-each>
+              <porosity description="{$depth_lower}-{$depth_upper} cm" factory="porosity" target_out="{$out}" info="{concat($info, dc:date-format('yyyy', $syear),
+                             ' - ', dc:date-format('yyyy', $eyear))}" ids="{$pid};{$description}"/>
+            </dc:for-each>
+          </dc:if>
+        </dc:context>
       </porosities>
     </dc:macro>
 
     <dc:macro name="densities">
       <densities>
-      <dc:context>
-        <dc:statement>
+        <dc:context>
+          <dc:statement>
             SELECT DISTINCT
-                sd.id          AS sdid,
-                d.lower        AS depth_lower,
-                d.upper        AS depth_upper,
-                min(sdv.year)  AS year,
-                sd.description || '&lt;BR&gt;Jahr: ' || min(sdv.year) AS info
-            FROM     sediment_density sd
-                JOIN depths d ON sd.depth_id = d.id
-                JOIN sediment_density_values sdv on sdv.sediment_density_id = sd.id
-            WHERE   sd.river_id = ${river_id}
+            sd.id AS sdid,
+            d.lower AS depth_lower,
+            d.upper AS depth_upper,
+            min(sdv.year) AS year,
+            sd.description || '&lt;BR&gt;Jahr: ' || min(sdv.year) AS info
+            FROM sediment_density sd
+            JOIN depths d ON sd.depth_id = d.id
+            JOIN sediment_density_values sdv on sdv.sediment_density_id = sd.id
+            WHERE sd.river_id = ${river_id}
             GROUP BY sd.id, sd.description, d.upper, d.lower
             ORDER BY year, depth_lower, depth_upper
-        </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:for-each>
-                  <density description="{$depth_lower}-{$depth_upper} cm"
-                   factory="sedimentdensity"
-                   target_out="{$out}"
-                   info="{$info}"
-                   ids="{$sdid}" />
-          </dc:for-each>
-        </dc:if>
-      </dc:context>
+          </dc:statement>
+          <dc:if test="dc:has-result()">
+            <dc:for-each>
+              <density description="{$depth_lower}-{$depth_upper} cm" factory="sedimentdensity" target_out="{$out}" info="{$info}" ids="{$sdid}"/>
+            </dc:for-each>
+          </dc:if>
+        </dc:context>
       </densities>
     </dc:macro>
 
     <!-- sediment load -->
     <dc:macro name="load">
-      <year description="{$timespan}"
-            factory="sedimentload"
-            target_out="{$out}"
-            info="{$info}"
-            ids="{$slid};{$fraction};{$timespan};{$kind}" />
+      <year description="{$timespan}" factory="sedimentload" target_out="{$out}" info="{$info}" ids="{$slid};{$fraction};{$timespan};{$kind}"/>
     </dc:macro>
 
     <dc:macro name="load_ls">
-      <year description="{$timespan}"
-            factory="sedimentload_ls"
-            target_out="{$out}"
-            info="{$info}"
-            ids="{$slid};{$timespan};{$kind}" />
+      <year description="{$timespan}" factory="sedimentload_ls" target_out="{$out}" info="{$info}" ids="{$slid};{$timespan};{$kind}"/>
     </dc:macro>
 
     <dc:macro name="loads">
@@ -1695,25 +1612,21 @@
                         dc:date-format('yyyy', $sqstop))">
           <sq_time description="{dc:group-key()}">
             <dc:group expr="$fraction">
-              <dc:variable name="fraction_name"
-                           expr="concat('${', dc:group-key(), '}')"/>
+              <dc:variable name="fraction_name" expr="concat('${', dc:group-key(), '}')"/>
               <fraction description="{$fraction_name}">
                 <dc:for-each>
                   <dc:choose>
                     <dc:when test="string-length(dc:get('endyear')) = 0">
-                      <dc:variable name="timespan" type="string"
-                                   expr="dc:date-format('yyyy', $startyear)"/>
+                      <dc:variable name="timespan" type="string" expr="dc:date-format('yyyy', $startyear)"/>
                     </dc:when>
                     <dc:otherwise>
-                      <dc:variable name="timespan" type="string"
-                                   expr="concat(dc:date-format('yyyy',
+                      <dc:variable name="timespan" type="string" expr="concat(dc:date-format('yyyy',
                                          $startyear), '-',
                                          dc:date-format('yyyy', $endyear))"/>
                     </dc:otherwise>
                   </dc:choose>
                   <dc:if test="$kind = 'official'">
-                    <dc:variable name="info" type="string"
-                                 expr="concat('Amtliche Epoche&lt;BR&gt;',
+                    <dc:variable name="info" type="string" expr="concat('Amtliche Epoche&lt;BR&gt;',
                                        dc:get('info'))"/>
                   </dc:if>
                   <dc:macro-body/>
@@ -1728,18 +1641,18 @@
     <dc:macro name="sedimentloads-filter">
       <years>
         <dc:filter expr="string-length(dc:get('endyear')) = 0 and
-                         $kind != 'official'" >
+                         $kind != 'official'">
           <dc:macro-body/>
         </dc:filter>
       </years>
       <epochs>
         <dc:filter expr="string-length(dc:get('endyear')) &gt; 0 and
-                         $kind != 'official'" >
+                         $kind != 'official'">
           <dc:macro-body/>
         </dc:filter>
       </epochs>
       <off_epochs>
-        <dc:filter expr="$kind = 'official'" >
+        <dc:filter expr="$kind = 'official'">
           <dc:macro-body/>
         </dc:filter>
       </off_epochs>
@@ -1774,63 +1687,64 @@
     <dc:macro name="sedimentload_stations_statement">
       <dc:statement>
         SELECT DISTINCT
-            sl.id          AS slid,
-            slk.kind       AS kind,
-            ti.start_time  AS startyear,
-            ti.stop_time   AS endyear,
-            sq.start_time  AS sqstart,
-            sq.stop_time   AS sqstop,
-            sq.id          AS sqid,
-            gf.name        AS fraction,
-            sl.description  || '&lt;BR&gt;' ||
-                'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
-                ' mm&lt;BR&gt;Einheit: t/a' AS info
-        FROM     sediment_load sl
-            JOIN sediment_load_kinds slk ON slk.id = sl.kind
-            JOIN sediment_load_values slv
-                ON sl.id = slv.sediment_load_id
-            JOIN measurement_station ms
-                ON ms.id = slv.measurement_station_id
-            JOIN ranges ra ON ms.range_id = ra.id
-            JOIN rivers r ON ra.river_id = r.id
-            JOIN time_intervals ti ON sl.time_interval_id = ti.id
-            LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
-            JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
+        sl.id AS slid,
+        slk.kind AS kind,
+        ti.start_time AS startyear,
+        ti.stop_time AS endyear,
+        sq.start_time AS sqstart,
+        sq.stop_time AS sqstop,
+        sq.id AS sqid,
+        gf.name AS fraction,
+        sl.description || '&lt;BR&gt;' ||
+        'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
+        ' mm&lt;BR&gt;Einheit: t/a' AS info
+        FROM sediment_load sl
+        JOIN sediment_load_kinds slk ON slk.id = sl.kind
+        JOIN sediment_load_values slv
+        ON sl.id = slv.sediment_load_id
+        JOIN measurement_station ms
+        ON ms.id =
+        slv.measurement_station_id
+        JOIN ranges ra ON ms.range_id = ra.id
+        JOIN rivers r ON ra.river_id = r.id
+        JOIN time_intervals ti ON sl.time_interval_id = ti.id
+        LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
+        JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
         WHERE r.id = ${river_id}
-            AND CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL
-            THEN ra.b ELSE ra.a END BETWEEN ${fromkm} AND ${tokm}
-            ORDER BY sqstart DESC, sqstop DESC,
-                fraction, startyear DESC, endyear DESC
+        AND CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL
+        THEN ra.b ELSE ra.a END BETWEEN ${fromkm} AND ${tokm}
+        ORDER BY sqstart DESC, sqstop DESC,
+        fraction, startyear DESC, endyear DESC
       </dc:statement>
     </dc:macro>
 
     <dc:macro name="sedimentload_ls_statement">
       <dc:statement>
         SELECT DISTINCT
-            sl.id          AS slid,
-            slk.kind       AS kind,
-            ti.start_time  AS startyear,
-            ti.stop_time   AS endyear,
-            sq.start_time  AS sqstart,
-            sq.stop_time   AS sqstop,
-            sq.id          AS sqid,
-            gf.name        AS fraction,
-            sl.description  || '&lt;BR&gt;' ||
-                'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
-                ' mm&lt;BR&gt;Einheit: ' || u.name AS info
-        FROM     sediment_load_ls sl
-            JOIN sediment_load_kinds slk ON slk.id = sl.kind
-            JOIN rivers r ON sl.river_id = r.id
-            JOIN sediment_load_ls_values slv
-                ON sl.id = slv.sediment_load_ls_id
-            JOIN time_intervals ti ON sl.time_interval_id = ti.id
-            LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
-            JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
-            JOIN units u ON sl.unit_id = u.id
-        WHERE   r.id = ${river_id}
-            AND slv.station BETWEEN ${fromkm} AND ${tokm}
+        sl.id AS slid,
+        slk.kind AS kind,
+        ti.start_time AS startyear,
+        ti.stop_time AS endyear,
+        sq.start_time AS sqstart,
+        sq.stop_time AS sqstop,
+        sq.id AS sqid,
+        gf.name AS fraction,
+        sl.description || '&lt;BR&gt;' ||
+        'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
+        ' mm&lt;BR&gt;Einheit: ' || u.name AS info
+        FROM sediment_load_ls sl
+        JOIN sediment_load_kinds slk ON slk.id = sl.kind
+        JOIN rivers r ON sl.river_id = r.id
+        JOIN sediment_load_ls_values slv
+        ON sl.id = slv.sediment_load_ls_id
+        JOIN time_intervals ti ON sl.time_interval_id = ti.id
+        LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
+        JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
+        JOIN units u ON sl.unit_id = u.id
+        WHERE r.id = ${river_id}
+        AND slv.station BETWEEN ${fromkm} AND ${tokm}
         ORDER BY sqstart DESC, sqstop DESC,
-            fraction, startyear DESC, endyear DESC
+        fraction, startyear DESC, endyear DESC
       </dc:statement>
     </dc:macro>
 
@@ -1842,16 +1756,14 @@
     <dc:macro name="annotations_per_type">
       <annotations>
         <dc:context>
-          <all_annotations factory="annotations" ids="{$river_id}" target_out="{$out}" />
+          <all_annotations factory="annotations" ids="{$river_id}" target_out="{$out}"/>
           <dc:statement>
-            SELECT id   AS anno_id,
-                   name AS anno_description
+            SELECT id AS anno_id,
+            name AS anno_description
             FROM annotation_types
           </dc:statement>
           <dc:for-each>
-            <annotation name="{$anno_description}"
-                        factory="annotations" target_out="{$out}"
-                        ids="{$river_id}:{$anno_description}"/>
+            <annotation name="{$anno_description}" factory="annotations" target_out="{$out}" ids="{$river_id}:{$anno_description}"/>
           </dc:for-each>
         </dc:context>
       </annotations>
@@ -1861,30 +1773,28 @@
       <sources_sinks>
         <dc:context>
           <dc:statement>
-            SELECT id   AS anno_id,
-                   name AS anno_description
+            SELECT id AS anno_id,
+            name AS anno_description
             FROM annotation_types
-	    WHERE name LIKE 'Quelle %' OR name LIKE 'Senke %'
+            WHERE name LIKE 'Quelle %' OR name LIKE 'Senke %'
           </dc:statement>
           <dc:for-each>
-            <annotation name="{$anno_description}"
-                        factory="annotations" target_out="{$out}"
-                        ids="{$river_id}:{$anno_description}"/>
+            <annotation name="{$anno_description}" factory="annotations" target_out="{$out}" ids="{$river_id}:{$anno_description}"/>
           </dc:for-each>
         </dc:context>
       </sources_sinks>
     </dc:macro>
 
     <dc:macro name="qsectors">
-      <qsector factory="qsectors" ids="{$river_id}" target_out="{$out}" />
+      <qsector factory="qsectors" ids="{$river_id}" target_out="{$out}"/>
     </dc:macro>
 
     <dc:macro name="flood-map-recommended">
       <kilometrage>
-        <riveraxis factory="riveraxis" ids="{$river_id}" target_out="{$out}" />
+        <riveraxis factory="riveraxis" ids="{$river_id}" target_out="{$out}"/>
       </kilometrage>
       <rastermap>
-        <background factory="wmsbackground" ids="{$river_id}" target_out="{$out}" />
+        <background factory="wmsbackground" ids="{$river_id}" target_out="{$out}"/>
       </rastermap>
     </dc:macro>
 
@@ -1892,32 +1802,33 @@
     <dc:macro name="minfo-heights-diff">
       <dc:context>
         <dc:statement>
-            WITH sta
-                 AS (SELECT bhs.id,
-                            bhs.description,
-                            bhsv.station,
-                            bhs.year
-                     FROM   bed_height bhs
-                            JOIN bed_height_values bhsv
-                                ON bhsv.bed_height_id = bhs.id
-                     WHERE  bhs.river_id = ${river_id}
-                     AND bhsv.station BETWEEN ${fromkm} AND ${tokm}),
-                 csta
-                 AS (SELECT b1.id          AS b1id,
-                            b1.description AS b1desc,
-                            b1.year        AS b1year,
-                            b2.id          AS b2id,
-                            b2.description AS b2desc,
-                            b2.year        AS b2year
-                     FROM   sta b1
-                            JOIN sta b2
-                              ON b1.station = b2.station
-                              AND b1.id &lt;&gt; b2.id
-                              AND (b1.year &gt; b2.year OR b1.year IS NULL))
-            SELECT DISTINCT b1id, b1desc, b1year,
-                   b2id, b2desc, b2year
-            FROM   csta
-            ORDER BY b1desc, b2desc
+          WITH sta
+          AS (SELECT bhs.id,
+          bhs.description,
+          bhsv.station,
+          bhs.year
+          FROM bed_height bhs
+          JOIN bed_height_values bhsv
+          ON bhsv.bed_height_id = bhs.id
+          WHERE bhs.river_id = ${river_id}
+          AND bhsv.station BETWEEN ${fromkm} AND ${tokm}),
+          csta
+          AS (SELECT b1.id AS b1id,
+          b1.description AS b1desc,
+          b1.year AS b1year,
+          b2.id AS b2id,
+          b2.description AS b2desc,
+          b2.year AS b2year
+          FROM sta b1
+          JOIN sta b2
+          ON b1.station = b2.station
+          AND b1.id &lt;&gt; b2.id
+          AND (b1.year &gt; b2.year OR b1.year IS NULL))
+          SELECT
+          DISTINCT b1id, b1desc, b1year,
+          b2id, b2desc, b2year
+          FROM csta
+          ORDER BY b1desc, b2desc
         </dc:statement>
         <dc:if test="dc:has-result()">
           <bedheights>
@@ -1950,23 +1861,11 @@
           <dc:for-each>
             <dc:choose>
               <dc:when test="dc:group-key() = $b1year">
-                <height factory="bedheight"
-                        target_out="{$out}"
-                        ids="bedheight-single-{$b1id}#bedheight-single-{$b2id}"
-                        info="{$b1desc}#{$b2desc}"
-                        description="{$b1desc} - {$b2desc}"/>
+                <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b1id}#bedheight-single-{$b2id}" info="{$b1desc}#{$b2desc}" description="{$b1desc} - {$b2desc}"/>
               </dc:when>
               <dc:when test="dc:group-key() = 'sonstige'">
-                <height factory="bedheight"
-                        target_out="{$out}"
-                        ids="bedheight-single-{$b1id}#bedheight-single-{$b2id}"
-                        info="{$b1desc}#{$b2desc}"
-                        description="{$b1desc} - {$b2desc}"/>
-                <height factory="bedheight"
-                        target_out="{$out}"
-                        ids="bedheight-single-{$b2id}#bedheight-single-{$b1id}"
-                        info="{$b2desc}#{$b1desc}"
-                        description="{$b2desc} - {$b1desc}"/>
+                <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b1id}#bedheight-single-{$b2id}" info="{$b1desc}#{$b2desc}" description="{$b1desc} - {$b2desc}"/>
+                <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b2id}#bedheight-single-{$b1id}" info="{$b2desc}#{$b1desc}" description="{$b2desc} - {$b1desc}"/>
               </dc:when>
             </dc:choose>
           </dc:for-each>
@@ -1983,11 +1882,7 @@
 
     <dc:macro name="bed-heights-factory">
       <dc:for-each>
-        <height factory="bedheight"
-                target_out="{$out}"
-                ids="bedheight-single-{$bedh_id}-{$bedh_year}"
-                info="{$info}"
-                description="{$bedh_descr}"/>
+        <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$bedh_id}-{$bedh_year}" info="{$info}" description="{$bedh_descr}"/>
       </dc:for-each>
     </dc:macro>
 
@@ -2021,11 +1916,7 @@
 
     <dc:macro name="sounding-width-factory">
       <dc:for-each>
-        <height factory="bedheight"
-                target_out="{$out}"
-                ids="bedheight-soundings-{$bedh_id}-{$bedh_year}"
-                info="{$info}"
-                description="{$bedh_descr}"/>
+        <height factory="bedheight" target_out="{$out}" ids="bedheight-soundings-{$bedh_id}-{$bedh_year}" info="{$info}" description="{$bedh_descr}"/>
       </dc:for-each>
     </dc:macro>
 
@@ -2051,23 +1942,24 @@
 
     <dc:macro name="bed-heights-statement">
       <dc:statement>
-        SELECT bhs.id       AS bedh_id,
-            bhs.year        AS bedh_year,
-            bhs.description AS bedh_descr,
-            bhs.description || '&lt;BR&gt;Jahr: ' || bhs.year ||
-            '&lt;BR&gt;Aufnahmeart: ' || bht.name ||
-            '&lt;BR&gt;Lagesystem: ' || ls.name ||
-            '&lt;BR&gt;Höhensystem: ' || cur_em.name ||
-            '&lt;BR&gt;ursprüngliches Höhensystem: ' || old_em.name ||
-            '&lt;BR&gt;Strecke: ' || round(r.a, 1) || '-' || round(r.b, 1) ||
-            '&lt;BR&gt;Auswerter: ' || bhs.evaluation_by AS info
+        SELECT bhs.id AS bedh_id,
+        bhs.year AS bedh_year,
+        bhs.description AS bedh_descr,
+        bhs.description || '&lt;BR&gt;Jahr: ' || bhs.year ||
+        '&lt;BR&gt;Aufnahmeart: ' || bht.name ||
+        '&lt;BR&gt;Lagesystem: ' || ls.name ||
+        '&lt;BR&gt;Höhensystem: ' || cur_em.name ||
+        '&lt;BR&gt;ursprüngliches Höhensystem: ' || old_em.name ||
+        '&lt;BR&gt;Strecke: ' || round(r.a, 1) || '-' || round(r.b, 1) ||
+        '&lt;BR&gt;Auswerter: ' || bhs.evaluation_by AS info
         FROM bed_height bhs
-            JOIN bed_height_type bht ON bht.id = bhs.type_id
-            JOIN location_system ls ON ls.id = location_system_id
-            JOIN elevation_model cur_em ON cur_em.id = cur_elevation_model_id
-            LEFT JOIN elevation_model old_em
-                ON old_em.id = old_elevation_model_id
-            LEFT JOIN ranges r ON r.id = range_id
+        JOIN bed_height_type bht ON bht.id =
+        bhs.type_id
+        JOIN location_system ls ON ls.id = location_system_id
+        JOIN elevation_model cur_em ON cur_em.id = cur_elevation_model_id
+        LEFT JOIN elevation_model old_em
+        ON old_em.id = old_elevation_model_id
+        LEFT JOIN ranges r ON r.id = range_id
         WHERE bhs.river_id = ${river_id}
       </dc:statement>
     </dc:macro>
@@ -2076,12 +1968,12 @@
     <dc:macro name="flow_velocity_models">
       <dc:context>
         <dc:statement>
-          SELECT fvm.id             AS fvmid,
-                 fvm.description    AS fvmd,
-                 dz.gauge_name      AS gauge,
-                 dz.value           AS q,
-                 dz.upper_discharge AS upperQ,
-                 dz.lower_discharge AS lowerQ
+          SELECT fvm.id AS fvmid,
+          fvm.description AS fvmd,
+          dz.gauge_name AS gauge,
+          dz.value AS q,
+          dz.upper_discharge AS upperQ,
+          dz.lower_discharge AS lowerQ
           FROM flow_velocity_model fvm
           JOIN discharge_zone dz ON dz.id = fvm.discharge_zone_id
           WHERE dz.river_id = ${river_id}
@@ -2090,13 +1982,9 @@
         <dc:if test="dc:has-result()">
           <flowvelocitymodel>
             <dc:for-each>
-              <measurement_value name="{$fvmd}"
-                                 ids="{$fvmid}"
-                                 factory="flowvelocitymodel"
-                                 info="{$lowerQ} - {$upperQ}&lt;BR&gt;
+              <measurement_value name="{$fvmd}" ids="{$fvmid}" factory="flowvelocitymodel" info="{$lowerQ} - {$upperQ}&lt;BR&gt;
                                        Pegel {$gauge}&lt;BR&gt;
-                                       Q = {$q} m3/s"
-                                 target_out="{$out}" />
+                                       Q = {$q} m3/s" target_out="{$out}"/>
             </dc:for-each>
           </flowvelocitymodel>
         </dc:if>
@@ -2107,8 +1995,8 @@
     <dc:macro name="flow_velocity_measurements">
       <dc:context>
         <dc:statement>
-          SELECT id          AS fvmid,
-                 description AS fvmd
+          SELECT id AS fvmid,
+          description AS fvmd
           FROM flow_velocity_measurements WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
@@ -2120,12 +2008,10 @@
                     SELECT id, description, station, datetime, v, w, q
                     FROM flow_velocity_measure_values
                     WHERE measurements_id = ${fvmid}
-                      AND station BETWEEN ${fromkm} AND ${tokm}
+                    AND station BETWEEN ${fromkm} AND ${tokm}
                   </dc:statement>
                   <dc:for-each>
-                    <measurement_value name="{$description} - {$station} - {$datetime}"
-                                       ids="{$id}"
-                                       factory="flowvelocity" target_out="{$out}" />
+                    <measurement_value name="{$description} - {$station} - {$datetime}" ids="{$id}" factory="flowvelocity" target_out="{$out}"/>
                   </dc:for-each>
                 </dc:context>
               </flow_velocity_measurement>
@@ -2138,7 +2024,7 @@
     <dc:macro name="morph_width">
       <dc:context>
         <dc:statement>
-          SELECT id   AS width_id
+          SELECT id AS width_id
           FROM morphologic_width
           WHERE river_id = ${river_id}
         </dc:statement>
@@ -2148,14 +2034,12 @@
               <dc:context>
                 <dc:statement>
                   SELECT min(station) AS from_station,
-                         max(station) AS to_station
+                  max(station) AS to_station
                   FROM morphologic_width_values
                   WHERE morphologic_width_id = ${width_id}
                 </dc:statement>
                 <dc:for-each>
-                  <morphologic-width name="{$from_station} - {$to_station}"
-                                     ids="{$width_id}"
-                                     factory="morph-width" target_out="{$out}" />
+                  <morphologic-width name="{$from_station} - {$to_station}" ids="{$width_id}" factory="morph-width" target_out="{$out}"/>
                 </dc:for-each>
               </dc:context>
             </dc:for-each>
@@ -2168,12 +2052,12 @@
       <dc:context>
         <dc:statement>
           SELECT
-            ti.start_time        AS start_time,
-            ti.stop_time         AS stop_time,
-            ms.name              AS station_name,
-            lower(sqv.parameter) AS parameter,
-            sqv.id               AS sqvid,
-            ra.a                 AS station_km
+          ti.start_time AS start_time,
+          ti.stop_time AS stop_time,
+          ms.name AS station_name,
+          lower(sqv.parameter) AS parameter,
+          sqv.id AS sqvid,
+          ra.a AS station_km
           FROM sq_relation sq
           JOIN time_intervals ti ON ti.id = sq.time_interval_id
           JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id
@@ -2192,15 +2076,11 @@
                                   $station_name)">
                     <station description="{dc:group-key()}">
                       <dc:for-each>
-                        <dc:variable name="combined_desc"
-                                     expr="concat(dc:date-format('yyyy',
+                        <dc:variable name="combined_desc" expr="concat(dc:date-format('yyyy',
                                            $start_time), ' bis ',
                                            dc:date-format('yyyy',
                                            $stop_time))"/>
-                        <sqvalue factory="sqrelationdatacage"
-                                 target_out="{$out}"
-                                 ids="{$sqvid};{dc:uppercase($parameter)} - {$station_name}: {$combined_desc}"
-                                 description="{$combined_desc}"/>
+                        <sqvalue factory="sqrelationdatacage" target_out="{$out}" ids="{$sqvid};{dc:uppercase($parameter)} - {$station_name}: {$combined_desc}" description="{$combined_desc}"/>
                       </dc:for-each>
                     </station>
                   </dc:group>
@@ -2250,28 +2130,25 @@
       <dems>
         <dc:context>
           <dc:statement>
-            SELECT d.id    AS dem_id,
-                   r.a     AS dem_lower,
-                   r.b     AS dem_upper,
-                   d.name  AS name,
-                   t.start_time AS start_time,
-                   t.stop_time AS stop_time,
-                   'Projektion: ' || d.projection || '&lt;BR&gt;' ||
-                   'Rasterweite: '   || d.resolution || 'm&lt;BR&gt;' ||
-                   'Format: '  || d.format || '&lt;BR&gt;' ||
-                   'Zeitraum: '
-                   AS info
+            SELECT d.id AS dem_id,
+            r.a AS dem_lower,
+            r.b AS dem_upper,
+            d.name AS name,
+            t.start_time AS start_time,
+            t.stop_time AS stop_time,
+            'Projektion: ' || d.projection || '&lt;BR&gt;' ||
+            'Rasterweite: ' || d.resolution || 'm&lt;BR&gt;' ||
+            'Format: ' || d.format || '&lt;BR&gt;' ||
+            'Zeitraum: '
+            AS info
             FROM dem d
-              JOIN ranges r ON d.range_id = r.id
-              LEFT JOIN time_intervals t ON d.time_interval_id = t.id
-              WHERE d.river_id = ${river_id}
-              AND NOT((${tokm} &lt; r.a) or (${fromkm} &gt; r.b))
-            </dc:statement>
-            <dc:for-each>
-            <dem factory="demfactory" target_out="{$out}"
-              ids="{$dem_id}"
-              name="{$name}"
-              info="{$info}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
+            JOIN ranges r ON d.range_id = r.id
+            LEFT JOIN time_intervals t ON d.time_interval_id = t.id
+            WHERE d.river_id = ${river_id}
+            AND NOT((${tokm} &lt; r.a) or (${fromkm} &gt; r.b))
+          </dc:statement>
+          <dc:for-each>
+            <dem factory="demfactory" target_out="{$out}" ids="{$dem_id}" name="{$name}" info="{$info}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
           </dc:for-each>
         </dc:context>
       </dems>
@@ -2281,25 +2158,31 @@
       <dc:macro name="durchlass_damm_graben">
         <dc:macro name="ddg_factory">
           <dc:for-each>
-            <hws factory="hwsfactory" name="{$hws_name}" target_out="{$out}" />
+            <hws factory="hwsfactory" name="{$hws_name}" target_out="{$out}"/>
           </dc:for-each>
         </dc:macro>
 
         <dc:filter expr="$hws_kind=1">
           <dc:if test="dc:has-result()">
-            <Durchlass><dc:call-macro name="ddg_factory"/></Durchlass>
+            <Durchlass>
+              <dc:call-macro name="ddg_factory"/>
+            </Durchlass>
           </dc:if>
         </dc:filter>
 
         <dc:filter expr="$hws_kind=2">
           <dc:if test="dc:has-result()">
-            <Damm><dc:call-macro name="ddg_factory"/></Damm>
+            <Damm>
+              <dc:call-macro name="ddg_factory"/>
+            </Damm>
           </dc:if>
         </dc:filter>
 
         <dc:filter expr="$hws_kind=3">
           <dc:if test="dc:has-result()">
-            <Graben><dc:call-macro name="ddg_factory"/></Graben>
+            <Graben>
+              <dc:call-macro name="ddg_factory"/>
+            </Graben>
           </dc:if>
         </dc:filter>
       </dc:macro>
@@ -2325,9 +2208,9 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-          name     AS hws_name,
+          name AS hws_name,
           official AS hws_official,
-          kind_id  AS hws_kind
+          kind_id AS hws_kind
           FROM hws_lines
           WHERE river_id = ${river_id}
         </dc:statement>
@@ -2343,9 +2226,9 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-          name     AS hws_name,
+          name AS hws_name,
           official AS hws_official,
-          kind_id  AS hws_kind
+          kind_id AS hws_kind
           FROM hws_points
           WHERE river_id = ${river_id}
         </dc:statement>
@@ -2362,29 +2245,25 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              name
+            name
             FROM hydr_boundaries
             WHERE river_id = ${river_id}
-              AND kind = 2
+            AND kind = 2
           </dc:statement>
           <dc:for-each>
-            <line factory="wmshydrboundariesfactory" target_out="{$out}"
-                  ids="{$river_id};{$name};2"
-                  name="{$name}"/>
+            <line factory="wmshydrboundariesfactory" target_out="{$out}" ids="{$river_id};{$name};2" name="{$name}"/>
           </dc:for-each>
         </dc:context>
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              name
+            name
             FROM hydr_boundaries_poly
             WHERE river_id = ${river_id}
-              AND kind = 2
+            AND kind = 2
           </dc:statement>
           <dc:for-each>
-            <line factory="wmshydrboundariespolyfactory" target_out="{$out}"
-                  ids="{$river_id};{$name};2"
-                  name="{$name}"/>
+            <line factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$name};2" name="{$name}"/>
           </dc:for-each>
         </dc:context>
       </federal>
@@ -2394,18 +2273,16 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-            name
+          name
           FROM hydr_boundaries
           WHERE river_id = ${river_id}
-            AND kind = 1
+          AND kind = 1
         </dc:statement>
         <dc:comment> What about all other line kinds?</dc:comment>
         <dc:if test="dc:has-result()">
           <lines>
             <dc:for-each>
-              <line factory="wmshydrboundariesfactory" target_out="{$out}"
-                    ids="{$river_id};{$name};1"
-                    name="{$name}"/>
+              <line factory="wmshydrboundariesfactory" target_out="{$out}" ids="{$river_id};{$name};1" name="{$name}"/>
             </dc:for-each>
           </lines>
         </dc:if>
@@ -2417,19 +2294,17 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              b.sectie AS sectie_id,
-              sk.name AS sectie
+            b.sectie AS sectie_id,
+            sk.name AS sectie
             FROM hydr_boundaries_poly b
-              JOIN sectie_kinds sk ON b.sectie = sk.id
+            JOIN sectie_kinds sk ON b.sectie = sk.id
             WHERE b.river_id = ${river_id}
-              AND b.kind = 1
+            AND b.kind = 1
           </dc:statement>
           <dc:if test="dc:has-result()">
             <sobek_areas>
               <dc:for-each>
-                <boundary name="{$sectie}"
-                          factory="wmshydrboundariespolyfactory" target_out="{$out}"
-                          ids="{$river_id};{$sectie};1;{$sectie_id};-1"/>
+                <boundary name="{$sectie}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$sectie};1;{$sectie_id};-1"/>
               </dc:for-each>
             </sobek_areas>
           </dc:if>
@@ -2437,19 +2312,17 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              b.sobek AS sobek_id,
-              sk.name AS sobek
+            b.sobek AS sobek_id,
+            sk.name AS sobek
             FROM hydr_boundaries_poly b
-              JOIN sobek_kinds sk ON b.sobek = sk.id
+            JOIN sobek_kinds sk ON b.sobek = sk.id
             WHERE b.river_id = ${river_id}
-              AND b.kind = 1
+            AND b.kind = 1
           </dc:statement>
           <dc:if test="dc:has-result()">
             <sobek_flooded>
               <dc:for-each>
-                <boundary name="{$sobek}"
-                          factory="wmshydrboundariespolyfactory" target_out="{$out}"
-                          ids="{$river_id};{$sobek};1;-1;{$sobek_id}"/>
+                <boundary name="{$sobek}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$sobek};1;-1;{$sobek_id}"/>
               </dc:for-each>
             </sobek_flooded>
           </dc:if>
@@ -2457,17 +2330,15 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              b.name AS name
+            b.name AS name
             FROM hydr_boundaries_poly b
             WHERE b.river_id = ${river_id}
-              AND b.kind = 1
-              AND b.sobek IS NULL
-              AND b.sectie is NULL
+            AND b.kind = 1
+            AND b.sobek IS NULL
+            AND b.sectie is NULL
           </dc:statement>
           <dc:for-each>
-            <boundary name="{$name}"
-                      factory="wmshydrboundariespolyfactory" target_out="{$out}"
-                      ids="{$river_id};{$name}"/>
+            <boundary name="{$name}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$name}"/>
           </dc:for-each>
         </dc:context>
       </areas>
@@ -2479,126 +2350,116 @@
           SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
-        <uesk>
-          <calculations>
-            <dc:context>
-              <dc:statement>
-                SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
-                AND (kind = 112 OR kind = 111)
-              </dc:statement>
-              <dc:if test="dc:has-result()">
-                <current>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT DISTINCT name AS name
-                      FROM floodmaps
-                      WHERE river_id = ${river_id} AND kind = 111
-                    </dc:statement>
-                    <dc:if test="dc:has-result()">
-                      <bfg>
-                        <dc:for-each>
-                          <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}"
-                            ids="{$river_id};{$name}"
-                            name="{$name}"/>
-                        </dc:for-each>
-                      </bfg>
-                    </dc:if>
-                  </dc:context>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT DISTINCT name AS name
-                      FROM floodmaps
-                      WHERE river_id = ${river_id} AND kind = 112
-                    </dc:statement>
-                    <dc:if test="dc:has-result()">
-                      <federal>
-                        <dc:for-each>
-                          <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}"
-                            ids="{$river_id};{$name}"
-                            name="{$name}"/>
-                        </dc:for-each>
-                      </federal>
-                    </dc:if>
-                  </dc:context>
-                </current>
-              </dc:if>
-            </dc:context>
-            <dc:context>
-              <dc:statement>
-                SELECT DISTINCT 1 from floodmaps where river_id = ${river_id}
-                AND (kind = 122 OR kind = 121)
-              </dc:statement>
-              <dc:if test="dc:has-result()">
-                <potential>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT DISTINCT name AS name
-                      FROM floodmaps
-                      WHERE river_id = ${river_id} AND kind = 121
-                    </dc:statement>
-                    <dc:if test="dc:has-result()">
-                      <bfg>
-                        <dc:for-each>
-                          <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}"
-                            ids="{$river_id};{$name}"
-                            name="{$name}"/>
-                        </dc:for-each>
-                      </bfg>
-                    </dc:if>
-                  </dc:context>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT DISTINCT
-                        name AS name
-                      FROM floodmaps
-                      WHERE river_id = ${river_id} AND kind = 122
-                    </dc:statement>
-                    <dc:if test="dc:has-result()">
-                      <federal>
-                        <dc:for-each>
-                          <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}"
-                            ids="{$river_id};{$name}"
-                            name="{$name}"/>
-                        </dc:for-each>
-                      </federal>
-                    </dc:if>
-                  </dc:context>
-                </potential>
-              </dc:if>
-            </dc:context>
-          </calculations>
-          <dc:context>
-            <dc:statement>
-              SELECT DISTINCT
-                source AS source
-              FROM floodmaps
-              WHERE river_id = ${river_id} AND kind = 200
-            </dc:statement>
-            <dc:if test="dc:has-result()">
-              <measurements>
-                <dc:for-each>
-                  <year name="{$source}">
+          <uesk>
+            <calculations>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
+                  AND (kind = 112 OR kind = 111)
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <current>
+                    <dc:context>
+                      <dc:statement>
+                        SELECT DISTINCT name AS name
+                        FROM floodmaps
+                        WHERE river_id = ${river_id} AND kind = 111
+                      </dc:statement>
+                      <dc:if test="dc:has-result()">
+                        <bfg>
+                          <dc:for-each>
+                            <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}"/>
+                          </dc:for-each>
+                        </bfg>
+                      </dc:if>
+                    </dc:context>
+                    <dc:context>
+                      <dc:statement>
+                        SELECT DISTINCT name AS name
+                        FROM floodmaps
+                        WHERE river_id = ${river_id} AND kind = 112
+                      </dc:statement>
+                      <dc:if test="dc:has-result()">
+                        <federal>
+                          <dc:for-each>
+                            <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}"/>
+                          </dc:for-each>
+                        </federal>
+                      </dc:if>
+                    </dc:context>
+                  </current>
+                </dc:if>
+              </dc:context>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT 1 from floodmaps where river_id = ${river_id}
+                  AND (kind = 122 OR kind = 121)
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <potential>
+                    <dc:context>
+                      <dc:statement>
+                        SELECT DISTINCT name AS name
+                        FROM floodmaps
+                        WHERE river_id = ${river_id} AND kind = 121
+                      </dc:statement>
+                      <dc:if test="dc:has-result()">
+                        <bfg>
+                          <dc:for-each>
+                            <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}"/>
+                          </dc:for-each>
+                        </bfg>
+                      </dc:if>
+                    </dc:context>
                     <dc:context>
                       <dc:statement>
                         SELECT DISTINCT
-                          name AS name
+                        name AS name
                         FROM floodmaps
-                        WHERE river_id = ${river_id} AND kind = 200 AND source =
-                        ${source}
+                        WHERE river_id = ${river_id} AND kind = 122
                       </dc:statement>
-                      <dc:for-each>
-                        <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}"
-                          ids="{$river_id};{$name}"
-                          name="{$name}"/>
-                      </dc:for-each>
+                      <dc:if test="dc:has-result()">
+                        <federal>
+                          <dc:for-each>
+                            <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}"/>
+                          </dc:for-each>
+                        </federal>
+                      </dc:if>
                     </dc:context>
-                  </year>
-                </dc:for-each>
-              </measurements>
-            </dc:if>
-          </dc:context>
-        </uesk>
-      </dc:if>
+                  </potential>
+                </dc:if>
+              </dc:context>
+            </calculations>
+            <dc:context>
+              <dc:statement>
+                SELECT DISTINCT
+                source AS source
+                FROM floodmaps
+                WHERE river_id = ${river_id} AND kind = 200
+              </dc:statement>
+              <dc:if test="dc:has-result()">
+                <measurements>
+                  <dc:for-each>
+                    <year name="{$source}">
+                      <dc:context>
+                        <dc:statement>
+                          SELECT DISTINCT
+                          name AS name
+                          FROM floodmaps
+                          WHERE river_id = ${river_id} AND kind = 200 AND source =
+                          ${source}
+                        </dc:statement>
+                        <dc:for-each>
+                          <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}"/>
+                        </dc:for-each>
+                      </dc:context>
+                    </year>
+                  </dc:for-each>
+                </measurements>
+              </dc:if>
+            </dc:context>
+          </uesk>
+        </dc:if>
       </dc:context>
     </dc:macro>
 
@@ -2606,28 +2467,24 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-            fp.kind_id AS kind_id,
-            flk.name AS kind_name
+          fp.kind_id AS kind_id,
+          flk.name AS kind_name
           FROM floodplain fp
-            JOIN floodplain_kinds flk on fp.kind_id = flk.id
+          JOIN floodplain_kinds flk on fp.kind_id = flk.id
           WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
           <floodplain>
             <dc:filter expr="$kind_id=1">
               <dc:for-each>
-                <floody factory="wmsfloodplainfactory" target_out="{$out}"
-                        description="{$kind_name}"
-                        ids="{$river_id};{$kind_name};{$kind_id}"/>
+                <floody factory="wmsfloodplainfactory" target_out="{$out}" description="{$kind_name}" ids="{$river_id};{$kind_name};{$kind_id}"/>
               </dc:for-each>
             </dc:filter>
             <dc:filter expr="$kind_id != 1">
               <dc:if test="dc:has-result()">
                 <other>
                   <dc:for-each>
-                    <floody factory="wmsfloodplainfactory" target_out="{$out}"
-                            description="{$layer_name}"
-                            ids="{$river_id};{$layer_name};{$kind_id}"/>
+                    <floody factory="wmsfloodplainfactory" target_out="{$out}" description="{$layer_name}" ids="{$river_id};{$layer_name};{$kind_id}"/>
                   </dc:for-each>
                 </other>
               </dc:if>
@@ -2645,9 +2502,7 @@
 
       <dc:macro name="hwspoints_by_kind_factory">
         <dc:for-each>
-          <hws factory="wmshwspointsfactory" target_out="{$out}"
-               ids="{$river_id};{$hws_name}"
-               name="{$hws_name}"/>
+          <hws factory="wmshwspointsfactory" target_out="{$out}" ids="{$river_id};{$hws_name}" name="{$hws_name}"/>
         </dc:for-each>
       </dc:macro>
 
@@ -2682,23 +2537,23 @@
           <dc:context>
             <dc:statement>
               SELECT DISTINCT
-                fs.name AS fed_name,
-                fs.id AS fed_id
+              fs.name AS fed_name,
+              fs.id AS fed_id
               FROM hws_points hws
-                JOIN fed_states fs ON hws.fed_state_id = fs.id
+              JOIN fed_states fs ON hws.fed_state_id = fs.id
               WHERE river_id = ${river_id}
-                AND hws.official=1
+              AND hws.official=1
             </dc:statement>
             <dc:for-each>
               <dc:context>
                 <dc:statement>
                   SELECT DISTINCT
-                    name AS hws_name,
-                    kind_id AS hws_kind
+                  name AS hws_name,
+                  kind_id AS hws_kind
                   FROM hws_points
                   WHERE river_id = ${river_id}
-                    AND official=1
-                    AND fed_state_id = ${fed_id} ORDER BY name
+                  AND official=1
+                  AND fed_state_id = ${fed_id} ORDER BY name
                 </dc:statement>
                 <fedstate description="{$fed_name}">
                   <dc:call-macro name="hwspoints_by_kind"/>
@@ -2709,13 +2564,13 @@
           <dc:context>
             <dc:statement>
               SELECT distinct
-                name AS hws_name,
-                kind_id AS hws_kind
+              name AS hws_name,
+              kind_id AS hws_kind
               FROM hws_points
               WHERE river_id = ${river_id}
-                AND official=1
-                AND fed_state_id IS NULL
-                ORDER BY name
+              AND official=1
+              AND fed_state_id IS NULL
+              ORDER BY name
             </dc:statement>
             <hws_fed_unknown>
               <dc:call-macro name="hwspoints_by_kind"/>
@@ -2726,23 +2581,23 @@
           <dc:context>
             <dc:statement>
               SELECT DISTINCT
-                fs.name AS fed_name,
-                fs.id AS fed_id
+              fs.name AS fed_name,
+              fs.id AS fed_id
               FROM hws_points hws
-                JOIN fed_states fs ON hws.fed_state_id = fs.id
+              JOIN fed_states fs ON hws.fed_state_id = fs.id
               WHERE river_id = ${river_id}
-                AND hws.official=0
+              AND hws.official=0
             </dc:statement>
             <dc:for-each>
               <dc:context>
                 <dc:statement>
                   SELECT DISTINCT
-                    name AS hws_name,
-                    kind_id AS hws_kind
+                  name AS hws_name,
+                  kind_id AS hws_kind
                   FROM hws_points
                   WHERE river_id = ${river_id}
-                    AND official=0
-                    AND fed_state_id = ${fed_id} ORDER BY name
+                  AND official=0
+                  AND fed_state_id = ${fed_id} ORDER BY name
                 </dc:statement>
                 <fedstate description="{$fed_name}">
                   <dc:call-macro name="hwspoints_by_kind"/>
@@ -2753,12 +2608,12 @@
           <dc:context>
             <dc:statement>
               SELECT distinct
-                name AS hws_name,
-                kind_id AS hws_kind
+              name AS hws_name,
+              kind_id AS hws_kind
               FROM hws_points
               WHERE river_id = ${river_id}
-                AND official=0
-                AND fed_state_id IS NULL ORDER BY name
+              AND official=0
+              AND fed_state_id IS NULL ORDER BY name
             </dc:statement>
             <hws_fed_unknown>
               <dc:call-macro name="hwspoints_by_kind"/>
@@ -2776,9 +2631,7 @@
 
       <dc:macro name="hwslines_by_kind_factory">
         <dc:for-each>
-          <hws factory="wmshwslinesfactory" target_out="{$out}"
-               ids="{$river_id};{$hws_name}"
-               name="{$hws_name}"/>
+          <hws factory="wmshwslinesfactory" target_out="{$out}" ids="{$river_id};{$hws_name}" name="{$hws_name}"/>
         </dc:for-each>
       </dc:macro>
 
@@ -2813,23 +2666,23 @@
           <dc:context>
             <dc:statement>
               SELECT DISTINCT
-                fs.name AS fed_name,
-                fs.id AS fed_id
+              fs.name AS fed_name,
+              fs.id AS fed_id
               FROM hws_lines hws
-                JOIN fed_states fs ON hws.fed_state_id = fs.id
+              JOIN fed_states fs ON hws.fed_state_id = fs.id
               WHERE river_id = ${river_id}
-                AND hws.official=1
+              AND hws.official=1
             </dc:statement>
             <dc:for-each>
               <dc:context>
                 <dc:statement>
                   SELECT DISTINCT
-                    name AS hws_name,
-                    kind_id AS hws_kind
+                  name AS hws_name,
+                  kind_id AS hws_kind
                   FROM hws_lines
                   WHERE river_id = ${river_id}
-                    AND official=1
-                    AND fed_state_id = ${fed_id} ORDER BY name
+                  AND official=1
+                  AND fed_state_id = ${fed_id} ORDER BY name
                 </dc:statement>
                 <fedstate description="{$fed_name}">
                   <dc:call-macro name="hwslines_by_kind"/>
@@ -2840,13 +2693,13 @@
           <dc:context>
             <dc:statement>
               SELECT distinct
-                name AS hws_name,
-                kind_id AS hws_kind
+              name AS hws_name,
+              kind_id AS hws_kind
               FROM hws_lines
               WHERE river_id = ${river_id}
-                AND official=1
-                AND fed_state_id IS NULL
-                ORDER BY name
+              AND official=1
+              AND fed_state_id IS NULL
+              ORDER BY name
             </dc:statement>
             <hws_fed_unknown>
               <dc:call-macro name="hwslines_by_kind"/>
@@ -2857,23 +2710,23 @@
           <dc:context>
             <dc:statement>
               SELECT DISTINCT
-                fs.name AS fed_name,
-                fs.id AS fed_id
+              fs.name AS fed_name,
+              fs.id AS fed_id
               FROM hws_lines hws
-                JOIN fed_states fs ON hws.fed_state_id = fs.id
+              JOIN fed_states fs ON hws.fed_state_id = fs.id
               WHERE river_id = ${river_id}
-                AND hws.official=0
+              AND hws.official=0
             </dc:statement>
             <dc:for-each>
               <dc:context>
                 <dc:statement>
                   SELECT DISTINCT
-                    name AS hws_name,
-                    kind_id AS hws_kind
+                  name AS hws_name,
+                  kind_id AS hws_kind
                   FROM hws_lines
                   WHERE river_id = ${river_id}
-                    AND official=0
-                    AND fed_state_id = ${fed_id} ORDER BY name
+                  AND official=0
+                  AND fed_state_id = ${fed_id} ORDER BY name
                 </dc:statement>
                 <fedstate description="{$fed_name}">
                   <dc:call-macro name="hwslines_by_kind"/>
@@ -2884,12 +2737,12 @@
           <dc:context>
             <dc:statement>
               SELECT distinct
-                name AS hws_name,
-                kind_id AS hws_kind
+              name AS hws_name,
+              kind_id AS hws_kind
               FROM hws_lines
               WHERE river_id = ${river_id}
-                AND official=0
-                AND fed_state_id IS NULL ORDER BY name
+              AND official=0
+              AND fed_state_id IS NULL ORDER BY name
             </dc:statement>
             <hws_fed_unknown>
               <dc:call-macro name="hwslines_by_kind"/>
@@ -2903,16 +2756,14 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-            COALESCE(CAST (year AS VARCHAR(64)), 'Unbekanntes Jahr') AS year
+          COALESCE(CAST (year AS VARCHAR(64)), 'Unbekanntes Jahr') AS year
           FROM flood_marks
           WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
           <floodmarks>
             <dc:for-each>
-              <floodmark name="{$year}"
-                factory="wmsfloodmarkfactory" target_out="{$out}"
-                ids="{$river_id};{$year};{$year}"/>
+              <floodmark name="{$year}" factory="wmsfloodmarkfactory" target_out="{$out}" ids="{$river_id};{$year};{$year}"/>
             </dc:for-each>
           </floodmarks>
         </dc:if>
@@ -2921,10 +2772,10 @@
 
     <dc:macro name="flood-map-gaugelocations">
       <gaugelocations>
-        <gauge_points factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelpunkte;Pegelpunkte (WSV)" target_out="{$out}" />
-        <gauge_names factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelnamen;Pegelnamen (WSV)" target_out="{$out}" />
-        <gauge_level factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelwasserstand;Aktueller Wasserstand (WSV)" target_out="{$out}" />
-        <gauge_tendency factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;TendenzWasserstand;Tendenz des Wasserstands (WSV)" target_out="{$out}" />
+        <gauge_points factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelpunkte;Pegelpunkte (WSV)" target_out="{$out}"/>
+        <gauge_names factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelnamen;Pegelnamen (WSV)" target_out="{$out}"/>
+        <gauge_level factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelwasserstand;Aktueller Wasserstand (WSV)" target_out="{$out}"/>
+        <gauge_tendency factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;TendenzWasserstand;Tendenz des Wasserstands (WSV)" target_out="{$out}"/>
       </gaugelocations>
     </dc:macro>
 
@@ -2932,28 +2783,24 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-            ak.name    AS kind_name,
-            ax.kind_id AS kind_id,
-            ax.name    AS layer_name
+          ak.name AS kind_name,
+          ax.kind_id AS kind_id,
+          ax.name AS layer_name
           FROM river_axes ax
-            JOIN axis_kinds ak on ax.kind_id = ak.id
+          JOIN axis_kinds ak on ax.kind_id = ak.id
           WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
           <axis>
             <dc:filter expr="$kind_id=1">
               <dc:for-each>
-                <actual description="{$kind_name}"
-                        ids="{$river_id};{$kind_name};{$kind_id}"
-                        factory="riveraxis" target_out="{$out}" />
+                <actual description="{$kind_name}" ids="{$river_id};{$kind_name};{$kind_id}" factory="riveraxis" target_out="{$out}"/>
               </dc:for-each>
             </dc:filter>
             <dc:filter expr="$kind_id!=1">
               <other>
                 <dc:for-each>
-                  <misc-axis description="{$layer_name}"
-                             ids="{$river_id};{$layer_name};{$kind_id}"
-                             factory="riveraxis" target_out="{$out}" />
+                  <misc-axis description="{$layer_name}" ids="{$river_id};{$layer_name};{$kind_id}" factory="riveraxis" target_out="{$out}"/>
                 </dc:for-each>
               </other>
             </dc:filter>
@@ -2967,8 +2814,8 @@
         <dc:statement>
           SELECT DISTINCT 1 FROM river_axes_km WHERE river_id = ${river_id}
         </dc:statement>
-         <dc:for-each>
-            <kilometrage factory="wmskmfactory" ids="{$river_id}" target_out="{$out}" />
+        <dc:for-each>
+          <kilometrage factory="wmskmfactory" ids="{$river_id}" target_out="{$out}"/>
         </dc:for-each>
       </dc:context>
     </dc:macro>
@@ -2979,11 +2826,10 @@
           SELECT name AS name
           FROM fixpoints
           WHERE river_id = ${river_id}
-            GROUP BY name
+          GROUP BY name
         </dc:statement>
         <dc:for-each>
-          <fixpoints factory="wmsfixpointsfactory" target_out="{$out}"
-            ids="{$river_id};{$name}"/>
+          <fixpoints factory="wmsfixpointsfactory" target_out="{$out}" ids="{$river_id};{$name}"/>
         </dc:for-each>
       </dc:context>
     </dc:macro>
@@ -2992,29 +2838,25 @@
       <dc:context>
         <dc:statement>
           SELECT DISTINCT
-            cs.kind_id AS kind_id,
-            cs.name    AS layer_name,
-            ck.name    AS kind_name
+          cs.kind_id AS kind_id,
+          cs.name AS layer_name,
+          ck.name AS kind_name
           FROM cross_section_tracks cs
-            JOIN cross_section_track_kinds ck ON cs.kind_id = ck.id
+          JOIN cross_section_track_kinds ck ON cs.kind_id = ck.id
           WHERE river_id = ${river_id}
         </dc:statement>
         <dc:if test="dc:has-result()">
           <qps>
             <dc:filter expr="$kind_id=1">
               <dc:for-each>
-                <actual description="{$kind_name}"
-                        factory="wmsqpsfactory" target_out="{$out}"
-                        ids="{$river_id};{$kind_name};{$kind_id}"/>
+                <actual description="{$kind_name}" factory="wmsqpsfactory" target_out="{$out}" ids="{$river_id};{$kind_name};{$kind_id}"/>
               </dc:for-each>
             </dc:filter>
             <dc:filter expr="$kind_id = 0">
               <dc:if test="dc:has-result()">
                 <other>
                   <dc:for-each>
-                    <misc-qps description="{$layer_name}"
-                              factory="wmsqpsfactory" target_out="{$out}"
-                              ids="{$river_id};{$layer_name};{$kind_id}"/>
+                    <misc-qps description="{$layer_name}" factory="wmsqpsfactory" target_out="{$out}" ids="{$river_id};{$layer_name};{$kind_id}"/>
                   </dc:for-each>
                 </other>
               </dc:if>
@@ -3029,27 +2871,23 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              b.name AS building_name,
-              bk.name AS building_kind,
-              b.kind_id AS building_kind_id
+            b.name AS building_name,
+            bk.name AS building_kind,
+            b.kind_id AS building_kind_id
             FROM buildings b
-              JOIN building_kinds bk ON b.kind_id = bk.id
+            JOIN building_kinds bk ON b.kind_id = bk.id
             WHERE river_id = ${river_id}
           </dc:statement>
           <dc:if test="dc:has-result()">
             <dc:filter expr="$building_kind_id!=0">
               <dc:for-each>
-                <buildings description="{$building_kind}"
-                           factory="wmsbuildingsfactory" target_out="{$out}"
-                           ids="{$river_id};{$building_kind};{$building_kind_id}"/>
+                <buildings description="{$building_kind}" factory="wmsbuildingsfactory" target_out="{$out}" ids="{$river_id};{$building_kind};{$building_kind_id}"/>
               </dc:for-each>
             </dc:filter>
             <dc:filter expr="$building_kind_id=0">
               <other>
                 <dc:for-each>
-                  <buildings description="{$building_name}"
-                             factory="wmsbuildingsfactory" target_out="{$out}"
-                             ids="{$river_id};{$building_name}"/>
+                  <buildings description="{$building_name}" factory="wmsbuildingsfactory" target_out="{$out}" ids="{$river_id};{$building_name}"/>
                 </dc:for-each>
               </other>
             </dc:filter>
@@ -3058,18 +2896,16 @@
         <dc:context>
           <dc:statement>
             SELECT DISTINCT
-              j.kind_id AS jetty_kind_id,
-              jk.name AS jetty_kind
+            j.kind_id AS jetty_kind_id,
+            jk.name AS jetty_kind
             FROM jetties j
-              JOIN jetty_kinds jk ON j.kind_id = jk.id
+            JOIN jetty_kinds jk ON j.kind_id = jk.id
             WHERE river_id = ${river_id}
           </dc:statement>
           <dc:if test="dc:has-result()">
             <jetties>
               <dc:for-each>
-                <jetty description="{$jetty_kind}"
-                       factory="wmsjettiesfactory" target_out="{$out}"
-                       ids="{$river_id};{$jetty_kind};{$jetty_kind_id}"/>
+                <jetty description="{$jetty_kind}" factory="wmsjettiesfactory" target_out="{$out}" ids="{$river_id};{$jetty_kind};{$jetty_kind_id}"/>
               </dc:for-each>
             </jetties>
           </dc:if>
@@ -3088,9 +2924,7 @@
           <dc:if test="dc:has-result()">
             <officiallines>
               <dc:for-each>
-                <column name="{$olname}"
-                  ids="official-wstv-{$wstcolpos}-{$wstid}"
-                  factory="staticwqkms" target_out="{$out}"/>
+                <column name="{$olname}" ids="official-wstv-{$wstcolpos}-{$wstid}" factory="staticwqkms" target_out="{$out}"/>
               </dc:for-each>
             </officiallines>
           </dc:if>
@@ -3101,19 +2935,14 @@
     <!-- sediment loads -->
     <dc:macro name="sedimentload_off_epoch_filter">
       <dc:if test="dc:has-result()">
-        <dc:variable name="sq_time_id" type="number"
-                     expr="number($sq_ti_id)"/>
+        <dc:variable name="sq_time_id" type="number" expr="number($sq_ti_id)"/>
         <dc:if test="string-length(dc:get('epochs')) &gt; 0">
-          <dc:variable name="start" type="number"
-                       expr="dc:min-number(dc:find-all('\d{4}', $epochs))"/>
-          <dc:variable name="end" type="number"
-                       expr="dc:max-number(dc:find-all('\d{4}', $epochs))"/>
+          <dc:variable name="start" type="number" expr="dc:min-number(dc:find-all('\d{4}', $epochs))"/>
+          <dc:variable name="end" type="number" expr="dc:max-number(dc:find-all('\d{4}', $epochs))"/>
         </dc:if>
         <dc:if test="string-length(dc:get('years')) &gt; 0">
-          <dc:variable name="start" type="number"
-                       expr="dc:min-number(dc:find-all('\d{4}', $years))"/>
-          <dc:variable name="end" type="number"
-                       expr="dc:max-number(dc:find-all('\d{4}', $years))"/>
+          <dc:variable name="start" type="number" expr="dc:min-number(dc:find-all('\d{4}', $years))"/>
+          <dc:variable name="end" type="number" expr="dc:max-number(dc:find-all('\d{4}', $years))"/>
         </dc:if>
         <dc:filter expr="$kind = 'official' and
                          $sqid = $sq_time_id and
@@ -3151,63 +2980,64 @@
     <dc:macro name="km-filtered-wsts">
       <dc:context connection="system">
         <dc:statement>
-          SELECT w.kind         AS kind,
-                 w.id           AS wst_id,
-                 wc.id          AS wst_column_id,
-                 wc.position    AS wst_column_position,
-                 wc.description AS info,
-                 w.description  AS wst_description,
-                 COALESCE(wc.name, '')        AS wst_column_name,
-                 wr.a           AS deffrom,
-                 wr.b           AS defto
+          SELECT w.kind AS kind,
+          w.id AS wst_id,
+          wc.id AS wst_column_id,
+          wc.position AS wst_column_position,
+          wc.description AS info,
+          w.description AS wst_description,
+          COALESCE(wc.name, '') AS wst_column_name,
+          wr.a AS deffrom,
+          wr.b AS defto
           FROM wst_columns wc
-            JOIN wsts w        ON wc.wst_id = w.id
-            JOIN wst_ranges wr ON wc.id = wr.wst_column_id
+          JOIN wsts w ON wc.wst_id = w.id
+          JOIN wst_ranges wr ON wc.id = wr.wst_column_id
           WHERE w.river_id = ${river_id} AND
-            NOT((${tokm} &lt; wr.a) or (${fromkm} &gt; wr.b))
-            ORDER BY wst_column_position
+          NOT((${tokm} &lt; wr.a) or (${fromkm} &gt; wr.b))
+          ORDER BY wst_column_position
         </dc:statement>
         <dc:macro-body/>
       </dc:context>
     </dc:macro>
 
     <dc:macro name="all-user-artifacts">
-        <dc:context connection="user">
-          <dc:comment>Select collections and masterartifacts.
-            XXX: The cast is a quick hack because the ld_* values are
-            now TEXT fields. To properly fix / asses the problems here
-            an SLT evaluation is needed.
-          </dc:comment>
+      <dc:context connection="user">
+        <dc:comment>Select collections and masterartifacts.
+          XXX: The cast is a quick hack because the ld_* values are
+          now TEXT fields. To properly fix / asses the problems here
+          an SLT evaluation is needed.
+        </dc:comment>
         <dc:statement>
-          SELECT c.name                     AS collection_name,
-                 ma.id                      AS a_id,
-                 ma.state                   AS a_state,
-                 ma.gid                     AS a_gid,
-                 ma.creation                AS a_creation,
-                 CAST(COALESCE(ma.ld_mode, '') AS VARCHAR(255)) AS ld_m,
-                 CAST(COALESCE(ma.ld_locations, '') AS VARCHAR(255)) AS ld_l,
-                 CAST(COALESCE(ma.ld_from, '') AS VARCHAR(255)) AS ld_f,
-                 CAST(COALESCE(ma.ld_to, '') AS VARCHAR(255)) AS ld_t,
-                 o.name                        AS out_name,
-                 o.id                          AS out_id,
-                 f.name                        AS facet_name,
-                 f.num                         AS facet_num,
-                 f.description                 AS facet_description,
-                 f.id                          AS fid
+          SELECT c.name AS collection_name,
+          ma.id AS a_id,
+          ma.state AS a_state,
+          ma.gid AS a_gid,
+          ma.creation AS a_creation,
+          CAST(COALESCE(ma.ld_mode, '') AS VARCHAR(255)) AS ld_m,
+          CAST(COALESCE(ma.ld_locations, '') AS VARCHAR(255)) AS ld_l,
+          CAST(COALESCE(ma.ld_from, '') AS VARCHAR(255)) AS ld_f,
+          CAST(COALESCE(ma.ld_to, '') AS VARCHAR(255)) AS ld_t,
+          o.name AS out_name,
+          o.id AS out_id,
+          f.name AS facet_name,
+          f.num AS facet_num,
+          f.description AS facet_description,
+          f.id AS fid
           FROM users u
-            JOIN collections c             ON c.user_id = u.id
-            JOIN master_artifacts_range ma ON ma.collection_id = c.id
-            JOIN outs o                    ON o.artifact_id = ma.id
-            JOIN facets f                  ON f.out_id = o.id
-          WHERE  u.gid = CAST(${user-id} AS UUID)
-            AND ma.gid &lt;&gt; CAST(${artifact-id} AS uuid)
-            AND f.name NOT LIKE '%empty.facet%'
-            AND EXISTS (
-              SELECT id
-              FROM artifact_data ad
-              WHERE ad.artifact_id = ma.id
-                AND k = 'river'
-                AND v = ${river})
+          JOIN
+          collections c ON c.user_id = u.id
+          JOIN master_artifacts_range ma ON ma.collection_id = c.id
+          JOIN outs o ON o.artifact_id = ma.id
+          JOIN facets f ON f.out_id = o.id
+          WHERE u.gid = CAST(${user-id} AS UUID)
+          AND ma.gid &lt;&gt; CAST(${artifact-id} AS uuid)
+          AND f.name NOT LIKE '%empty.facet%'
+          AND EXISTS (
+          SELECT id
+          FROM artifact_data ad
+          WHERE ad.artifact_id = ma.id
+          AND k = 'river'
+          AND v = ${river})
         </dc:statement>
         <dc:virtual-column name="deffrom" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)">
           <dc:virtual-column name="defto" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)">
@@ -3231,27 +3061,21 @@
     <dc:macro name="artifact-range">
       <dc:choose>
         <dc:when test="dc:coalesce(dc:get('ld_locations'), ' ') != ' '">
-          <dc:variable name="fromkm" type="number"
-                       expr="dc:min-number(dc:find-all('\d*\.?\d*',
+          <dc:variable name="fromkm" type="number" expr="dc:min-number(dc:find-all('\d*\.?\d*',
                              dc:get('ld_locations')))"/>
-          <dc:variable name="tokm" type="number"
-                       expr="dc:max-number(dc:find-all('\d*\.?\d*',
+          <dc:variable name="tokm" type="number" expr="dc:max-number(dc:find-all('\d*\.?\d*',
                              dc:get('ld_locations')))"/>
         </dc:when>
         <dc:otherwise>
-          <dc:variable name="fromkm" type="number"
-                       expr="dc:fromValue(dc:get('ld_mode'),
+          <dc:variable name="fromkm" type="number" expr="dc:fromValue(dc:get('ld_mode'),
                              dc:get('ld_locations'), dc:get('ld_from'))"/>
-          <dc:variable name="tokm" type="number"
-                       expr="dc:toValue(dc:get('ld_mode'),
+          <dc:variable name="tokm" type="number" expr="dc:toValue(dc:get('ld_mode'),
                              dc:get('ld_locations'), dc:get('ld_to'))"/>
           <dc:if test="$fromkm > $tokm">
             <dc:message>Inverting KM filter.</dc:message>
-            <dc:variable name="fromkm" type="number"
-                         expr="dc:toValue(dc:get('ld_mode'),
+            <dc:variable name="fromkm" type="number" expr="dc:toValue(dc:get('ld_mode'),
                                dc:get('ld_locations'), dc:get('ld_to'))"/>
-            <dc:variable name="tokm" type="number"
-                         expr="dc:fromValue(dc:get('ld_mode'),
+            <dc:variable name="tokm" type="number" expr="dc:fromValue(dc:get('ld_mode'),
                                dc:get('ld_locations'), dc:get('ld_from'))"/>
           </dc:if>
         </dc:otherwise>
@@ -3260,7 +3084,8 @@
     </dc:macro>
 
     <dc:macro name="sinfo_flowdepths">
-      <dc:filter expr="($out_name = 'sinfo_flow_depth' and ($facet_name = 'sinfo_flow_depth.filtered' or $facet_name = 'sinfo_flow_depth.tkh.filtered' ) )">
+      <!-- dc:filter expr="($out_name = 'sinfo_flow_depth' and ($facet_name = 'sinfo_flow_depth.filtered' or $facet_name = 'sinfo_flow_depth.tkh.filtered' ) )" -->
+      <dc:filter expr="( $facet_name = 'sinfo_facet_flow_depth.filtered' or $facet_name = 'sinfo_facet_flow_depth_with_tkh.filtered' )">
         <dc:if test="dc:has-result()">
           <sinfo_flow_depths>
             <dc:call-macro name="collection-group">
@@ -3283,7 +3108,7 @@
     </dc:macro>
 
     <dc:macro name="sinfo_tkh">
-      <dc:filter expr="($out_name = 'sinfo_flow_depth' and $facet_name = 'sinfo_flow_depth.tkh')">
+      <dc:filter expr="$facet_name = 'sinfo_facet_tkh' or $facet_name = 'sinfo_facet_tkh'">
         <dc:if test="dc:has-result()">
           <sinfo_tkhs>
             <dc:call-macro name="collection-group">
@@ -3305,5 +3130,76 @@
       </dc:filter>
     </dc:macro>
 
+    <dc:macro name="sinfo_tkh_velocity">
+      <dc:filter expr="starts-with( $facet_name , 'sinfo_facet_velocity.filtered' )">
+        <dc:if test="dc:has-result()">
+          <sinfo_velocities>
+            <dc:call-macro name="collection-group">
+              <sinfo_velocity description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="sinfo"/>
+                    <dc:attribute name="target_out" value="${out}"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="${out_name}"/>
+                  </dc:element>
+                </dc:for-each>
+              </sinfo_velocity>
+            </dc:call-macro>
+          </sinfo_velocities>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="sinfo_tkh_d50">
+      <dc:filter expr="starts-with( $facet_name , 'sinfo_facet_d50.filtered' )">
+        <dc:if test="dc:has-result()">
+          <sinfo_bedqualities>
+            <sinfo_d50s>
+              <dc:call-macro name="collection-group">
+                <sinfo_d50 description="{dc:group-key()}">
+                  <dc:for-each>
+                    <dc:element name="${facet_name}">
+                      <dc:attribute name="factory" value="sinfo"/>
+                      <dc:attribute name="target_out" value="${out}"/>
+                      <dc:attribute name="description" value="${facet_description}"/>
+                      <dc:attribute name="ids" value="${facet_num}"/>
+                      <dc:attribute name="artifact-id" value="${a_gid}"/>
+                      <dc:attribute name="out" value="${out_name}"/>
+                    </dc:element>
+                  </dc:for-each>
+                </sinfo_d50>
+              </dc:call-macro>
+            </sinfo_d50s>
+          </sinfo_bedqualities>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="sinfo_tkh_tau">
+      <dc:filter expr="starts-with( $facet_name , 'sinfo_facet_tau.filtered' )">
+        <dc:if test="dc:has-result()">
+          <sinfo_taus>
+            <dc:call-macro name="collection-group">
+              <sinfo_tau description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="sinfo"/>
+                    <dc:attribute name="target_out" value="${out}"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="${out_name}"/>
+                  </dc:element>
+                </dc:for-each>
+              </sinfo_tau>
+            </dc:call-macro>
+          </sinfo_taus>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
   </datacage>
-</dc:template>
+</dc:template>
\ No newline at end of file

http://dive4elements.wald.intevation.org