diff artifacts/doc/conf/meta-data.xml @ 8241:a65afd85d516

Suggestion: Load official epochs via recommendations instead of a pseudo-calculation.
author Tom Gottfried <tom@intevation.de>
date Tue, 09 Sep 2014 10:53:50 +0200
parents 1cd7225df846
children 9bb8d581f6ca
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Mon Sep 08 19:48:17 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Tue Sep 09 10:53:50 2014 +0200
@@ -115,6 +115,7 @@
                   </dc:when>
                   <dc:when test="$out = 'sedimentload_ls'">
                     <dc:call-macro name="annotations"/>
+                    <dc:call-macro name="sedimentload_off_epochs"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_longitudinal_section'">
                     <dc:call-macro name="annotations"/>
@@ -1441,7 +1442,7 @@
              </dc:choose>
              <dc:if test="$kind = 'official'">
                <dc:variable name="info" type="string"
-                            expr="concat('Amtliche Epoche&lt;BR&gt;', $info)"/>
+                            expr="concat('Amtliche Epoche&lt;BR&gt;', dc:get('info'))"/>
              </dc:if>
              <dc:macro-body/>
            </dc:for-each>
@@ -3073,6 +3074,85 @@
       </dc:if>
     </dc:macro>
 
+
+    <dc:macro name="sedimentload_off_epoch_filter">
+        <dc:if test="dc:has-result()">
+          <dc:if test="string-length(dc:get('epochs')) &gt; 0">
+            <dc:variable name="start" type="number"
+                         expr="dc:min-number(dc:find-all('\d{4}', $epochs))"/>
+            <dc:variable name="end" type="number"
+                         expr="dc:max-number(dc:find-all('\d{4}', $epochs))"/>
+          </dc:if>
+          <dc:filter expr="not(number($end) &lt;
+                               number(dc:date-format('yyyy', $startyear))
+                             or number($start) &gt;
+                               number(dc:date-format('yyyy', $endyear)))">
+            <dc:macro-body/>
+          </dc:filter>
+        </dc:if>
+    </dc:macro>
+
+    <dc:macro name="sedimentload_off_epochs">
+      <dc:variable name="sq_time_id" type="number" expr="number($sq_ti_id)"/>
+      <dc:context>
+        <dc:comment> data at measurement stations </dc:comment>
+        <dc:statement>
+          SELECT DISTINCT
+              sl.id               AS slid,
+              slk.kind            AS kind,
+              ti.start_time       AS startyear,
+              ti.stop_time        AS endyear,
+              gf.name             AS fraction
+          FROM     sediment_load sl
+              JOIN sediment_load_kinds slk ON slk.id = sl.kind
+              JOIN sediment_load_values slv
+                  ON sl.id = slv.sediment_load_id
+              JOIN measurement_station ms
+                  ON ms.id = slv.measurement_station_id
+              JOIN rivers r ON ms.river_id = r.id
+              JOIN time_intervals ti ON sl.time_interval_id = ti.id
+              JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
+          WHERE r.id = ${river_id}
+              AND sq_time_interval_id = ${sq_time_id}
+              AND ms.station BETWEEN ${fromkm} AND ${tokm}
+              AND slk.kind = 'official'
+        </dc:statement>
+        <dc:call-macro name="sedimentload_off_epoch_filter">
+          <dc:call-macro name="loads">
+            <dc:call-macro name="load"/>
+          </dc:call-macro>
+        </dc:call-macro>
+      </dc:context>
+      <dc:context>
+        <dc:comment> longitudinal sections </dc:comment>
+        <dc:statement>
+          SELECT DISTINCT
+              sl.id               AS slid,
+              slk.kind            AS kind,
+              ti.start_time       AS startyear,
+              ti.stop_time        AS endyear,
+              sq_time_interval_id AS sqid,
+              gf.name             AS fraction
+          FROM     sediment_load_ls sl
+              JOIN sediment_load_kinds slk ON slk.id = sl.kind
+              JOIN rivers r ON sl.river_id = r.id
+              JOIN sediment_load_ls_values slv
+                  ON sl.id = slv.sediment_load_ls_id
+              JOIN time_intervals ti ON sl.time_interval_id = ti.id
+              JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
+          WHERE   r.id = ${river_id}
+              AND sq_time_interval_id = ${sq_time_id}
+              AND slv.station BETWEEN ${fromkm} AND ${tokm}
+              AND slk.kind = 'official'
+        </dc:statement>
+        <dc:call-macro name="sedimentload_off_epoch_filter">
+          <dc:call-macro name="loads">
+            <dc:call-macro name="load_ls"/>
+          </dc:call-macro>
+        </dc:call-macro>
+      </dc:context>
+    </dc:macro>
+
     <!-- Common stuff -->
 
     <dc:macro name="km-filtered-wsts">

http://dive4elements.wald.intevation.org