diff artifacts/doc/conf/meta-data.xml @ 7961:598e4bec920b

New macros for bed height differneces.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 20 Jun 2014 16:33:09 +0200
parents a4764ab23eef
children 7f1143972f16
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Fri Jun 20 13:45:54 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Fri Jun 20 16:33:09 2014 +0200
@@ -132,6 +132,9 @@
               <dc:iterate var="out" container="artifact-outs">
                 <dc:message>Non Rec out iteration for: {$out}</dc:message>
                 <dc:choose>
+                  <dc:when test="$out = 'minfo-heights-diff'">
+                    <dc:call-macro name="minfo-heights-diff"/>
+                  </dc:when>
                   <dc:when test="$out = 'cross_section'">
                     <dc:call-macro name="basedata_0"/>
                     <dc:call-macro name="basedata_1_additionals"/>
@@ -1718,6 +1721,104 @@
       </rastermap>
     </dc:macro>
 
+    <dc:macro name="minfo-heights-diff">
+      <dc:message>blablub</dc:message>
+      <dc:call-macro name="minfo-heights-years">
+        <dc:context>
+          <dc:statement>
+            WITH sta
+                 AS (SELECT bhs.id,
+                            bhs.description,
+                            bhsv.station,
+                            bhs.year
+                     FROM   bed_height_single bhs
+                            JOIN bed_height_single_values bhsv
+                              ON bhsv.bed_height_single_id = bhs.id
+                     WHERE  bhs.river_id = ${river_id}
+                            AND bhs.year BETWEEN ${year_from} AND ${year_to}),
+                 csta
+                 AS (SELECT b1.id          AS id1,
+                            b1.description AS b1desc,
+                            b1.year        AS b1year,
+                            b2.id          AS id2,
+                            b2.description AS b2desv,
+                            b2.year        AS b2year
+                     FROM   sta b1
+                            JOIN sta b2
+                              ON b1.station = b2.station
+                                 AND b1.id &lt; b2.id)
+            SELECT id1, b1desc, b1year,
+                   id2, b2desc, b2year
+            FROM   csta
+          </dc:statement>
+          <dc:if test="dc:has-result()">
+            <bedheights>
+              <dc:call-macro name="bed-heights-single-diff"/>
+              <dc:call-macro name="bed-heights-epoch-diff"/>
+            </bedheights>
+          </dc:if>
+        </dc:context>
+      </dc:call-macro>
+    </dc:macro>
+
+    <dc:macro name="bed-heights-single-diff">
+      <dc:filter expr="not(contains(lower-case($b1desc), 'epoche') or contains(lower-case($b2desc), 'epoche'))">
+        <years>
+          <dc:call-macro name="bed-heights-diff-tree"/>
+        </years>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="bed-heights-epoch-diff">
+      <dc:filter expr="contains(lower-case($b1desc), 'epoche') and contains(lower-case($b2desc), 'epoche')">
+        <epochs>
+          <dc:call-macro name="bed-heights-diff-tree"/>
+        </epochs>
+      </dc:filter>
+    </dc:macro>
+
+    <dc:macro name="minfo-heights-diff-tree">
+      <dc:comment>TODO: We need to group for year1 and year2</dc:comment>
+      <dc:group expr="$b1year">
+        <dc:element name="${dc:group-key()}">
+          <dc:comment>TODO: Better structure</dc:comment>
+          <dc:for-each>
+            <dc:comment>A - B</dc:comment>
+            <height factory="bedheight"
+                    target_out="{$out}"
+                    ids="bedheight-single-{$b1id}-{$b2id}"
+                    description="{$b1desc} - {$b2desc}"/>
+          </dc:for-each>
+          <dc:for-each>
+            <dc:comment>B - A</dc:comment>
+            <height factory="bedheight"
+                    target_out="{$out}"
+                    ids="bedheight-single-{$b2id}-{$b1id}"
+                    description="{$b2desc} - {$b1desc}"/>
+          </dc:for-each>
+        </dc:element>
+      </dc:group>
+      <dc:group expr="$b2year">
+        <dc:element name="${dc:group-key()}">
+          <dc:comment>TODO: Better structure</dc:comment>
+          <dc:for-each>
+            <dc:comment>A - B</dc:comment>
+            <height factory="bedheight"
+                    target_out="{$out}"
+                    ids="bedheight-single-{$b1id}-{$b2id}"
+                    description="{$b1desc} - {$b2desc}"/>
+          </dc:for-each>
+          <dc:for-each>
+            <dc:comment>B - A</dc:comment>
+            <height factory="bedheight"
+                    target_out="{$out}"
+                    ids="bedheight-single-{$b2id}-{$b1id}"
+                    description="{$b2desc} - {$b1desc}"/>
+          </dc:for-each>
+        </dc:element>
+      </dc:group>
+    </dc:macro>
+
     <dc:macro name="minfo-heights">
       <dc:call-macro name="minfo-heights-years">
         <bedheights>

http://dive4elements.wald.intevation.org