[PATCH] Implemented datacage for sinfo - ueberflutungsdauern

Wald Commits scm-commit at wald.intevation.org
Fri Oct 19 17:19:15 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1539962349 -7200
# Node ID 669ab639c56bfac31bd59935c3ac99d66f440b85
# Parent  26ac94cff0b6137627473b6d58d1493e2928eda3
Implemented datacage for sinfo - ueberflutungsdauern
Implemented h/Q  mainvalues in sinfo - ueberflutungsdauern chart

diff -r 26ac94cff0b6 -r 669ab639c56b artifacts/doc/conf/meta-data.xml
--- a/artifacts/doc/conf/meta-data.xml	Fri Oct 19 16:27:07 2018 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Fri Oct 19 17:19:09 2018 +0200
@@ -142,10 +142,9 @@
                   <dc:when test="$out = 'sinfo_flood_height'">
                     <dc:call-macro name="annotations"/>
                   </dc:when>
-                  <!--TODO sinfo_floodduration_curve: mainvalues wie in winfo-duration_curve unterstuetzen -->
-                  <!--dc:when test="$out = 'sinfo_floodduration_curve'">
+                  <dc:when test="$out = 'sinfo_floodduration_curve'">
                     <dc:call-macro name="mainvalues" />
-                    </dc:when -->
+                  </dc:when>
                   <dc:when test="$out = 'uinfo_salix_line'">
                     <dc:call-macro name="annotations"/>
                   </dc:when>
@@ -260,10 +259,7 @@
                   </dc:when>
                   <dc:comment> Duration curve </dc:comment>
                   <dc:when test="$out = '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:call-macro name="duration_curve_system"/>
                   </dc:when>
                   <dc:comment> Reference curve </dc:comment>
                   <dc:when test="$out = 'reference_curve'">
@@ -329,14 +325,9 @@
                   <dc:when test="$out = 'sinfo_flood_height'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
-                  <!--TODO sinfo_floodduration_curve: mainvalues wie in winfo-duration_curve unterstuetzen -->
-                  <!--dc:when test="$out = 'sinfo_floodduration_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:when -->
-
+                  <dc:when test="$out = 'sinfo_floodduration_curve'">
+                    <dc:call-macro name="floodduration_curve_system" />
+                  </dc:when>
                   <dc:when test="$out = 'uinfo_salix_line'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
@@ -450,15 +441,23 @@
                     <dc:when test="$out = 'sinfo_flood_duration'">
                       <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
+                    <dc:when test="$out = 'sinfo_floodduration_curve'">
+                      <dc:call-macro name="floodduration-curve-user"/>
+                    </dc:when>
                     <dc:when test="$out = 'sinfo_flood_height'">
                       <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
+                    <dc:when test="$out = 'sinfo_flowdepth_waterlevels'">
+                      <dc:call-macro name="longitudinal-section-fix-vollmer_w"/>
+                    </dc:when>
+
                     <dc:when test="$out = 'uinfo_salix_line'">
                       <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
                     <dc:when test="$out = 'uinfo.inundation_duration.vegzoneselect'">
                       <dc:call-macro name="vegetationzones"/>
                     </dc:when>
+
                     <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
                       <dc:call-macro name="longitudinal-section-user-prototype"/>
                     </dc:when>
@@ -497,7 +496,7 @@
                     </dc:when>
                     <dc:comment> Duration curve </dc:comment>
                     <dc:when test="$out = 'duration_curve'">
-                      <dc:call-macro name="duration-curve"/>
+                      <dc:call-macro name="duration-curve-user"/>
                     </dc:when>
                     <dc:comment> Reference curve </dc:comment>
                     <dc:when test="$out = 'reference_curve'">
@@ -510,10 +509,6 @@
                     <dc:when test="$out = 'map'">
                       <dc:call-macro name="flood-map"/>
                     </dc:when>
-
-                    <dc:when test="$out = 'sinfo_flowdepth_waterlevels'">
-                      <dc:call-macro name="longitudinal-section-fix-vollmer_w"/>
-                    </dc:when>
                   </dc:choose>
                 </dc:iterate>
               </dc:otherwise>
@@ -881,18 +876,30 @@
       </dc:filter>
     </dc:macro>
 
-    <dc:macro name="duration-curve">
-      <dc:filter expr="$facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w'">
+    <!-- Unterschreitungsdauern aus WINFO -->
+    <dc:macro name="duration-curve-user">
+      <dc:call-macro name="duration-curve-user_winfo-duration-curve"/>
+    </dc:macro>
+
+    <!-- Überschrautungsdauern aus SINFO -->
+    <dc:macro name="floodduration-curve-user">
+      <dc:call-macro name="duration-curve-user_sinfo-flood-duration"/>
+    </dc:macro>
+
+    <dc:macro name="duration-curve-user_winfo-duration-curve">
+      <!-- Restults of WINFO-DurationCurve calculation -->
+      <dc:filter expr="$a_state = 'state.winfo.durationcurve' and ( $facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w' )">
         <dc:if test="dc:has-result()">
+          <!-- FIXME: this label is wrong, should be rather 'winfo - duration curve' or something -->
           <computed_discharge_curves>
             <dc:for-each>
               <dc:element name="${facet_name}">
                 <dc:attribute name="description" value="${facet_description}"/>
                 <dc:attribute name="factory" value="winfo"/>
                 <dc:attribute name="target_out" value="${out}"/>
-                <dc:attribute name="artifact-id" value="${a_id}"/>
-                <dc:attribute name="ids" value="${a_id}"/>
-                <dc:attribute name="out" value="duration_curve"/>
+                <dc:attribute name="artifact-id" value="${a_gid}"/>
+                <dc:attribute name="ids" value="${facet_num}"/>
+                <dc:attribute name="out" value="${out_name}"/>
               </dc:element>
             </dc:for-each>
           </computed_discharge_curves>
@@ -900,6 +907,31 @@
       </dc:filter>
     </dc:macro>
 
+    <dc:macro name="duration-curve-user_sinfo-flood-duration">
+      <!-- Restults of SINFO-Überflutungsdauern-Aue calculation -->
+      <dc:filter expr="$a_state = 'state.sinfo.flood_duration' and $out_name = 'sinfo_floodduration_curve'">
+      <!-- FIXME: group by calculation? -->
+        <dc:if test="dc:has-result()">
+          <sinfo_flood_durations>
+          
+            <dc:call-macro name="collection-group">
+              <sinfo_flood_durations description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="factory" value="sinfo"/>
+                    <dc:attribute name="target_out" value="${out}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="out" value="${out_name}"/>
+                  </dc:element>
+                </dc:for-each>
+              </sinfo_flood_durations>
+            </dc:call-macro>
+          </sinfo_flood_durations>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
 
     <dc:macro name="waterlevels-user">
       <dc:filter expr="($out_name = 'longitudinal_section'
@@ -1198,6 +1230,17 @@
 
     <!-- Macros to load system data -->
 
+    <dc:macro name="duration_curve_system">
+      <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:macro>
+
+    <dc:macro name="floodduration_curve_system">
+      <dc:call-macro name="mainvalues"/>
+    </dc:macro>
+
     <dc:macro name="qmainvalues">
       <qmainvalue factory="mainvalue" ids="{$river_id}:q" target_out="{$out}"/>
     </dc:macro>
diff -r 26ac94cff0b6 -r 669ab639c56b artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Oct 19 16:27:07 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Oct 19 17:19:09 2018 +0200
@@ -400,7 +400,8 @@
                 }
                 else if (!(pnpObject instanceof Number) &&
                     g != null &&
-                    !"duration_curve".equals(getBoundToOut())
+                    !"duration_curve".equals(getBoundToOut() ) &&
+                    !"sinfo_floodduration_curve".equals(getBoundToOut() )
                 ) {
                     if (mv.getMainValue().getType().getName().equals("W")) {
                         filteredList.add(new NamedDouble(
diff -r 26ac94cff0b6 -r 669ab639c56b artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java	Fri Oct 19 16:27:07 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java	Fri Oct 19 17:19:09 2018 +0200
@@ -10,16 +10,19 @@
 
 package org.dive4elements.river.artifacts.sinfo.flood_duration;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.DefaultFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.DurationCurveFacet;
 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
 import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
-
 /**
  * Data of a flood duration curve.
  */
@@ -36,7 +39,6 @@
         super(0, name, description);
     }
 
-
     /**
      * Expose state computation from SINFOArtifact.
      */
@@ -51,6 +53,31 @@
         return new FloodDurationCalculation(context).calcStationCurve(currentKm, (SINFOArtifact) flys);
     }
 
+    @Override
+    public List getStaticDataProviderKeys(final Artifact art) {
+        final List<String> list = new ArrayList<>();
+        list.add(DurationCurveFacet.BB_DURATIONCURVE);
+        return list;
+    }
+
+    /**
+     * Can provide whatever getData returns and additionally the location.
+     *
+     * @param key
+     *            will respond on BB_DURATIONCURVE +KM
+     * @param param
+     *            ignored
+     * @param context
+     *            ignored
+     * @return whatever getData delivers or location.
+     */
+    @Override
+    public Object provideBlackboardData(final Artifact artifact, final Object key, final Object param, final CallContext context) {
+        if (key.equals(DurationCurveFacet.BB_DURATIONCURVE))
+            return getData(artifact, context);
+
+        return null;
+    }
 
     /** Create a deep copy. */
     @Override
@@ -59,5 +86,4 @@
         copy.set(this);
         return copy;
     }
-}
-
+}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list