diff flys-artifacts/doc/conf/meta-data.xml @ 5405:5ca06120b918

Remove river_name and map elements to reduce datacage level depth
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 25 Mar 2013 15:38:54 +0100
parents 08262e0ce57a
children 70026e3b6af3
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml	Mon Mar 25 15:02:04 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Mon Mar 25 15:38:54 2013 +0100
@@ -709,1048 +709,1044 @@
         <dc:comment>
         + River-Node
         </dc:comment>
-        <river>
-          <dc:attribute name="name" value="${river_name}"/>
+        <dc:attribute name="name" value="${river_name}"/>
 
-          <dc:choose>
-            <dc:when test="dc:contains($parameters, 'recommended')">
-               <dc:comment>
-                  Recommendations (client shall load immediately).
-               </dc:comment>
-               <dc:if test="dc:contains($artifact-outs, 'w_differences') or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'historical_discharge_wq')">
-                 <dc:call-macro name="mainvalues"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'cross_section')">
-                 <dc:call-macro name="cross_sections"/>
-                 <dc:call-macro name="hyks"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
-                 <dc:call-macro name="mainvalues"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'duration_curve')">
-                 <dc:call-macro name="mainvalues"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'reference_curve')">
-                 <dc:call-macro name="annotations"/>
-                 <dc:call-macro name="mainvalues"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')">
-                 <dc:call-macro name="qsectors"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'bed_difference_epoch')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'bed_difference_year')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'bed_difference_height_year')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-               <dc:if test="dc:contains($artifact-outs, 'flow_velocity')">
-                 <dc:call-macro name="annotations"/>
-               </dc:if>
-            </dc:when>
-            <dc:otherwise>
-              <dc:comment>
-                 Non - Recommendations.
-              </dc:comment>
-              <dc:if test="dc:contains($artifact-outs, 'cross_section')">
-                 <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_4_heightmarks-points"/>
-                 <dc:call-macro name="cross_sections"/>
-                 <dc:call-macro name="hyks"/>
-              </dc:if>
-              <!--dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
-                 <dc:call-macro name="basedata_0_wq"/>
-                 <dc:call-macro name="basedata_4_heightmarks-wq"/>
-              </dc:if-->
-              <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'w_differences')) or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
-                  <dc:call-macro name="longitudinal-section-prototype"/>
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'duration_curve')">
-                  <dc:call-macro name="mainvalues"/>
-                  <dc:call-macro name="basedata_2_fixations_relative_point"/>
-                  <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
-                  <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'reference_curve')">
-                <dc:call-macro name="annotations"/>
-                <!--dc:call-macro name="basedata_0"/-->
-                <dc:call-macro name="basedata_1_additionals-relative_point"/>
-                <dc:comment comment=" FIXATIONS ---------------------------"/>
+        <dc:choose>
+          <dc:when test="dc:contains($parameters, 'recommended')">
+             <dc:comment>
+                Recommendations (client shall load immediately).
+             </dc:comment>
+             <dc:if test="dc:contains($artifact-outs, 'w_differences') or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'historical_discharge_wq')">
+               <dc:call-macro name="mainvalues"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'cross_section')">
+               <dc:call-macro name="cross_sections"/>
+               <dc:call-macro name="hyks"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
+               <dc:call-macro name="mainvalues"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'duration_curve')">
+               <dc:call-macro name="mainvalues"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'reference_curve')">
+               <dc:call-macro name="annotations"/>
+               <dc:call-macro name="mainvalues"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')">
+               <dc:call-macro name="qsectors"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'bed_difference_epoch')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'bed_difference_year')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'bed_difference_height_year')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+             <dc:if test="dc:contains($artifact-outs, 'flow_velocity')">
+               <dc:call-macro name="annotations"/>
+             </dc:if>
+          </dc:when>
+          <dc:otherwise>
+            <dc:comment>
+               Non - Recommendations.
+            </dc:comment>
+            <dc:if test="dc:contains($artifact-outs, 'cross_section')">
+               <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_4_heightmarks-points"/>
+               <dc:call-macro name="cross_sections"/>
+               <dc:call-macro name="hyks"/>
+            </dc:if>
+            <!--dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
+               <dc:call-macro name="basedata_0_wq"/>
+               <dc:call-macro name="basedata_4_heightmarks-wq"/>
+            </dc:if-->
+            <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'w_differences')) or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
+                <dc:call-macro name="longitudinal-section-prototype"/>
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'duration_curve')">
+                <dc:call-macro name="mainvalues"/>
                 <dc:call-macro name="basedata_2_fixations_relative_point"/>
-                <dc:comment comment=" HOEHENMARKEN ---------------------------"/>
                 <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
                 <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')">
-                <dc:call-macro name="basedata_0_wq"/>
-                <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:if>
-              <dc:if test="dc:contains($artifact-outs, 'fix_deltawt_curve')">
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')">
-                <dc:call-macro name="annotations"/>
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'map')">
-                 <map>
-                   <dc:call-macro name="flood-map-complete"/>
-                 </map>
-              </dc:if>
-              <dc:if test="dc:contains($artifact-outs, 'flow_velocity')">
-                <dc:call-macro name="annotations"/>
-                <dc:call-macro name="flow_velocity_measurements"/>
-              </dc:if>
-              <dc:comment>
-                MINFO bedheight middle
-              </dc:comment>
-              <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')">
-                <dc:call-macro name="sounding-width"/>
-              </dc:if>
-             <dc:comment comment="--- non-recommendations---"/>
-            </dc:otherwise>
-          </dc:choose>
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'reference_curve')">
+              <dc:call-macro name="annotations"/>
+              <!--dc:call-macro name="basedata_0"/-->
+              <dc:call-macro name="basedata_1_additionals-relative_point"/>
+              <dc:comment comment=" FIXATIONS ---------------------------"/>
+              <dc:call-macro name="basedata_2_fixations_relative_point"/>
+              <dc:comment comment=" HOEHENMARKEN ---------------------------"/>
+              <dc:call-macro name="basedata_4_heightmarks-points-relative_points"/>
+              <dc:call-macro name="basedata_5_flood-protections_relative_points"/>
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')">
+              <dc:call-macro name="basedata_0_wq"/>
+              <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:if>
+            <dc:if test="dc:contains($artifact-outs, 'fix_deltawt_curve')">
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')">
+              <dc:call-macro name="annotations"/>
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'map')">
+              <dc:call-macro name="flood-map-complete"/>
+            </dc:if>
+            <dc:if test="dc:contains($artifact-outs, 'flow_velocity')">
+              <dc:call-macro name="annotations"/>
+              <dc:call-macro name="flow_velocity_measurements"/>
+            </dc:if>
+            <dc:comment>
+              MINFO bedheight middle
+            </dc:comment>
+            <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')">
+              <dc:call-macro name="sounding-width"/>
+            </dc:if>
+           <dc:comment comment="--- non-recommendations---"/>
+          </dc:otherwise>
+        </dc:choose>
 
 
-          <dc:if test="dc:contains($artifact-outs, 'waterlevels')">
-
-            <!-- base data -->
-            <dc:call-macro name="basedata_0"/>
-
-            <!-- extra-longitudinal-sections -->
-            <dc:call-macro name="basedata_1_additionals"/>
-
-            <!-- fixations -->
-            <dc:call-macro name="basedata_2_fixations"/>
-
-            <!-- flood water marks-->
-            <dc:call-macro name="basedata_4_heightmarks-points"/>
-
-            <!-- flood protection -->
-            <dc:call-macro name="basedata_5_flood-protections"/>
-
-          </dc:if>
-          <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve') and (dc:contains($parameters, 'recommended'))">
-                <!--dc:call-macro name="basedata_2_fixations_wst"/-->
-          </dc:if>
-
-          <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve') and not (dc:contains($parameters, 'recommended'))">
-              <discharge_table_nn>
-                <discharge_table_gauge>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT id   AS gauge_id,
-                             name AS gauge_name
-                      FROM gauges WHERE river_id = ${river_id}
-                    </dc:statement>
-                    <dc:elements>
-                      <gauge>
-                        <dc:attribute name="name" value="${gauge_name}"/>
-                        <dc:attribute name="db-id" value="${gauge_id}"/>
-                        <dc:attribute name="factory" value="gaugedischarge"/>
-                        <dc:attribute name="from" value="${g_start}"/>
-                        <dc:attribute name="to" value="${g_stop}"/>
-                        <dc:attribute name="ids" value="${gauge_name}"/>
-                      </gauge>
-                      <!--
-                      <gauge>
-                        <dc:attribute name="name" value="${gauge_name}"/>
-                        <dc:attribute name="db-id" value="${gauge_id}"/>
-                        <dc:context>
-                          <dc:statement>
-                            SELECT description   AS gauge_desc,
-                                   d.id          AS discharge_id,
-                                   ti.start_time AS g_start,
-                                   ti.stop_time  AS g_stop
-                            FROM discharge_tables d JOIN time_intervals ti
-                            ON d.time_interval_id = ti.id
-                            WHERE d.gauge_id = ${gauge_id} AND d.kind = 1
-                          </dc:statement>
-                          <dc:elements>
-                            <historical>
-                              <dc:attribute name="name" value="${gauge_desc}"/>
-                              <dc:attribute name="factory" value="gaugedischarge"/>
-                              <dc:attribute name="from" value="${g_start}"/>
-                              <dc:attribute name="to" value="${g_stop}"/>
-                              <dc:attribute name="ids" value="${discharge_id}-${g_start}-${g_stop}"/>
-                            </historical>
-                          </dc:elements>
-                        </dc:context>
-                      </gauge>
-                      -->
-                    </dc:elements>
-                  </dc:context>
-                </discharge_table_gauge>
-
-              </discharge_table_nn>
-
-            <dc:call-macro name="basedata_2_fixations_wst"/>
-
-            <dc:call-macro name="basedata_5_flood-protections"/>
-
-            <!-- former waterlevels -->
-            <dc:call-macro name="basedata_0"/>
-
-            <dc:call-macro name="basedata_1_additionals"/>
-
-            <!-- former flood-water-marks -->
-            <dc:call-macro name="basedata_4_heightmarks-points"/>
-              <computed_discharge_curve>
-                <dc:call-macro name="mainvalues"/>
-              </computed_discharge_curve>
-          </dc:if>
+        <dc:if test="dc:contains($artifact-outs, 'waterlevels')">
 
-          <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve') and not (dc:contains($parameters, 'recommended'))">
-              <discharge_table_nn>
-                <discharge_table_gauge>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT id   AS gauge_id,
-                             name AS gauge_name
-                      FROM gauges WHERE river_id = ${river_id}
-                    </dc:statement>
-                    <dc:elements>
-                      <gauge>
-                        <dc:attribute name="name" value="${gauge_name}"/>
-                        <dc:attribute name="db-id" value="${gauge_id}"/>
-                        <dc:attribute name="factory" value="gaugedischarge"/>
-                        <dc:attribute name="from" value="${g_start}"/>
-                        <dc:attribute name="to" value="${g_stop}"/>
-                        <dc:attribute name="ids" value="${gauge_name}"/>
-                      </gauge>
-                    </dc:elements>
-                  </dc:context>
-                </discharge_table_gauge>
-              </discharge_table_nn>
-          </dc:if>
+          <!-- base data -->
+          <dc:call-macro name="basedata_0"/>
 
-          <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'floodmap-hws')">
-              <floodmap>
-              <dc:choose>
-                  <dc:when test="dc:contains($parameters, 'recommended')">
-                    <dc:call-macro name="flood-map-recommended"/>
-                  </dc:when>
-                  <dc:when test="dc:contains($parameters, 'dem')">
-                    <dc:call-macro name="flood-map-dem"/>
-                  </dc:when>
-                  <dc:otherwise>
-                    <dc:call-macro name="flood-map-complete"/>
-                  </dc:otherwise>
-              </dc:choose>
-              </floodmap>
-              <dc:if test="dc:contains($parameters, 'hws')">
-                <hws>
-                  <dc:call-macro name="flood-map-hws-lines" />
-                  <dc:call-macro name="flood-map-hws-points" />
-                </hws>
-              </dc:if>
+          <!-- extra-longitudinal-sections -->
+          <dc:call-macro name="basedata_1_additionals"/>
 
-              <dc:macro name="flood-map-recommended">
-                <dc:comment>
-                   FIXME: Following two macros look identical to me.
-                </dc:comment>
-                  <kilometrage>
-                      <riveraxis>
-                          <dc:attribute name="factory" value="riveraxis"/>
-                          <dc:attribute name="ids" value="${river_id}"/>
-                      </riveraxis>
-                  </kilometrage>
-                  <rastermap>
-                      <background>
-                          <dc:attribute name="factory" value="wmsbackground"/>
-                          <dc:attribute name="ids" value="${river_id}"/>
-                      </background>
-                  </rastermap>
-              </dc:macro>
-              <dc:macro name="flood-map-dem">
-                <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,
-                             d.projection || ' | ' || t.start_time || ' - ' || t.stop_time AS info
-                             FROM dem d
-                             JOIN ranges r ON d.range_id = r.id
-                             JOIN time_intervals t ON d.time_interval_id = t.id
-                             WHERE d.river_id = ${river_id}
-                    </dc:statement>
-                    <dc:elements>
-                        <dem>
-                          <dc:attribute name="factory" value="demfactory"/>
-                          <dc:attribute name="ids" value="${dem_id}"/>
-                          <dc:attribute name="name" value="${name}"/>
-                          <dc:attribute name="info" value="${info}"/>
-                        </dem>
-                    </dc:elements>
-                  </dc:context>
-                </dems>
-              </dc:macro>
-              <dc:macro name="flood-map-hws-lines">
+          <!-- fixations -->
+          <dc:call-macro name="basedata_2_fixations"/>
+
+          <!-- flood water marks-->
+          <dc:call-macro name="basedata_4_heightmarks-points"/>
+
+          <!-- flood protection -->
+          <dc:call-macro name="basedata_5_flood-protections"/>
+
+        </dc:if>
+        <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve') and (dc:contains($parameters, 'recommended'))">
+              <!--dc:call-macro name="basedata_2_fixations_wst"/-->
+        </dc:if>
+
+        <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve') and not (dc:contains($parameters, 'recommended'))">
+            <discharge_table_nn>
+              <discharge_table_gauge>
                 <dc:context>
                   <dc:statement>
-                    SELECT DISTINCT
-                           name AS hws_name,
-                           official AS hws_official,
-                           kind_id AS hws_kind
-                    FROM hws_lines
-                    WHERE river_id = ${river_id}
+                    SELECT id   AS gauge_id,
+                           name AS gauge_name
+                    FROM gauges WHERE river_id = ${river_id}
                   </dc:statement>
-                  <lines>
-                    <official>
-                      <Durchlass>
-                        <dc:elements filter="$hws_kind=1 and $hws_official=1">
-                            <hws>
-                              <dc:attribute name="factory" value="hwsfactory"/>
-                              <dc:attribute name="name" value="${hws_name}"/>
-                            </hws>
-                        </dc:elements>
-                      </Durchlass>
-                      <Damm>
-                        <dc:elements filter="$hws_kind=2 and $hws_official=1">
-                            <hws>
-                              <dc:attribute name="factory" value="hwsfactory"/>
-                              <dc:attribute name="name" value="${hws_name}"/>
-                            </hws>
+                  <dc:elements>
+                    <gauge>
+                      <dc:attribute name="name" value="${gauge_name}"/>
+                      <dc:attribute name="db-id" value="${gauge_id}"/>
+                      <dc:attribute name="factory" value="gaugedischarge"/>
+                      <dc:attribute name="from" value="${g_start}"/>
+                      <dc:attribute name="to" value="${g_stop}"/>
+                      <dc:attribute name="ids" value="${gauge_name}"/>
+                    </gauge>
+                    <!--
+                    <gauge>
+                      <dc:attribute name="name" value="${gauge_name}"/>
+                      <dc:attribute name="db-id" value="${gauge_id}"/>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT description   AS gauge_desc,
+                                 d.id          AS discharge_id,
+                                 ti.start_time AS g_start,
+                                 ti.stop_time  AS g_stop
+                          FROM discharge_tables d JOIN time_intervals ti
+                          ON d.time_interval_id = ti.id
+                          WHERE d.gauge_id = ${gauge_id} AND d.kind = 1
+                        </dc:statement>
+                        <dc:elements>
+                          <historical>
+                            <dc:attribute name="name" value="${gauge_desc}"/>
+                            <dc:attribute name="factory" value="gaugedischarge"/>
+                            <dc:attribute name="from" value="${g_start}"/>
+                            <dc:attribute name="to" value="${g_stop}"/>
+                            <dc:attribute name="ids" value="${discharge_id}-${g_start}-${g_stop}"/>
+                          </historical>
                         </dc:elements>
-                      </Damm>
-                      <Graben>
-                        <dc:elements filter="$hws_kind=3 and $hws_official=1">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Graben>
-                    </official>
-                    <inofficial>
-                      <Durchlass>
-                        <dc:elements filter="$hws_kind=1 and $hws_official=0">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Durchlass>
-                      <Damm>
-                        <dc:elements filter="$hws_kind=2 and $hws_official=0">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Damm>
-                      <Graben>
-                        <dc:elements filter="$hws_kind=3 and $hws_official=0">
+                      </dc:context>
+                    </gauge>
+                    -->
+                  </dc:elements>
+                </dc:context>
+              </discharge_table_gauge>
+
+            </discharge_table_nn>
+
+          <dc:call-macro name="basedata_2_fixations_wst"/>
+
+          <dc:call-macro name="basedata_5_flood-protections"/>
+
+          <!-- former waterlevels -->
+          <dc:call-macro name="basedata_0"/>
+
+          <dc:call-macro name="basedata_1_additionals"/>
+
+          <!-- former flood-water-marks -->
+          <dc:call-macro name="basedata_4_heightmarks-points"/>
+            <computed_discharge_curve>
+              <dc:call-macro name="mainvalues"/>
+            </computed_discharge_curve>
+        </dc:if>
+
+        <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve') and not (dc:contains($parameters, 'recommended'))">
+            <discharge_table_nn>
+              <discharge_table_gauge>
+                <dc:context>
+                  <dc:statement>
+                    SELECT id   AS gauge_id,
+                           name AS gauge_name
+                    FROM gauges WHERE river_id = ${river_id}
+                  </dc:statement>
+                  <dc:elements>
+                    <gauge>
+                      <dc:attribute name="name" value="${gauge_name}"/>
+                      <dc:attribute name="db-id" value="${gauge_id}"/>
+                      <dc:attribute name="factory" value="gaugedischarge"/>
+                      <dc:attribute name="from" value="${g_start}"/>
+                      <dc:attribute name="to" value="${g_stop}"/>
+                      <dc:attribute name="ids" value="${gauge_name}"/>
+                    </gauge>
+                  </dc:elements>
+                </dc:context>
+              </discharge_table_gauge>
+            </discharge_table_nn>
+        </dc:if>
+
+        <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'floodmap-hws')">
+            <floodmap>
+            <dc:choose>
+                <dc:when test="dc:contains($parameters, 'recommended')">
+                  <dc:call-macro name="flood-map-recommended"/>
+                </dc:when>
+                <dc:when test="dc:contains($parameters, 'dem')">
+                  <dc:call-macro name="flood-map-dem"/>
+                </dc:when>
+                <dc:otherwise>
+                  <dc:call-macro name="flood-map-complete"/>
+                </dc:otherwise>
+            </dc:choose>
+            </floodmap>
+            <dc:if test="dc:contains($parameters, 'hws')">
+              <hws>
+                <dc:call-macro name="flood-map-hws-lines" />
+                <dc:call-macro name="flood-map-hws-points" />
+              </hws>
+            </dc:if>
+
+            <dc:macro name="flood-map-recommended">
+              <dc:comment>
+                 FIXME: Following two macros look identical to me.
+              </dc:comment>
+                <kilometrage>
+                    <riveraxis>
+                        <dc:attribute name="factory" value="riveraxis"/>
+                        <dc:attribute name="ids" value="${river_id}"/>
+                    </riveraxis>
+                </kilometrage>
+                <rastermap>
+                    <background>
+                        <dc:attribute name="factory" value="wmsbackground"/>
+                        <dc:attribute name="ids" value="${river_id}"/>
+                    </background>
+                </rastermap>
+            </dc:macro>
+            <dc:macro name="flood-map-dem">
+              <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,
+                           d.projection || ' | ' || t.start_time || ' - ' || t.stop_time AS info
+                           FROM dem d
+                           JOIN ranges r ON d.range_id = r.id
+                           JOIN time_intervals t ON d.time_interval_id = t.id
+                           WHERE d.river_id = ${river_id}
+                  </dc:statement>
+                  <dc:elements>
+                      <dem>
+                        <dc:attribute name="factory" value="demfactory"/>
+                        <dc:attribute name="ids" value="${dem_id}"/>
+                        <dc:attribute name="name" value="${name}"/>
+                        <dc:attribute name="info" value="${info}"/>
+                      </dem>
+                  </dc:elements>
+                </dc:context>
+              </dems>
+            </dc:macro>
+            <dc:macro name="flood-map-hws-lines">
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                         name AS hws_name,
+                         official AS hws_official,
+                         kind_id AS hws_kind
+                  FROM hws_lines
+                  WHERE river_id = ${river_id}
+                </dc:statement>
+                <lines>
+                  <official>
+                    <Durchlass>
+                      <dc:elements filter="$hws_kind=1 and $hws_official=1">
                           <hws>
                             <dc:attribute name="factory" value="hwsfactory"/>
                             <dc:attribute name="name" value="${hws_name}"/>
                           </hws>
-                        </dc:elements>
-                      </Graben>
-                    </inofficial>
-                  </lines>
-                </dc:context>
-              </dc:macro>
-              <dc:macro name="flood-map-hws-points">
-                <dc:context>
-                  <dc:statement>
-                    SELECT DISTINCT
-                           name AS hws_points_name,
-                           official AS hws_points_official,
-                           kind_id AS hws_points_kind
-                    FROM hws_points
-                    WHERE river_id = ${river_id}
-                  </dc:statement>
-                  <points>
-                    <official>
-                      <Durchlass>
-                        <dc:elements filter="$hws_points_kind=1 and $hws_points_official=1">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Durchlass>
-                      <Damm>
-                        <dc:elements filter="$hws_points_kind=2 and $hws_points_official=1">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Damm>
-                      <Graben>
-                        <dc:elements filter="$hws_kind=3 and $hws_official=1">
+                      </dc:elements>
+                    </Durchlass>
+                    <Damm>
+                      <dc:elements filter="$hws_kind=2 and $hws_official=1">
                           <hws>
                             <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Graben>
-                    </official>
-                    <inofficial>
-                      <Durchlass>
-                        <dc:elements filter="$hws_points_kind=1 and $hws_points_official=0">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
+                            <dc:attribute name="name" value="${hws_name}"/>
                           </hws>
-                        </dc:elements>
-                      </Durchlass>
-                      <Damm>
-                        <dc:elements filter="$hws_points_kind=2 and $hws_points_official=0">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Damm>
-                      <Graben>
-                        <dc:elements filter="$hws_points_kind=3 and $hws_points_official=0">
-                          <hws>
-                            <dc:attribute name="factory" value="hwsfactory"/>
-                            <dc:attribute name="name" value="${hws_points_name}"/>
-                          </hws>
-                        </dc:elements>
-                      </Graben>
-                    </inofficial>
-                  </points>
-                </dc:context>
-              </dc:macro>
-              <dc:macro name="flood-map-km">
+                      </dc:elements>
+                    </Damm>
+                    <Graben>
+                      <dc:elements filter="$hws_kind=3 and $hws_official=1">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Graben>
+                  </official>
+                  <inofficial>
+                    <Durchlass>
+                      <dc:elements filter="$hws_kind=1 and $hws_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Durchlass>
+                    <Damm>
+                      <dc:elements filter="$hws_kind=2 and $hws_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Damm>
+                    <Graben>
+                      <dc:elements filter="$hws_kind=3 and $hws_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Graben>
+                  </inofficial>
+                </lines>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-hws-points">
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                         name AS hws_points_name,
+                         official AS hws_points_official,
+                         kind_id AS hws_points_kind
+                  FROM hws_points
+                  WHERE river_id = ${river_id}
+                </dc:statement>
+                <points>
+                  <official>
+                    <Durchlass>
+                      <dc:elements filter="$hws_points_kind=1 and $hws_points_official=1">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Durchlass>
+                    <Damm>
+                      <dc:elements filter="$hws_points_kind=2 and $hws_points_official=1">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Damm>
+                    <Graben>
+                      <dc:elements filter="$hws_kind=3 and $hws_official=1">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Graben>
+                  </official>
+                  <inofficial>
+                    <Durchlass>
+                      <dc:elements filter="$hws_points_kind=1 and $hws_points_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Durchlass>
+                    <Damm>
+                      <dc:elements filter="$hws_points_kind=2 and $hws_points_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Damm>
+                    <Graben>
+                      <dc:elements filter="$hws_points_kind=3 and $hws_points_official=0">
+                        <hws>
+                          <dc:attribute name="factory" value="hwsfactory"/>
+                          <dc:attribute name="name" value="${hws_points_name}"/>
+                        </hws>
+                      </dc:elements>
+                    </Graben>
+                  </inofficial>
+                </points>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-km">
+              <dc:context>
+                <dc:statement>
+                  SELECT count(*) as km_exists
+                  FROM river_axes_km WHERE river_id = ${river_id}
+                </dc:statement>
+                 <dc:elements>
+                  <dc:if test="$km_exists>0">
+                    <km>
+                      <dc:attribute name="factory" value="wmskmfactory"/>
+                      <dc:attribute name="ids" value="${river_id}"/>
+                    </km>
+                  </dc:if>
+                </dc:elements>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-qps">
+              <dc:context>
+                <dc:statement>
+                  SELECT count(*) as km_exists
+                  FROM cross_section_tracks WHERE river_id = ${river_id}
+                </dc:statement>
+                 <dc:elements>
+                  <dc:if test="$km_exists>0">
+                    <qps>
+                      <dc:attribute name="factory" value="wmsqpsfactory"/>
+                      <dc:attribute name="ids" value="${river_id}"/>
+                    </qps>
+                  </dc:if>
+                </dc:elements>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-hydr-boundaries">
+              <hydr_boundaries_lines>
+                <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
+              </hydr_boundaries_lines>
+              <hydr_boundaries_polygons>
+                <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
+              </hydr_boundaries_polygons>
+            </dc:macro>
+            <dc:macro name="flood-map-hydr-boundaries-lines">
+              <bfg>
                 <dc:context>
                   <dc:statement>
-                    SELECT count(*) as km_exists
-                    FROM river_axes_km WHERE river_id = ${river_id}
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <km>
-                        <dc:attribute name="factory" value="wmskmfactory"/>
-                        <dc:attribute name="ids" value="${river_id}"/>
-                      </km>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </dc:macro>
-              <dc:macro name="flood-map-qps">
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists
-                    FROM cross_section_tracks WHERE river_id = ${river_id}
+                    SELECT count(*) as km_exists, name as name
+                    FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
                   </dc:statement>
                    <dc:elements>
                     <dc:if test="$km_exists>0">
-                      <qps>
-                        <dc:attribute name="factory" value="wmsqpsfactory"/>
-                        <dc:attribute name="ids" value="${river_id}"/>
-                      </qps>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </dc:macro>
-              <dc:macro name="flood-map-hydr-boundaries">
-                <hydr_boundaries_lines>
-                  <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
-                </hydr_boundaries_lines>
-                <hydr_boundaries_polygons>
-                  <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
-                </hydr_boundaries_polygons>
-              </dc:macro>
-              <dc:macro name="flood-map-hydr-boundaries-lines">
-                <bfg>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT count(*) as km_exists, name as name
-                      FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
-                    </dc:statement>
-                     <dc:elements>
-                      <dc:if test="$km_exists>0">
-                        <hydrboundary>
-                          <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
-                          <dc:attribute name="ids" value="${river_id};${name}"/>
-                          <dc:attribute name="name" value="${name}"/>
-                        </hydrboundary>
-                      </dc:if>
-                    </dc:elements>
-                  </dc:context>
-                </bfg>
-                <land>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT count(*) as km_exists, name as name
-                      FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
-                    </dc:statement>
-                     <dc:elements>
-                      <dc:if test="$km_exists>0">
-                        <hydrboundary>
-                          <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
-                          <dc:attribute name="ids" value="${river_id};${name}"/>
-                          <dc:attribute name="name" value="${name}"/>
-                        </hydrboundary>
-                      </dc:if>
-                    </dc:elements>
-                  </dc:context>
-                </land>
-              </dc:macro>
-              <dc:macro name="flood-map-hydr-boundaries-poly">
-                <bfg>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT count(*) as km_exists, name as name
-                      FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
-                    </dc:statement>
-                     <dc:elements>
-                      <dc:if test="$km_exists>0">
-                        <hws>
-                          <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
-                          <dc:attribute name="ids" value="${river_id};${name}"/>
-                          <dc:attribute name="name" value="${name}"/>
-                        </hws>
-                      </dc:if>
-                    </dc:elements>
-                  </dc:context>
-                </bfg>
-                <land>
-                  <dc:context>
-                    <dc:statement>
-                      SELECT count(*) as km_exists, name as name
-                      FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
-                    </dc:statement>
-                     <dc:elements>
-                      <dc:if test="$km_exists>0">
-                        <hws>
-                          <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
-                          <dc:attribute name="ids" value="${river_id};${name}"/>
-                          <dc:attribute name="name" value="${name}"/>
-                        </hws>
-                      </dc:if>
-                    </dc:elements>
-                  </dc:context>
-                </land>
-              </dc:macro>
-              <dc:macro name="flood-map-floodplain">
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists
-                    FROM floodplain WHERE river_id = ${river_id}
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <floodplain>
-                        <dc:attribute name="factory" value="wmsfloodplainfactory"/>
-                        <dc:attribute name="ids" value="${river_id}"/>
-                      </floodplain>
+                      <hydrboundary>
+                        <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
+                        <dc:attribute name="ids" value="${river_id};${name}"/>
+                        <dc:attribute name="name" value="${name}"/>
+                      </hydrboundary>
                     </dc:if>
                   </dc:elements>
                 </dc:context>
-              </dc:macro>
-
-              <dc:macro name="hwslines_by_kind">
-                <dc:comment>
-                  Call from a context where fed_name hws_kind hws_name and river_id is
-                  availble
-                </dc:comment>
-                <Durchlass>
-                  <dc:elements filter="$hws_kind=1">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwslinesfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
-                  </dc:elements>
-                </Durchlass>
-                <Damm>
-                  <dc:elements filter="$hws_kind=2">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwslinesfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
-                  </dc:elements>
-                </Damm>
-                <Graben>
-                  <dc:elements filter="$hws_kind=3">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwslinesfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
+              </bfg>
+              <land>
+                <dc:context>
+                  <dc:statement>
+                    SELECT count(*) as km_exists, name as name
+                    FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
+                  </dc:statement>
+                   <dc:elements>
+                    <dc:if test="$km_exists>0">
+                      <hydrboundary>
+                        <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
+                        <dc:attribute name="ids" value="${river_id};${name}"/>
+                        <dc:attribute name="name" value="${name}"/>
+                      </hydrboundary>
+                    </dc:if>
                   </dc:elements>
-                </Graben>
-              </dc:macro>
-
-              <dc:macro name="hwslines">
-                <hws_lines>
-                  <official>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT DISTINCT
-                        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
-                        WHERE river_id = ${river_id}
-                        AND hws.official=1
-                      </dc:statement>
-                      <dc:elements>
-                        <dc:context>
-                          <dc:statement>
-                            SELECT DISTINCT
-                            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
-                          </dc:statement>
-                          <fedstate>
-                            <dc:attribute name="description" value="${fed_name}"/>
-                            <dc:call-macro name="hwslines_by_kind"/>
-                          </fedstate>
-                        </dc:context>
-                      </dc:elements>
-                    </dc:context>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT distinct
-                        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
-                      </dc:statement>
-                      <hws_fed_unknown>
-                        <dc:call-macro name="hwslines_by_kind"/>
-                      </hws_fed_unknown>
-                    </dc:context>
-                  </official>
-                  <inofficial>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT DISTINCT
-                        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
-                        WHERE river_id = ${river_id}
-                        AND hws.official=0
-                      </dc:statement>
-                      <dc:elements>
-                        <dc:context>
-                          <dc:statement>
-                            SELECT DISTINCT
-                            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
-                          </dc:statement>
-                          <fedstate>
-                            <dc:attribute name="description" value="${fed_name}"/>
-                            <dc:call-macro name="hwslines_by_kind"/>
-                          </fedstate>
-                        </dc:context>
-                      </dc:elements>
-                    </dc:context>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT distinct
-                        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
-                      </dc:statement>
-                      <hws_fed_unknown>
-                        <dc:call-macro name="hwslines_by_kind"/>
-                      </hws_fed_unknown>
-                    </dc:context>
-                  </inofficial>
-              </hws_lines>
+                </dc:context>
+              </land>
             </dc:macro>
-
-              <dc:macro name="hwspoints_by_kind">
-                <dc:comment>
-                  Call from a context where fed_name hws_kind hws_name and river_id is
-                  availble
-                </dc:comment>
-                <Durchlass>
-                  <dc:elements filter="$hws_kind=1">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwspointsfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
-                  </dc:elements>
-                </Durchlass>
-                <Damm>
-                  <dc:elements filter="$hws_kind=2">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwspointsfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
-                  </dc:elements>
-                </Damm>
-                <Graben>
-                  <dc:elements filter="$hws_kind=3">
-                    <hws>
-                      <dc:attribute name="factory" value="wmshwspointsfactory"/>
-                      <dc:attribute name="ids" value="${river_id};${hws_name}"/>
-                      <dc:attribute name="name" value="${hws_name}"/>
-                    </hws>
+            <dc:macro name="flood-map-hydr-boundaries-poly">
+              <bfg>
+                <dc:context>
+                  <dc:statement>
+                    SELECT count(*) as km_exists, name as name
+                    FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
+                  </dc:statement>
+                   <dc:elements>
+                    <dc:if test="$km_exists>0">
+                      <hws>
+                        <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
+                        <dc:attribute name="ids" value="${river_id};${name}"/>
+                        <dc:attribute name="name" value="${name}"/>
+                      </hws>
+                    </dc:if>
                   </dc:elements>
-                </Graben>
-              </dc:macro>
-
-              <dc:macro name="hwspoints">
-                <hws_points>
-                  <official>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT DISTINCT
-                        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
-                        WHERE river_id = ${river_id}
-                        AND hws.official=1
-                      </dc:statement>
-                      <dc:elements>
-                        <dc:context>
-                          <dc:statement>
-                            SELECT DISTINCT
-                            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
-                          </dc:statement>
-                          <fedstate>
-                            <dc:attribute name="description" value="${fed_name}"/>
-                            <dc:call-macro name="hwspoints_by_kind"/>
-                          </fedstate>
-                        </dc:context>
-                      </dc:elements>
-                    </dc:context>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT distinct
-                        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
-                      </dc:statement>
-                      <hws_fed_unknown>
-                        <dc:call-macro name="hwspoints_by_kind"/>
-                      </hws_fed_unknown>
-                    </dc:context>
-                  </official>
-                  <inofficial>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT DISTINCT
-                        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
-                        WHERE river_id = ${river_id}
-                        AND hws.official=0
-                      </dc:statement>
-                      <dc:elements>
-                        <dc:context>
-                          <dc:statement>
-                            SELECT DISTINCT
-                            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
-                          </dc:statement>
-                          <fedstate>
-                            <dc:attribute name="description" value="${fed_name}"/>
-                            <dc:call-macro name="hwspoints_by_kind"/>
-                          </fedstate>
-                        </dc:context>
-                      </dc:elements>
-                    </dc:context>
-                    <dc:context>
-                      <dc:statement>
-                        SELECT distinct
-                        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
-                      </dc:statement>
-                      <hws_fed_unknown>
-                        <dc:call-macro name="hwspoints_by_kind"/>
-                      </hws_fed_unknown>
-                    </dc:context>
-                  </inofficial>
-              </hws_points>
+                </dc:context>
+              </bfg>
+              <land>
+                <dc:context>
+                  <dc:statement>
+                    SELECT count(*) as km_exists, name as name
+                    FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
+                  </dc:statement>
+                   <dc:elements>
+                    <dc:if test="$km_exists>0">
+                      <hws>
+                        <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
+                        <dc:attribute name="ids" value="${river_id};${name}"/>
+                        <dc:attribute name="name" value="${name}"/>
+                      </hws>
+                    </dc:if>
+                  </dc:elements>
+                </dc:context>
+              </land>
             </dc:macro>
-
-
-            <dc:macro name="flood-map-buildings">
+            <dc:macro name="flood-map-floodplain">
               <dc:context>
                 <dc:statement>
-                  SELECT DISTINCT
-                  b.kind_id AS building_kind_id,
-                  bk.name AS building_kind
-                  FROM buildings b
-                  JOIN building_kinds bk ON b.kind_id = bk.id
-                  WHERE river_id = ${river_id}
+                  SELECT count(*) as km_exists
+                  FROM floodplain WHERE river_id = ${river_id}
                 </dc:statement>
-                <dc:elements>
-                  <buildings>
-                    <dc:attribute name="description" value="${building_kind}"/>
-                    <dc:attribute name="factory" value="wmsbuildingsfactory"/>
-                    <dc:attribute name="ids" value="${river_id};${building_kind};${building_kind_id}"/>
-                  </buildings>
+                 <dc:elements>
+                  <dc:if test="$km_exists>0">
+                    <floodplain>
+                      <dc:attribute name="factory" value="wmsfloodplainfactory"/>
+                      <dc:attribute name="ids" value="${river_id}"/>
+                    </floodplain>
+                  </dc:if>
                 </dc:elements>
               </dc:context>
             </dc:macro>
-              <dc:macro name="flood-map-fixpoints">
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM fixpoints WHERE river_id = ${river_id} GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <fixpoint>
-                        <dc:attribute name="factory" value="wmsfixpointsfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name"  value="${name}"/>
-                      </fixpoint>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </dc:macro>
-              <dc:macro name="flood-map-gaugelocations">
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM gauge_location WHERE river_id = ${river_id} GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <gaugelocation>
-                        <dc:attribute name="factory" value="wmsgaugelocationfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name"  value="${name}"/>
-                      </gaugelocation>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
+
+            <dc:macro name="hwslines_by_kind">
+              <dc:comment>
+                Call from a context where fed_name hws_kind hws_name and river_id is
+                availble
+              </dc:comment>
+              <Durchlass>
+                <dc:elements filter="$hws_kind=1">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwslinesfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Durchlass>
+              <Damm>
+                <dc:elements filter="$hws_kind=2">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwslinesfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Damm>
+              <Graben>
+                <dc:elements filter="$hws_kind=3">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwslinesfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Graben>
+            </dc:macro>
+
+            <dc:macro name="hwslines">
+              <hws_lines>
+                <official>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT DISTINCT
+                      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
+                      WHERE river_id = ${river_id}
+                      AND hws.official=1
+                    </dc:statement>
+                    <dc:elements>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT DISTINCT
+                          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
+                        </dc:statement>
+                        <fedstate>
+                          <dc:attribute name="description" value="${fed_name}"/>
+                          <dc:call-macro name="hwslines_by_kind"/>
+                        </fedstate>
+                      </dc:context>
+                    </dc:elements>
+                  </dc:context>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT distinct
+                      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
+                    </dc:statement>
+                    <hws_fed_unknown>
+                      <dc:call-macro name="hwslines_by_kind"/>
+                    </hws_fed_unknown>
+                  </dc:context>
+                </official>
+                <inofficial>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT DISTINCT
+                      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
+                      WHERE river_id = ${river_id}
+                      AND hws.official=0
+                    </dc:statement>
+                    <dc:elements>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT DISTINCT
+                          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
+                        </dc:statement>
+                        <fedstate>
+                          <dc:attribute name="description" value="${fed_name}"/>
+                          <dc:call-macro name="hwslines_by_kind"/>
+                        </fedstate>
+                      </dc:context>
+                    </dc:elements>
+                  </dc:context>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT distinct
+                      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
+                    </dc:statement>
+                    <hws_fed_unknown>
+                      <dc:call-macro name="hwslines_by_kind"/>
+                    </hws_fed_unknown>
+                  </dc:context>
+                </inofficial>
+            </hws_lines>
+          </dc:macro>
+
+            <dc:macro name="hwspoints_by_kind">
+              <dc:comment>
+                Call from a context where fed_name hws_kind hws_name and river_id is
+                availble
+              </dc:comment>
+              <Durchlass>
+                <dc:elements filter="$hws_kind=1">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwspointsfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Durchlass>
+              <Damm>
+                <dc:elements filter="$hws_kind=2">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwspointsfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Damm>
+              <Graben>
+                <dc:elements filter="$hws_kind=3">
+                  <hws>
+                    <dc:attribute name="factory" value="wmshwspointsfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${hws_name}"/>
+                    <dc:attribute name="name" value="${hws_name}"/>
+                  </hws>
+                </dc:elements>
+              </Graben>
+            </dc:macro>
+
+            <dc:macro name="hwspoints">
+              <hws_points>
+                <official>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT DISTINCT
+                      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
+                      WHERE river_id = ${river_id}
+                      AND hws.official=1
+                    </dc:statement>
+                    <dc:elements>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT DISTINCT
+                          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
+                        </dc:statement>
+                        <fedstate>
+                          <dc:attribute name="description" value="${fed_name}"/>
+                          <dc:call-macro name="hwspoints_by_kind"/>
+                        </fedstate>
+                      </dc:context>
+                    </dc:elements>
+                  </dc:context>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT distinct
+                      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
+                    </dc:statement>
+                    <hws_fed_unknown>
+                      <dc:call-macro name="hwspoints_by_kind"/>
+                    </hws_fed_unknown>
+                  </dc:context>
+                </official>
+                <inofficial>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT DISTINCT
+                      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
+                      WHERE river_id = ${river_id}
+                      AND hws.official=0
+                    </dc:statement>
+                    <dc:elements>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT DISTINCT
+                          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
+                        </dc:statement>
+                        <fedstate>
+                          <dc:attribute name="description" value="${fed_name}"/>
+                          <dc:call-macro name="hwspoints_by_kind"/>
+                        </fedstate>
+                      </dc:context>
+                    </dc:elements>
+                  </dc:context>
+                  <dc:context>
+                    <dc:statement>
+                      SELECT distinct
+                      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
+                    </dc:statement>
+                    <hws_fed_unknown>
+                      <dc:call-macro name="hwspoints_by_kind"/>
+                    </hws_fed_unknown>
+                  </dc:context>
+                </inofficial>
+            </hws_points>
+          </dc:macro>
+
+
+          <dc:macro name="flood-map-buildings">
+            <dc:context>
+              <dc:statement>
+                SELECT DISTINCT
+                b.kind_id AS building_kind_id,
+                bk.name AS building_kind
+                FROM buildings b
+                JOIN building_kinds bk ON b.kind_id = bk.id
+                WHERE river_id = ${river_id}
+              </dc:statement>
+              <dc:elements>
+                <buildings>
+                  <dc:attribute name="description" value="${building_kind}"/>
+                  <dc:attribute name="factory" value="wmsbuildingsfactory"/>
+                  <dc:attribute name="ids" value="${river_id};${building_kind};${building_kind_id}"/>
+                </buildings>
+              </dc:elements>
+            </dc:context>
+          </dc:macro>
+            <dc:macro name="flood-map-fixpoints">
+              <dc:context>
+                <dc:statement>
+                  SELECT count(*) as km_exists, name as name
+                  FROM fixpoints WHERE river_id = ${river_id} GROUP BY name
+                </dc:statement>
+                 <dc:elements>
+                  <dc:if test="$km_exists>0">
+                    <fixpoint>
+                      <dc:attribute name="factory" value="wmsfixpointsfactory"/>
+                      <dc:attribute name="ids" value="${river_id};${name}"/>
+                      <dc:attribute name="name"  value="${name}"/>
+                    </fixpoint>
+                  </dc:if>
+                </dc:elements>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-gaugelocations">
+              <dc:context>
+                <dc:statement>
+                  SELECT count(*) as km_exists, name as name
+                  FROM gauge_location WHERE river_id = ${river_id} GROUP BY name
+                </dc:statement>
+                 <dc:elements>
+                  <dc:if test="$km_exists>0">
+                    <gaugelocation>
+                      <dc:attribute name="factory" value="wmsgaugelocationfactory"/>
+                      <dc:attribute name="ids" value="${river_id};${name}"/>
+                      <dc:attribute name="name"  value="${name}"/>
+                    </gaugelocation>
+                  </dc:if>
+                </dc:elements>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-uesk">
+              <uesk>
+                <calculations>
+                  <current>
+                    <bfg>
+                      <dc:context>
+                        <dc:statement>
+                            SELECT count(*) as uesg_exist, name as name
+                            FROM floodmaps
+                            WHERE river_id = ${river_id} AND kind = 111
+                            GROUP BY name, kind
+                        </dc:statement>
+                        <dc:elements>
+                          <dc:if test="$uesg_exist>0">
+                            <floodmaps>
+                              <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
+                              <dc:attribute name="ids" value="${river_id};${name}"/>
+                              <dc:attribute name="name" value="${name}"/>
+                            </floodmaps>
+                          </dc:if>
+                        </dc:elements>
+                      </dc:context>
+                    </bfg>
+                    <land>
+                      <dc:context>
+                        <dc:statement>
+                            SELECT count(*) as uesg_exist, name as name
+                            FROM floodmaps
+                            WHERE river_id = ${river_id} AND kind = 112
+                            GROUP BY name, kind
+                        </dc:statement>
+                        <dc:elements>
+                          <dc:if test="$uesg_exist>0">
+                            <floodmaps>
+                              <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
+                              <dc:attribute name="ids" value="${river_id};${name}"/>
+                              <dc:attribute name="name" value="${name}"/>
+                            </floodmaps>
+                          </dc:if>
+                        </dc:elements>
+                      </dc:context>
+                    </land>
+                  </current>
+                  <potentiel>
+                    <bfg>
+                      <dc:context>
+                        <dc:statement>
+                            SELECT count(*) as uesg_exist, name as name
+                            FROM floodmaps
+                            WHERE river_id = ${river_id} AND kind = 121
+                            GROUP BY name, kind
+                        </dc:statement>
+                        <dc:elements>
+                          <dc:if test="$uesg_exist>0">
+                            <floodmaps>
+                              <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
+                              <dc:attribute name="ids" value="${river_id};${name}"/>
+                              <dc:attribute name="name" value="${name}"/>
+                            </floodmaps>
+                          </dc:if>
+                        </dc:elements>
+                      </dc:context>
+                    </bfg>
+                    <land>
+                      <dc:context>
+                        <dc:statement>
+                            SELECT count(*) as uesg_exist, name as name
+                            FROM floodmaps
+                            WHERE river_id = ${river_id} AND kind = 122
+                            GROUP BY name, kind
+                        </dc:statement>
+                        <dc:elements>
+                          <dc:if test="$uesg_exist>0">
+                            <floodmaps>
+                              <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
+                              <dc:attribute name="ids" value="${river_id};${name}"/>
+                              <dc:attribute name="name" value="${name}"/>
+                            </floodmaps>
+                          </dc:if>
+                        </dc:elements>
+                      </dc:context>
+                    </land>
+                  </potentiel>
+                </calculations>
+              </uesk>
+            </dc:macro>
+            <dc:macro name="flood-map-complete">
+                <buildings>
+                  <dc:call-macro name="flood-map-buildings"/>
+                </buildings>
+                <catchments>
+                  <dc:call-macro name="flood-map-catchments"/>
+                </catchments>
+                <fixpoints>
+                  <dc:call-macro name="flood-map-fixpoints"/>
+                </fixpoints>
+                <hydrboundaries>
+                  <dc:call-macro name="flood-map-hydr-boundaries"/>
+                  <dc:call-macro name="flood-map-floodplain"/>
+                </hydrboundaries>
+                <kilometrage>
+                    <riveraxis>
+                        <dc:attribute name="factory" value="riveraxis"/>
+                        <dc:attribute name="ids" value="${river_id}"/>
+                    </riveraxis>
+                  <dc:call-macro name="flood-map-km"/>
+                  <dc:call-macro name="flood-map-qps"/>
+                </kilometrage>
+                <hws>
+                  <dc:call-macro name="hwslines"/>
+                  <dc:call-macro name="hwspoints"/>
+                </hws>
+                <dc:call-macro name="flood-map-uesk"/>
+                <gaugelocations>
+                  <dc:call-macro name="flood-map-gaugelocations"/>
+                </gaugelocations>
+                <rastermap>
+                  <background>
+                    <dc:attribute name="factory" value="wmsbackground"/>
+                    <dc:attribute name="ids" value="${river_id}"/>
+                  </background>
+                </rastermap>
               </dc:macro>
-              <dc:macro name="flood-map-uesk">
-                <uesk>
-                  <calculations>
-                    <current>
-                      <bfg>
-                        <dc:context>
-                          <dc:statement>
-                              SELECT count(*) as uesg_exist, name as name
-                              FROM floodmaps
-                              WHERE river_id = ${river_id} AND kind = 111
-                              GROUP BY name, kind
-                          </dc:statement>
-                          <dc:elements>
-                            <dc:if test="$uesg_exist>0">
-                              <floodmaps>
-                                <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
-                                <dc:attribute name="ids" value="${river_id};${name}"/>
-                                <dc:attribute name="name" value="${name}"/>
-                              </floodmaps>
-                            </dc:if>
-                          </dc:elements>
-                        </dc:context>
-                      </bfg>
-                      <land>
-                        <dc:context>
-                          <dc:statement>
-                              SELECT count(*) as uesg_exist, name as name
-                              FROM floodmaps
-                              WHERE river_id = ${river_id} AND kind = 112
-                              GROUP BY name, kind
-                          </dc:statement>
-                          <dc:elements>
-                            <dc:if test="$uesg_exist>0">
-                              <floodmaps>
-                                <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
-                                <dc:attribute name="ids" value="${river_id};${name}"/>
-                                <dc:attribute name="name" value="${name}"/>
-                              </floodmaps>
-                            </dc:if>
-                          </dc:elements>
-                        </dc:context>
-                      </land>
-                    </current>
-                    <potentiel>
-                      <bfg>
-                        <dc:context>
-                          <dc:statement>
-                              SELECT count(*) as uesg_exist, name as name
-                              FROM floodmaps
-                              WHERE river_id = ${river_id} AND kind = 121
-                              GROUP BY name, kind
-                          </dc:statement>
-                          <dc:elements>
-                            <dc:if test="$uesg_exist>0">
-                              <floodmaps>
-                                <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
-                                <dc:attribute name="ids" value="${river_id};${name}"/>
-                                <dc:attribute name="name" value="${name}"/>
-                              </floodmaps>
-                            </dc:if>
-                          </dc:elements>
-                        </dc:context>
-                      </bfg>
-                      <land>
-                        <dc:context>
-                          <dc:statement>
-                              SELECT count(*) as uesg_exist, name as name
-                              FROM floodmaps
-                              WHERE river_id = ${river_id} AND kind = 122
-                              GROUP BY name, kind
-                          </dc:statement>
-                          <dc:elements>
-                            <dc:if test="$uesg_exist>0">
-                              <floodmaps>
-                                <dc:attribute name="factory" value="wmsfloodmapsfactory"/>
-                                <dc:attribute name="ids" value="${river_id};${name}"/>
-                                <dc:attribute name="name" value="${name}"/>
-                              </floodmaps>
-                            </dc:if>
-                          </dc:elements>
-                        </dc:context>
-                      </land>
-                    </potentiel>
-                  </calculations>
-                </uesk>
-              </dc:macro>
-              <dc:macro name="flood-map-complete">
-                  <buildings>
-                    <dc:call-macro name="flood-map-buildings"/>
-                  </buildings>
-                  <catchments>
-                    <dc:call-macro name="flood-map-catchments"/>
-                  </catchments>
-                  <fixpoints>
-                    <dc:call-macro name="flood-map-fixpoints"/>
-                  </fixpoints>
-                  <hydrboundaries>
-                    <dc:call-macro name="flood-map-hydr-boundaries"/>
-                    <dc:call-macro name="flood-map-floodplain"/>
-                  </hydrboundaries>
-                  <kilometrage>
-                      <riveraxis>
-                          <dc:attribute name="factory" value="riveraxis"/>
-                          <dc:attribute name="ids" value="${river_id}"/>
-                      </riveraxis>
-                    <dc:call-macro name="flood-map-km"/>
-                    <dc:call-macro name="flood-map-qps"/>
-                  </kilometrage>
-                  <hws>
-                    <dc:call-macro name="hwslines"/>
-                    <dc:call-macro name="hwspoints"/>
-                  </hws>
-                  <dc:call-macro name="flood-map-uesk"/>
-                  <gaugelocations>
-                    <dc:call-macro name="flood-map-gaugelocations"/>
-                  </gaugelocations>
-                  <rastermap>
-                      <background>
-                          <dc:attribute name="factory" value="wmsbackground"/>
-                          <dc:attribute name="ids" value="${river_id}"/>
-                      </background>
-                  </rastermap>
-              </dc:macro>
-          </dc:if>
-          <dc:if test="dc:contains($artifact-outs, 'minfo-heights')">
-            <dc:call-macro name="minfo-heights"/>
-            <dc:macro name="minfo-heights">
-              <bedheights>
-                <dc:call-macro name="bed-heights-single"/>
-                <dc:call-macro name="bed-heights-epoch"/>
-              </bedheights>
-            </dc:macro>
-          </dc:if>
-          <dc:if test="dc:contains($artifact-outs, 'minfo-heights-epoch')">
+        </dc:if>
+        <dc:if test="dc:contains($artifact-outs, 'minfo-heights')">
+          <dc:call-macro name="minfo-heights"/>
+          <dc:macro name="minfo-heights">
             <bedheights>
+              <dc:call-macro name="bed-heights-single"/>
               <dc:call-macro name="bed-heights-epoch"/>
             </bedheights>
-          </dc:if>
-          <dc:macro name="bed-heights-single">
-            <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}
-                </dc:statement>
-                <dc:elements>
-                  <height>
-                    <dc:attribute name="factory" value="bedheight"/>
-                    <dc:attribute name="ids" value="bedheight-single-${bedh_id}-${bedh_year}"/>
-                    <dc:attribute name="description" value="${bedh_descr}"/>
-                  </height>
-                </dc:elements>
-              </dc:context>
-            </single>
           </dc:macro>
-          <dc:macro name="bed-heights-epoch">
-            <epoch>
-              <dc:context>
-                <dc:statement>
-                  SELECT id               AS bedh_id,
-                         time_interval_id AS bedh_interval_id,
-                         description      AS bedh_descr
-                  FROM bed_height_epoch WHERE river_id = ${river_id}
-                </dc:statement>
-                <dc:elements>
-                  <height>
-                    <dc:attribute name="factory" value="bedheight"/>
-                    <dc:attribute name="ids" value="bedheight-epoch-${bedh_id}-${bedh_interval_id}"/>
-                    <dc:attribute name="description" value="${bedh_descr}"/>
-                  </height>
-                </dc:elements>
-              </dc:context>
-            </epoch>
-          </dc:macro>
-        </river>
+        </dc:if>
+        <dc:if test="dc:contains($artifact-outs, 'minfo-heights-epoch')">
+          <bedheights>
+            <dc:call-macro name="bed-heights-epoch"/>
+          </bedheights>
+        </dc:if>
+        <dc:macro name="bed-heights-single">
+          <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}
+              </dc:statement>
+              <dc:elements>
+                <height>
+                  <dc:attribute name="factory" value="bedheight"/>
+                  <dc:attribute name="ids" value="bedheight-single-${bedh_id}-${bedh_year}"/>
+                  <dc:attribute name="description" value="${bedh_descr}"/>
+                </height>
+              </dc:elements>
+            </dc:context>
+          </single>
+        </dc:macro>
+        <dc:macro name="bed-heights-epoch">
+          <epoch>
+            <dc:context>
+              <dc:statement>
+                SELECT id               AS bedh_id,
+                       time_interval_id AS bedh_interval_id,
+                       description      AS bedh_descr
+                FROM bed_height_epoch WHERE river_id = ${river_id}
+              </dc:statement>
+              <dc:elements>
+                <height>
+                  <dc:attribute name="factory" value="bedheight"/>
+                  <dc:attribute name="ids" value="bedheight-epoch-${bedh_id}-${bedh_interval_id}"/>
+                  <dc:attribute name="description" value="${bedh_descr}"/>
+                </height>
+              </dc:elements>
+            </dc:context>
+          </epoch>
+        </dc:macro>
       </dc:elements>
     </dc:context>
   </dc:macro>

http://dive4elements.wald.intevation.org