[PATCH 1 of 2] New macros for bed height differneces

Wald Commits scm-commit at wald.intevation.org
Fri Jun 20 16:33:39 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1403274789 -7200
# Node ID 598e4bec920b2a216c7388d99fffefbbe59692de
# Parent  8e320b5933dea471672ff2c2624a0fbedb8cdcd1
New macros for bed height differneces.

diff -r 8e320b5933de -r 598e4bec920b artifacts/doc/conf/meta-data.xml
--- 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 < 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>


More information about the Dive4Elements-commits mailing list