diff artifacts/doc/conf/meta-data.xml @ 7340:2ce7bacc940f double-precision

Merged changes from default into double precision branch.
author Tom Gottfried <tom@intevation.de>
date Tue, 15 Oct 2013 18:41:55 +0200
parents 7389fef8905c
children 93a1e63f5644
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Tue Oct 15 15:32:36 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Tue Oct 15 18:41:55 2013 +0200
@@ -73,7 +73,6 @@
                     <dc:call-macro name="mainvalues"/>
                   </dc:when>
                   <dc:when test="$out = 'reference_curve'">
-                    <dc:call-macro name="annotations"/>
                     <dc:call-macro name="mainvalues"/>
                   </dc:when>
                   <dc:when test="$out = 'fix_wq_curve'">
@@ -124,7 +123,7 @@
             </dc:when>
             <dc:otherwise>
               <dc:comment>
-                Non - Recommendations.
+                Non - Recommendations (offered to user to choose additional data from).
               </dc:comment>
               <dc:iterate var="out" container="artifact-outs">
                 <dc:message>Non Rec out iteration for: {$out}</dc:message>
@@ -141,19 +140,15 @@
                   </dc:when>
                   <dc:when test="$out = 'longitudinal_section'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
-                    <dc:call-macro name="bedheight_differences"/>
                   </dc:when>
                   <dc:when test="$out = 'w_differences'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
-                    <dc:call-macro name="bedheight_differences"/>
                   </dc:when>
                   <dc:when test="$out = 'discharge_longitudinal_section'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'historical_discharge_wq'">
-                    <dc:call-macro name="historical_discharge_curve"/>
-                    <dc:call-macro name="discharge_table_gauge"/>
-                    <dc:call-macro name="basedata_2_fixations_wqkms"/>
+                    <dc:call-macro name="discharge-curve-prototype"/>
                     <dc:call-macro name="basedata_5_flood-protections"/>
                     <dc:call-macro name="basedata_0"/>
                     <dc:call-macro name="basedata_1_additionals"/>
@@ -163,13 +158,9 @@
                     </computed_discharge_curve>
                   </dc:when>
                   <dc:when test="$out = 'discharge_curve'">
-                    <dc:call-macro name="historical_discharge_curve"/>
-                    <dc:call-macro name="discharge_table_gauge"/>
-                    <dc:call-macro name="basedata_2_fixations_wqkms"/>
+                    <dc:call-macro name="discharge-curve-prototype"/>
+                    <dc:call-macro name="basedata_1_additionals_wq"/>
                     <dc:call-macro name="basedata_5_flood-protections"/>
-                    <dc:call-macro name="basedata_0_wq"/>
-                    <dc:call-macro name="basedata_1_additionals"/>
-                    <dc:call-macro name="basedata_4_heightmarks-points"/>
                     <computed_discharge_curve>
                       <dc:call-macro name="mainvalues"/>
                     </computed_discharge_curve>
@@ -189,13 +180,10 @@
                     <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
                   </dc:when>
                   <dc:when test="$out = 'fix_wq_curve'">
-                    <dc:call-macro name="historical_discharge_curve"/>
-                    <dc:call-macro name="discharge_table_gauge"/>
-                    <dc:call-macro name="basedata_0_wq"/>
+                    <dc:call-macro name="discharge-curve-prototype"/>
                     <dc:call-macro name="basedata_1_additionals_marks"/>
                     <dc:call-macro name="basedata_2_fixations_wqkms"/>
                     <dc:call-macro name="basedata_3_officials"/>
-                    <dc:call-macro name="basedata_4_heightmarks-points"/>
                     <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
                   </dc:when>
                   <dc:when test="$out = 'fix_longitudinal_section_curve'">
@@ -205,49 +193,25 @@
                     <dc:call-macro name="flood-map-complete"/>
                   </dc:when>
                   <dc:when test="$out = 'flow_velocity'">
-                    <dc:call-macro name="annotations_per_type"/>
-                    <dc:call-macro name="flow_velocity_measurements"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_longitudinal_section'">
-                    <dc:call-macro name="annotations_per_type"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'sedimentload_ls'">
-                    <dc:call-macro name="annotations_per_type"/>
-                    <dc:call-macro name="morph_width"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'bedheight_middle'">
-                    <dc:call-macro name="sounding-width"/>
-                    <dc:call-macro name="basedata_0"/>
-                    <dc:call-macro name="basedata_1_additionals"/>
-                    <dc:call-macro name="basedata_2_fixations"/>
-                    <dc:call-macro name="basedata_3_officials"/>
-                    <dc:call-macro name="annotations_per_type"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_height_year'">
-                    <dc:call-macro name="basedata_0"/>
-                    <dc:call-macro name="basedata_1_additionals"/>
-                    <dc:call-macro name="basedata_2_fixations"/>
-                    <dc:call-macro name="basedata_3_officials"/>
-                    <dc:call-macro name="basedata_6_delta_w"/>
-                    <dc:call-macro name="annotations_per_type"/>
-                    <dc:call-macro name="morph_width"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_year'">
-                    <dc:call-macro name="basedata_0"/>
-                    <dc:call-macro name="basedata_1_additionals"/>
-                    <dc:call-macro name="basedata_2_fixations"/>
-                    <dc:call-macro name="basedata_3_officials"/>
-                    <dc:call-macro name="basedata_6_delta_w"/>
-                    <dc:call-macro name="annotations_per_type"/>
-                    <dc:call-macro name="morph_width"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_epoch'">
-                    <dc:call-macro name="basedata_0"/>
-                    <dc:call-macro name="basedata_1_additionals"/>
-                    <dc:call-macro name="basedata_2_fixations"/>
-                    <dc:call-macro name="basedata_3_officials"/>
-                    <dc:call-macro name="annotations_per_type"/>
-                    <dc:call-macro name="morph_width"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'floodmap'">
                     <dc:choose>
@@ -282,13 +246,10 @@
                     </dc:choose>
                   </dc:when>
                   <dc:when test="$out = 'computed_discharge_curve'">
-                    <dc:call-macro name="historical_discharge_curve"/>
-                    <dc:call-macro name="discharge_table_gauge"/>
-                    <dc:call-macro name="basedata_2_fixations_wqkms"/>
-                    <dc:call-macro name="basedata_5_flood-protections"/>
+                    <dc:call-macro name="discharge-curve-prototype"/>
                     <dc:call-macro name="basedata_0_wq"/>
                     <dc:call-macro name="basedata_1_additionals_wq"/>
-                    <dc:call-macro name="basedata_4_heightmarks-points"/>
+                    <dc:call-macro name="basedata_5_flood-protections"/>
                     <computed_discharge_curve>
                       <dc:call-macro name="mainvalues"/>
                     </computed_discharge_curve>
@@ -320,6 +281,9 @@
                       <dc:call-macro name="basedata_5_flood-protections"/>
                     </dc:if>
                   </dc:when>
+                  <dc:when test="starts-with($out, 'sq_relation')">
+                    <dc:call-macro name="sqrelations"/>
+                  </dc:when>
                 </dc:choose>
               </dc:iterate>
             </dc:otherwise>
@@ -347,24 +311,12 @@
               </dc:when>
               <dc:otherwise>
                 <dc:comment>
-                  Non Recommendations (user)
+                  Non Recommendations (user) - offer to load other projects
                 </dc:comment>
                 <dc:iterate var="out" container="artifact-outs">
                   <dc:choose>
                     <dc:when test="$out = 'longitudinal_section'">
-                      <dc:call-macro name="longitudinal"/>
-                      <dc:call-macro name="differences"/>
-                      <dc:call-macro name="bedheight_differences"/>
-                      <dc:call-macro name="bedquality-bed"/>
-                      <dc:call-macro name="bedquality-load"/>
-                      <dc:call-macro name="flow-velocity"/>
-                      <dc:call-macro name="sediment-load"/>
-                      <dc:call-macro name="bedquality-density"/>
-                      <dc:call-macro name="bedquality-porosity"/>
-                      <dc:call-macro name="waterlevels-discharge"/>
-                      <dc:call-macro name="differenceable-fix"/>
-                      <dc:call-macro name="delta-wt-ls"/>
-                      <dc:call-macro name="longitudinal-section"/>
+                      <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
                     <dc:when test="$out = 'discharge_longitudinal_section'">
                       <dc:call-macro name="longitudinal"/>
@@ -375,6 +327,12 @@
                       <dc:call-macro name="differences"/>
                       <dc:call-macro name="bedheight_differences"/>
                     </dc:when>
+                    <dc:when test="$out = 'computed_discharge_curve'">
+                      <dc:call-macro name="computed-discharge-curve"/>
+                      <dc:call-macro name="fix-wq-curve"/>
+                      <dc:call-macro name="discharge-curve"/>
+                      <dc:call-macro name="extreme-wq-curve"/>
+                    </dc:when>
                     <dc:when test="$out = 'fix_deltawt_curve'">
                       <dc:call-macro name="delta-wt"/>
                     </dc:when>
@@ -580,8 +538,8 @@
     <dc:macro name="longitudinal">
       <dc:filter expr="$out_name = 'longitudinal_section'">
         <dc:if test="dc:has-result()">
-          <waterlevels>
-            <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation))">
+          <waterlevels_ls>
+            <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)">
               <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment>
               <longitudinal_section_columns description="{dc:group-key()}">
                 <dc:for-each>
@@ -596,19 +554,19 @@
                 </dc:for-each>
               </longitudinal_section_columns>
             </dc:group>
-          </waterlevels>
+          </waterlevels_ls>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
-    <dc:macro name="longitudinal-section">
+    <dc:macro name="longitudinal-section-fix">
       <dc:filter expr="$out_name = 'fix_longitudinal_section_curve' and
         (starts-with($facet_name, 'fix_deviation_ls') or
         starts-with($facet_name, 'fix_sector_average_ls') or
         starts-with($facet_name, 'fix_analysis_events_ls') or
         starts-with($facet_name, 'fix_reference_events_ls'))">
         <dc:if test="dc:has-result()">
-          <waterlevels>
+          <waterlevels_fix>
             <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)">
               <waterlevels description="{dc:group-key()}">
                 <dc:for-each>
@@ -623,7 +581,7 @@
                 </dc:for-each>
               </waterlevels>
             </dc:group>
-          </waterlevels>
+          </waterlevels_fix>
         </dc:if>
       </dc:filter>
     </dc:macro>
@@ -731,6 +689,64 @@
       </dc:filter>
     </dc:macro>
 
+
+    <dc:macro name="discharge-curve">
+      <dc:filter expr="$facet_name = 'discharge_curve.curve'">
+        <dc:if test="dc:has-result()">
+          <discharge_curves>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="winfo"/>
+                <dc:attribute name="target_out" value="${out}"/>
+                <dc:attribute name="artifact-id" value="${a_gid}"/>
+                <dc:attribute name="ids" value="${a_gid}"/>
+                <dc:attribute name="out" value="discharge_curve"/>
+              </dc:element>
+            </dc:for-each>
+          </discharge_curves>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="extreme-wq-curve">
+      <dc:filter expr="$facet_name = 'extreme_wq_curve'">
+        <dc:if test="dc:has-result()">
+          <computed_discharge_curves>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="fixanalysis"/>
+                <dc:attribute name="target_out" value="${out}"/>
+                <dc:attribute name="artifact-id" value="${a_gid}"/>
+                <dc:attribute name="ids" value="${a_gid}"/>
+                <dc:attribute name="out" value="computed_discharge_curve"/>
+              </dc:element>
+            </dc:for-each>
+          </computed_discharge_curves>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="computed-discharge-curve">
+      <dc:filter expr="$facet_name = 'computed_discharge_curve.q'">
+        <dc:if test="dc:has-result()">
+          <computed_discharge_curves>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="winfo"/>
+                <dc:attribute name="target_out" value="${out}"/>
+                <dc:attribute name="artifact-id" value="${a_gid}"/>
+                <dc:attribute name="ids" value="${a_gid}"/>
+                <dc:attribute name="out" value="computed_discharge_curve"/>
+              </dc:element>
+            </dc:for-each>
+          </computed_discharge_curves>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
     <dc:macro name="duration-curve">
       <dc:filter expr="$facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w'">
         <dc:if test="dc:has-result()">
@@ -1049,8 +1065,8 @@
     <dc:macro name="waterlevels-discharge">
       <dc:filter expr="$out_name = 'discharge_longitudinal_section' and $facet_name = 'discharge_longitudinal_section.w'">
         <dc:if test="dc:has-result()">
-          <waterlevels-discharge>
-            <dc:group expr="concat($oid, ' ', $river, ' ', $a_gid, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)">
+          <waterlevels_discharge>
+            <dc:group expr="concat($river, ' ',  dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)">
               <discharge description="{dc:group-key()}">
                 <dc:for-each>
                   <dc:element name="${facet_name}">
@@ -1064,7 +1080,7 @@
                 </dc:for-each>
               </discharge>
             </dc:group>
-          </waterlevels-discharge>
+          </waterlevels_discharge>
         </dc:if>
       </dc:filter>
     </dc:macro>
@@ -1212,6 +1228,14 @@
       </dc:filter>
     </dc:macro>
 
+    <dc:macro name="discharge-curve-prototype">
+        <dc:call-macro name="discharge_table_gauge"/>
+        <dc:call-macro name="historical_discharge_curve"/>
+        <dc:call-macro name="basedata_0_wq"/>
+        <dc:call-macro name="basedata_2_fixations_wqkms"/>
+        <dc:call-macro name="basedata_4_heightmarks-points"/>
+    </dc:macro>
+
     <dc:macro name="longitudinal-section-prototype">
       <dc:call-macro name="basedata_0"/>
       <dc:call-macro name="basedata_1_additionals"/>
@@ -1221,69 +1245,184 @@
       <dc:call-macro name="basedata_5_flood-protections"/>
       <dc:call-macro name="annotations_per_type"/>
       <minfo>
-          <dc:call-macro name="basedata_6_delta_w"/>
-          <dc:call-macro name="basedata_7_waterlevels"/>
+          <fixanalysis>
+            <dc:call-macro name="basedata_6_delta_w"/>
+            <dc:call-macro name="basedata_7_waterlevels"/>
+          </fixanalysis>
+          <dc:call-macro name="yields"/>
+          <dc:call-macro name="densities"/>
           <dc:call-macro name="minfo-heights"/>
           <dc:call-macro name="sounding-width"/>
-          <dc:call-macro name="yields"/>
+          <dc:call-macro name="morph_width"/>
+          <dc:call-macro name="flow_velocity_measurements"/>
+          <dc:call-macro name="flow_velocity_models"/>
       </minfo>
     </dc:macro>
 
+    <dc:macro name="longitudinal-section-user-prototype">
+       <dc:call-macro name="longitudinal"/>
+       <dc:call-macro name="differences"/>
+       <dc:call-macro name="bedheight_differences"/>
+       <dc:call-macro name="bedquality-bed"/>
+       <dc:call-macro name="bedquality-load"/>
+       <dc:call-macro name="flow-velocity"/>
+       <dc:call-macro name="sediment-load"/>
+       <dc:call-macro name="bedquality-density"/>
+       <dc:call-macro name="bedquality-porosity"/>
+       <dc:call-macro name="waterlevels-discharge"/>
+       <dc:call-macro name="differenceable-fix"/><!-- TODO double entries? -->
+       <dc:call-macro name="delta-wt-ls"/>
+       <dc:call-macro name="longitudinal-section-fix"/>
+       <dc:call-macro name="discharge-curve"/>
+    </dc:macro>
+
+
+    <dc:macro name="densities">
+      <densities>
+      <dc:context>
+        <dc:statement>
+            SELECT DISTINCT
+                sd.id          AS sdid,
+                sd.description AS description,
+                d.lower        AS depth_lower,
+                d.upper        AS depth_upper
+            FROM     sediment_density sd
+                JOIN rivers r ON sd.river_id = r.id
+                JOIN depths d ON sd.depth_id = d.id
+            WHERE   r.id = ${river_id}
+        </dc:statement>
+        <dc:if test="dc:has-result()">
+          <dc:for-each>
+            <density description="{$description}"
+                   factory="sedimentdensity"
+                   target_out="{$out}"
+                   info="infome"
+                   ids="{$sdid}" />
+          </dc:for-each>
+        </dc:if>
+      </dc:context>
+      </densities>
+    </dc:macro>
+
+    <dc:macro name="one-load">
+      <dc:for-each>
+          <dc:variable name="syear" type="string" expr="dc:date-format('yyyy', $year)"/>
+          <year description="{$syear}"
+                 factory="sedimentyield"
+                 target_out="{$out}"
+                 info="{$description}"
+                ids="{$syid}" />
+      </dc:for-each>
+    </dc:macro>
+
+    <dc:macro name="epoch-load">
+      <dc:for-each>
+          <dc:variable name="syear" type="string" expr="dc:date-format('yyyy', $startyear)"/>
+          <dc:variable name="eyear" type="string" expr="dc:date-format('yyyy', $endyear)"/>
+          <year description="{$syear}-{$eyear}"
+                 factory="sedimentyield"
+                 target_out="{$out}"
+                 info="{$description}"
+                ids="{$syid}" />
+      </dc:for-each>
+    </dc:macro>
+
+    <dc:macro name="loads">
+     <dc:if test="dc:has-result()">
+       <dc:filter expr="$fraction='sand'">
+         <dc:if test="dc:has-result()">
+           <sand>
+             <dc:macro-body/>
+           </sand>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='fine_middle'">
+         <dc:if test="dc:has-result()">
+           <fine_middle>
+             <dc:macro-body/>
+           </fine_middle>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='coarse'">
+         <dc:if test="dc:has-result()">
+           <coarse>
+             <dc:macro-body/>
+           </coarse>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='suspended_sediment'">
+         <dc:if test="dc:has-result()">
+           <susp_sediment>
+             <dc:macro-body/>
+           </susp_sediment>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='susp_sand'">
+         <dc:if test="dc:has-result()">
+           <susp_sand>
+             <dc:macro-body/>
+           </susp_sand>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='susp_sand_bed'">
+         <dc:if test="dc:has-result()">
+           <susp_sand_bed>
+             <dc:macro-body/>
+           </susp_sand_bed>
+         </dc:if>
+       </dc:filter>
+     </dc:if>
+    </dc:macro>
+      
     <dc:macro name="yields">
       <yields>
       <years>
       <dc:context>
         <dc:statement>
             SELECT DISTINCT
-                sy.id AS syid,
+                sy.id          AS syid,
                 sy.description AS description,
-                ti.start_time AS year
+                ti.start_time  AS year,
+                gf.name        AS fraction
             FROM     sediment_yield sy
                 JOIN rivers r ON sy.river_id = r.id
                 JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id
                 JOIN time_intervals ti ON sy.time_interval_id = ti.id
-            WHERE   r.name = 'Elbe'
+                JOIN grain_fraction gf ON gf.id = sy.grain_fraction_id
+            WHERE   r.id = ${river_id}
                 AND ti.stop_time IS NULL
                 AND syv.station BETWEEN ${fromkm} AND ${tokm}
+            ORDER BY fraction
         </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:for-each>
-            <year description="{$description}"
-                   factory="sedimentyield"
-                   target_out="{$out}"
-                   info="infome"
-                  ids="{$syid}" />
-          </dc:for-each>
-        </dc:if>
+        <dc:call-macro name="loads">
+          <dc:call-macro name="one-load"/>
+        </dc:call-macro>
       </dc:context>
       </years>
       <epochs>
       <dc:context>
         <dc:statement>
             SELECT DISTINCT
-                sy.id AS syid,
+                sy.id          AS syid,
                 sy.description AS description,
-                ti.start_time AS year
+                ti.start_time  AS startyear,
+                ti.stop_time   AS endyear,
+                gf.name        AS fraction
             FROM     sediment_yield sy
                 JOIN rivers r ON sy.river_id = r.id
                 JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id
                 JOIN time_intervals ti ON sy.time_interval_id = ti.id
-            WHERE   r.name = 'Elbe'
+                JOIN grain_fraction gf ON gf.id = sy.grain_fraction_id
+            WHERE   r.id = ${river_id}
                 AND ti.stop_time IS NOT NULL
                 AND syv.station BETWEEN ${fromkm} AND ${tokm}
+            ORDER BY fraction
         </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:for-each>
-            <epoch description="{$description}"
-                   factory="sedimentyield"
-                   target_out="{$out}"
-                   info="infome"
-                   ids="{$syid}" />
-          </dc:for-each>
-        </dc:if>
+        <dc:call-macro name="loads">
+          <dc:call-macro name="epoch-load"/>
+        </dc:call-macro>
       </dc:context>
       </epochs>
-
       </yields>
     </dc:macro>
 
@@ -1488,18 +1627,28 @@
       <single>
         <dc:context>
           <dc:statement>
-            SELECT id          AS bedh_id,
-                   year        AS bedh_year,
-                   description AS bedh_descr
-            FROM bed_height_single
-            WHERE river_id = ${river_id}
-              AND lower(description) NOT LIKE '%epoch%'
+            SELECT bhs.id          AS bedh_id,
+                   bhs.year        AS bedh_year,
+                   bhs.description AS bedh_descr,
+                   bht.name        AS type_name
+            FROM bed_height_single bhs
+               JOIN bed_height_type bht ON bht.id = bhs.type_id
+            WHERE bhs.river_id = ${river_id}
+              AND lower(bhs.description) NOT LIKE '%epoch%'
           </dc:statement>
-          <dc:for-each>
-            <height factory="bedheight" target_out="{$out}"
-                    ids="bedheight-single-{$bedh_id}-{$bedh_year}"
-                    description="{$bedh_descr}"/>
-          </dc:for-each>
+          <dc:if test="dc:has-result()">
+            <dc:group expr="$bedh_year">
+              <cross-sections name="{dc:group-key()}">
+                <dc:for-each>
+                  <height factory="bedheight"
+                          target_out="{$out}"
+                          ids="bedheight-single-{$bedh_id}-{$bedh_year}"
+                          info="{$type_name}"
+                          description="{$bedh_descr}"/>
+                </dc:for-each>
+              </cross-sections>
+            </dc:group>
+          </dc:if>
         </dc:context>
       </single>
     </dc:macro>
@@ -1524,6 +1673,28 @@
       </epoch>
     </dc:macro>
 
+    <dc:macro name="flow_velocity_models">
+      <dc:context>
+        <dc:statement>
+          SELECT fvm.id          AS fvmid,
+                 fvm.description AS fvmd
+          FROM flow_velocity_model fvm
+          JOIN discharge_zone dz ON dz.id = fvm.discharge_zone_id 
+          WHERE dz.river_id = ${river_id}
+        </dc:statement>
+        <dc:if test="dc:has-result()">
+          <flowvelocitymodel>
+            <dc:for-each>
+                    <measurement_value name="{$fvmd}"
+                                       ids="{$fvmid}"
+                                       factory="flowvelocitymodel" target_out="{$out}" />
+            </dc:for-each>
+          </flowvelocitymodel>
+        </dc:if>
+      </dc:context>
+    </dc:macro>
+
+
     <dc:macro name="flow_velocity_measurements">
       <dc:context>
         <dc:statement>
@@ -1607,6 +1778,40 @@
       </dc:context>
     </dc:macro>
 
+    <dc:macro name="sqrelations">
+      <dc:context>
+        <dc:statement>
+          SELECT sq.description  AS description,
+            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
+          FROM sq_relation sq
+          JOIN time_intervals ti ON ti.id   = sq.time_interval_id
+          JOIN rivers r ON r.id = sq.river_id
+          JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id
+          JOIN measurement_station ms ON sqv.measurement_station_id = ms.id
+          WHERE r.id = ${river_id}
+        </dc:statement>
+        <dc:if test="dc:has-result()">
+          <sq_relations>
+            <dc:filter expr="$out = concat('sq_relation_', $parameter)">
+              <dc:group expr="$station_name">
+                <station description="{dc:group-key()}">
+                  <dc:for-each>
+                    <dc:variable name="combined_desc" expr="concat(dc:date-format('yyyy', $start_time), ' bis ', dc:date-format('yyyy', $stop_time))"/>
+                    <sqvalue factory="staticsqrelation" target_out="{$out}"
+                      ids="{$sqvid};{$station_name}: {$combined_desc}" description="{$combined_desc}"/>
+                  </dc:for-each>
+                </station>
+              </dc:group>
+            </dc:filter>
+          </sq_relations>
+        </dc:if>
+      </dc:context>
+    </dc:macro>
+
     <dc:macro name="basedata_0_macro">
       <dc:filter expr="$kind = 0">
         <dc:if test="dc:has-result()">
@@ -1675,6 +1880,15 @@
       </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}]"/>
+      </dc:call-macro>
+    </dc:macro>
+
     <!-- Floodmap part -->
     <dc:macro name="flood-map-complete">
       <dc:call-macro name="flood-map-buildings"/>
@@ -1709,18 +1923,6 @@
       <dc:call-macro name="flood-map-hydr-boundaries-state"/>
     </dc:macro>
 
-    <dc:macro name="flood-map-recommended">
-      <dc:comment>
-         FIXME: Following two macros look identical to me.
-      </dc:comment>
-      <kilometrage>
-        <riveraxis factory="riveraxis" ids="{$river_id}" target_out="{$out}" />
-      </kilometrage>
-      <rastermap>
-        <background factory="wmsbackground" ids="{$river_id}" target_out="{$out}" />
-      </rastermap>
-    </dc:macro>
-
     <dc:macro name="flood-map-dem">
       <dems>
         <dc:context>

http://dive4elements.wald.intevation.org