changeset 8431:f1bc081210ea

Load sounding width via recommendations for bed height differences and cleanup and fix related bed height macros.
author Tom Gottfried <tom@intevation.de>
date Fri, 17 Oct 2014 18:20:33 +0200
parents 64e527208942
children e54641c44d6d
files artifacts/doc/conf/meta-data.xml artifacts/doc/datacage_ref_de.rst
diffstat 2 files changed, 48 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Fri Oct 17 17:39:34 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Fri Oct 17 18:20:33 2014 +0200
@@ -58,6 +58,7 @@
                   <dc:when test="$out = 'bed_difference_year'">
                     <dc:call-macro name="annotations"/>
                     <dc:call-macro name="basedata_6_delta_w"/>
+                    <dc:call-macro name="sounding-width-recommendations"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_height_year'">
                     <dc:call-macro name="annotations"/>
@@ -1798,9 +1799,8 @@
 
     <!-- bed heights -->
     <dc:macro name="minfo-heights-diff">
-      <dc:call-macro name="minfo-heights-years">
-        <dc:context>
-          <dc:statement>
+      <dc:context>
+        <dc:statement>
             WITH sta
                  AS (SELECT bhs.id,
                             bhs.description,
@@ -1825,15 +1825,14 @@
                    b2id, b2desc, b2year
             FROM   csta
             ORDER BY b1desc, b2desc
-          </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: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:macro>
 
     <dc:macro name="bed-heights-single-diff">
@@ -1882,56 +1881,6 @@
       </dc:group>
     </dc:macro>
 
-    <dc:macro name="minfo-heights-years">
-        <dc:comment>
-        The input here is a list differenc ids noted in the
-        form:
-        [2726deb8-e71f-4acc-bc57-c7ae6062df2e;bedheight;0;FP-Mai2006vHW]#
-        [df79ba16-7e2a-43d6-b15b-34dca1fd9bff;bedheight;0;FP-2007_0-286]#
-        [027ba0ac-5453-4e63-a99b-1feeb82a4e06;bedheight;0;QP-2002nHW]#
-        [26b9b6eb-1ce5-4011-83c7-b88e15e99870;bedheight;0;FP-Nov2008]
-
-        (Linebreaks inserted for readability)
-
-        We take this string and look for all 4 digit numbers (\d{4}) after
-        we have removed the uuids from the input string (dc:replace all).
-        On this list of numbers we use the dc:min/max-number functions to
-        get the extreme values and interpret the result as a number.
-      </dc:comment>
-      <dc:choose>
-        <dc:when test="dc:contains($parameters, 'diffids')">
-          <dc:variable name="year_from" expr="
-            dc:min-number(
-              dc:find-all(
-                '\d{4}',
-                dc:replace-all(
-                  $diffids,
-                  '[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}', '')))"
-            type="number"/>
-          <dc:if test="$year_from = dc:min-number('x')">
-              <dc:variable name="year_from" expr="0" type="number"/>
-          </dc:if>
-          <dc:variable name="year_to" expr="
-            dc:max-number(
-              dc:find-all(
-                '\d{4}',
-                dc:replace-all(
-                  $diffids,
-                  '[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}', '')))"
-            type="number"/>
-          <dc:if test="$year_to = dc:max-number('x')">
-              <dc:variable name="year_to" expr="9999" type="number"/>
-          </dc:if>
-        </dc:when>
-        <dc:otherwise>
-          <dc:comment>Just show everything</dc:comment>
-          <dc:variable name="year_to" expr="9999" type="number"/>
-          <dc:variable name="year_from" expr="0" type="number"/>
-        </dc:otherwise>
-      </dc:choose>
-      <dc:macro-body/>
-    </dc:macro>
-
     <dc:macro name="minfo-heights">
       <bedheights>
         <dc:call-macro name="bed-heights-single"/>
@@ -1977,6 +1926,36 @@
       </epoch>
     </dc:macro>
 
+    <dc:macro name="sounding-width-factory">
+      <dc:for-each>
+        <height factory="bedheight"
+                target_out="{$out}"
+                ids="bedheight-soundings-{$bedh_id}-{$bedh_year}"
+                info="{$info}"
+                description="{$bedh_descr}"/>
+      </dc:for-each>
+    </dc:macro>
+
+    <dc:macro name="sounding-width">
+      <dc:context>
+        <dc:call-macro name="bed-heights-statement"/>
+        <dc:if test="dc:has-result()">
+          <soundings_width>
+            <dc:call-macro name="sounding-width-factory"/>
+          </soundings_width>
+        </dc:if>
+      </dc:context>
+    </dc:macro>
+
+    <dc:macro name="sounding-width-recommendations">
+      <dc:context>
+        <dc:call-macro name="bed-heights-statement"/>
+        <dc:filter expr="dc:contains($diffids, concat(';', $bedh_descr, ']'))">
+          <dc:call-macro name="sounding-width-factory"/>
+        </dc:filter>
+      </dc:context>
+    </dc:macro>
+
     <dc:macro name="bed-heights-statement">
       <dc:statement>
         SELECT bhs.id       AS bedh_id,
@@ -1990,11 +1969,12 @@
             '&lt;BR&gt;Strecke: ' || round(r.a, 1) || '-' || round(r.b, 1) ||
             '&lt;BR&gt;Auswerter: ' || bhs.evaluation_by AS info
         FROM bed_height_single bhs
-        JOIN bed_height_type bht ON bht.id = bhs.type_id
-        JOIN location_system ls ON ls.id = location_system_id
-        JOIN elevation_model cur_em ON cur_em.id = cur_elevation_model_id
-        JOIN elevation_model old_em ON old_em.id = old_elevation_model_id
-        JOIN ranges r ON r.id = range_id
+            JOIN bed_height_type bht ON bht.id = bhs.type_id
+            JOIN location_system ls ON ls.id = location_system_id
+            JOIN elevation_model cur_em ON cur_em.id = cur_elevation_model_id
+            LEFT JOIN elevation_model old_em
+                ON old_em.id = old_elevation_model_id
+            LEFT JOIN ranges r ON r.id = range_id
         WHERE bhs.river_id = ${river_id}
       </dc:statement>
     </dc:macro>
@@ -2091,23 +2071,6 @@
       </dc:context>
     </dc:macro>
 
-    <dc:macro name="sounding-width">
-      <dc:context>
-        <dc:call-macro name="bed-heights-statement"/>
-        <dc:if test="dc:has-result()">
-          <soundings_width>
-            <dc:for-each>
-                    <height factory="bedheight"
-                      target_out="{$out}"
-                      ids="bedheight-soundings-{$bedh_id}-{$bedh_year}"
-                      info="{$info}"
-                      description="{$bedh_descr}"/>
-            </dc:for-each>
-          </soundings_width>
-        </dc:if>
-      </dc:context>
-    </dc:macro>
-
     <dc:macro name="sqrelations">
       <dc:context>
         <dc:statement>
--- a/artifacts/doc/datacage_ref_de.rst	Fri Oct 17 17:39:34 2014 +0200
+++ b/artifacts/doc/datacage_ref_de.rst	Fri Oct 17 18:20:33 2014 +0200
@@ -670,7 +670,7 @@
 ``dc:contains`` Prüfen, ob Suchbegriff in einer Liste vorhanden ist
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-``dc:contains(Nadel, Heuhaufen)`` prüft ob das Suchobjekt Nadel in
+``dc:contains(Heuhaufen, Nadel)`` prüft ob das Suchobjekt Nadel in
 der Liste Heufhaufen zu finden ist. Liefert logisch wahr falls die
 Nadel gefunden wurde, ansonsten logisch falsch. Typischer Anwendungsfall:
 ``dc:contains($outs, 'longitudinal-section')`` prüft, ob in der Liste

http://dive4elements.wald.intevation.org