changeset 9438:d2f5375ede26

Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
author mschaefer
date Mon, 20 Aug 2018 16:05:06 +0200
parents 751a3eff6244
children ce0a48b93f4b
files artifacts/doc/conf/artifacts/bundu.xml artifacts/doc/conf/meta-data.xml artifacts/doc/conf/themes.xml artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstFixationFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 11 files changed, 86 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/bundu.xml	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml	Mon Aug 20 16:05:06 2018 +0200
@@ -507,7 +507,7 @@
       <outputmodes>
         <outputmode name="bundu_wspl_longitudinal_section" description="output.bundu_wspl_longitudinal_section" mime-type="image/png" type="chart">
           <facets>
-            <facet name="bundu_facet_w" description="bundu_facet_w"/>
+            <facet name="longitudinal_section.w" description="longitudinal_section.w"/>
             <facet name="bundu_facet_channelmin" description="bundu_facet_channelmin"/>
             <facet name="bundu_facet_bedheight" description="bundu_facet_bedheight"/>
             <facet name="longitudinal_section.q" description="longitudinal_section.q"/>
--- a/artifacts/doc/conf/meta-data.xml	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Mon Aug 20 16:05:06 2018 +0200
@@ -146,10 +146,15 @@
                   <!--dc:when test="$out = 'sinfo_floodduration_curve'">
                     <dc:call-macro name="mainvalues" />
                   </dc:when-->
-
                   <dc:when test="$out = 'uinfo_salix_line'">
                     <dc:call-macro name="annotations" />
                   </dc:when>
+                  <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
+                    <dc:call-macro name="annotations" />
+                  </dc:when>
+                  <dc:when test="$out = 'bundu_depth_longitudinal_section'">
+                    <dc:call-macro name="annotations" />
+                  </dc:when>
                 </dc:choose>
               </dc:iterate>
             </dc:when>
@@ -338,6 +343,12 @@
                     <dc:variable name="vegzonedata" expr="dc:defaultvegetationzone()"></dc:variable>
                     <defaultVegetationZone factory="dummy" target_out="{$out}" data="{$vegzonedata}"></defaultVegetationZone>
                   </dc:when>
+                  <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
+                    <dc:call-macro name="longitudinal-section-prototype" />
+                  </dc:when>
+                  <dc:when test="$out = 'bundu_depth_longitudinal_section'">
+                    <dc:call-macro name="longitudinal-section-prototype" />
+                  </dc:when>
                 </dc:choose>
               </dc:iterate>
             </dc:otherwise>
@@ -448,6 +459,12 @@
                     <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>
+                    <dc:when test="$out = 'bundu_depth_longitudinal_section'">
+                      <dc:call-macro name="longitudinal-section-user-prototype" />
+                    </dc:when>
                     <dc:comment> Discharge curves </dc:comment>
                     <dc:when test="$out = 'computed_discharge_curve'">
                       <dc:call-macro name="discharge-curve-user-prototype" />
--- a/artifacts/doc/conf/themes.xml	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/doc/conf/themes.xml	Mon Aug 20 16:05:06 2018 +0200
@@ -494,10 +494,8 @@
         
         <mapping from="uinfo_salix_line.manualpoints" to="ManualPoints"/>
 
-        <mapping from="bundu_facet_w" to="LongitudinalSectionW"/>
         <mapping from="bundu_facet_channelmin" to="BunduChannel"/>
         <mapping from="bundu_facet_bedheight" to="BunduBed"/>
-        <mapping from="bundu_facet_q" to="LongitudinalSection"/>
         <mapping from="bundu_facet_flowdepth.filtered" to="BunduBed"/>
         <mapping from="bundu_facet_channeldepth" to="BunduChannel"/>
     </mappings>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Aug 20 16:05:06 2018 +0200
@@ -43,10 +43,12 @@
 
     private final CallContext context;
 
+
     public BezugswstCalculation(final CallContext context) {
         this.context = context;
     }
 
+
     /**
      * Calculates the result rows of a bundu bzws workflow
      */
@@ -73,9 +75,11 @@
         bunduartifact.addStringData("wq_isq", "true"); // macht doch Sinn hier, sorry!
         final WinfoArtifactWrapper winfo = new WinfoArtifactWrapper(bunduartifact);
         final RiverInfoProvider riverInfoProvider = RiverInfoProvider.forRange(this.context, river, access.getRange(), true);
-        final WQKms wqkms = calculateWspl(bunduartifact, problems);
-        if (wqkms == null)
+        final FixRealizingResult fixResult = calculateWspl(bunduartifact, problems);
+        if (fixResult == null)
             return new CalculationResult(results, problems);
+
+        final WQKms wqkms = fixResult.getWQKms()[0];
         final WstInfo wstInfo = new WstInfo(wqkms.getName(), 0, riverInfoProvider.getReferenceGauge(), true);
 
         // Fetch the bed heights of the selected sounding
@@ -99,7 +103,7 @@
         final WaterlevelDescriptionBuilder descBuilder = new WaterlevelDescriptionBuilder(winfo, this.context);
         final String qtext = descBuilder.getMetadataQ();
         final BezugswstMainCalculationResult result = new BezugswstMainCalculationResult("bundu-bzws", rows, bedHeightsFinder.getInfo(), wstInfo,
-                access.getFunction(), preprocessing, startYear, endYear, ud, qtext, missingVolFrom, missingVolTo);
+                access.getFunction(), preprocessing, startYear, endYear, ud, qtext, wqkms, missingVolFrom, missingVolTo);
         results.addResult(result, problems);
 
         // // missing volume calculation
@@ -177,7 +181,7 @@
     /**
      * Calculates a w-q-longitudinal section for a river range and Q specified in an artifact
      */
-    private WQKms calculateWspl(final BUNDUArtifact bundu, final Calculation problems) {
+    private FixRealizingResult calculateWspl(final BUNDUArtifact bundu, final Calculation problems) {
 
         final FixRealizingAccess access = new FixRealizingAccess(bundu);
         final FixRealizingCalculation calc = new FixRealizingCalculation(access);
@@ -185,7 +189,6 @@
         final CalculationResult res = calc.calculate();
 
         final FixRealizingResult fixRes = (FixRealizingResult) res.getData();
-        final WQKms[] wqkms = (fixRes != null) ? fixRes.getWQKms() : new WQKms[0];
 
         final List<Problem> problems2 = res.getReport().getProblems();
         if (problems2 != null) {
@@ -193,9 +196,7 @@
                 problems.addProblem(problem);
             }
         }
-        if (wqkms.length >= 1)
-            return wqkms[0];
-        return null;
+        return fixRes;
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstFixationFacet.java	Mon Aug 20 16:05:06 2018 +0200
@@ -0,0 +1,42 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.artifacts.bundu.bezugswst;
+
+import java.util.List;
+
+import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
+import org.dive4elements.river.artifacts.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.model.fixings.FixWaterlevelFacet;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+public class BezugswstFixationFacet extends FixWaterlevelFacet {
+
+    public BezugswstFixationFacet() {
+    }
+
+    public BezugswstFixationFacet(final int index, final String name, final String description, final ComputeType type, final String hash,
+            final String stateID) {
+        super(index, name, description, type, hash, stateID);
+    }
+
+    @Override
+    protected WQKms[] getWQKms(final CalculationResult res) {
+
+        final BezugswstCalculationResults results = (BezugswstCalculationResults) res.getData();
+
+        final List<AbstractCalculationExportableResult> resultList = results.getResults();
+
+        if (!resultList.isEmpty())
+            return new WQKms[] { ((BezugswstMainCalculationResult) resultList.get(0)).getWQKms() };
+        return null;
+    }
+
+}
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstHeightProcessor.java	Mon Aug 20 16:05:06 2018 +0200
@@ -19,7 +19,6 @@
 import org.dive4elements.river.artifacts.bundu.BunduResultType;
 import org.dive4elements.river.artifacts.common.AbstractProcessor;
 import org.dive4elements.river.artifacts.common.AbstractResultType;
-import org.dive4elements.river.artifacts.common.GeneralResultType;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
 import org.dive4elements.river.exports.DiagramGenerator;
@@ -34,9 +33,6 @@
  */
 public final class BezugswstHeightProcessor extends AbstractProcessor {
 
-    private static final String FACET_W = "bundu_facet_w";
-
-    private static final String FACET_W_DESCRIPTION = "bundu_facet_w.description";
 
     private static final String FACET_CHANNELMIN = "bundu_facet_channelmin";
 
@@ -46,34 +42,19 @@
 
     private static final String FACET_BEDHEIGHT_DESCRIPTION = "bundu_facet_bedheight.description";
 
-    public static final String FACET_Q = "bundu_facet_q";
-
-    private static final String FACET_Q_DESCRIPTION = "bundu_facet_q.description";
-
     private static final String AXIS_LABEL = LongitudinalSectionGenerator.I18N_YAXIS_LABEL;
 
-    private static final String Q_AXIS_LABEL = LongitudinalSectionGenerator.I18N_2YAXIS_LABEL;
-
     private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
 
     static {
-        HANDLED_FACET_TYPES.add(FACET_W);
         HANDLED_FACET_TYPES.add(FACET_CHANNELMIN);
         HANDLED_FACET_TYPES.add(FACET_BEDHEIGHT);
-        HANDLED_FACET_TYPES.add(FACET_Q);
     }
 
     public BezugswstHeightProcessor() {
         super(AXIS_LABEL, HANDLED_FACET_TYPES);
     }
 
-    public static Facet createWFacet(final CallContext context, final String hash, final String id, final int facetIndex,
-            final int resultIndex, final String seriesName) {
-
-        final String description = Resources.getMsg(context.getMeta(), FACET_W_DESCRIPTION, FACET_W_DESCRIPTION, seriesName);
-        return new BezugswstResultFacet(facetIndex, resultIndex, FACET_W, description, AXIS_LABEL, id, hash);
-    }
-
     public static Facet createChannelminFacet(final CallContext context, final String hash, final String id, final int facetIndex,
             final int resultIndex) {
 
@@ -96,14 +77,10 @@
 
     protected AbstractResultType doGetType(final String facetName) {
 
-        if (FACET_W.contentEquals(facetName))
-            return BunduResultType.bezugswst;
         if (FACET_CHANNELMIN.contentEquals(facetName))
             return BunduResultType.channelLowerEdge;
         if (FACET_BEDHEIGHT.contentEquals(facetName))
             return SInfoResultType.meanBedHeight;
-        if (FACET_Q.contentEquals(facetName))
-            return GeneralResultType.dischargeQwithUnit;
 
         final String error = String.format("Unknown facet name: %s", facetName);
         throw new UnsupportedOperationException(error);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Mon Aug 20 16:05:06 2018 +0200
@@ -20,6 +20,7 @@
 import org.dive4elements.river.artifacts.common.IExportContext;
 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
 import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.model.WQKms;
 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo;
 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
 import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
@@ -46,9 +47,11 @@
     private final Integer ud;
     private final String qOfGauges;
 
+    private final WQKms wqkms;
+
     public BezugswstMainCalculationResult(final String label, final Collection<ResultRow> rows, final BedHeightInfo sounding, final WstInfo wst,
             final String function, final boolean preprocessing, final int startYear, final int endYear, final Integer ud, final String qOfGauges,
-            final Double missingVolumeFrom, final Double missingVolumeTo) {
+            final WQKms wqkms, final Double missingVolumeFrom, final Double missingVolumeTo) {
         super(label, rows);
         this.wst = wst;
         this.sounding = sounding;
@@ -60,6 +63,11 @@
         this.missingVolumeFrom = missingVolumeFrom;
         this.ud = ud;
         this.qOfGauges = qOfGauges;
+        this.wqkms = wqkms;
+    }
+
+    public WQKms getWQKms() {
+        return this.wqkms;
     }
 
     public String getWstLabel() {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java	Mon Aug 20 16:05:06 2018 +0200
@@ -25,7 +25,6 @@
 import org.dive4elements.river.artifacts.model.EmptyFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.ReportFacet;
-import org.dive4elements.river.artifacts.model.WaterlevelFacet;
 import org.dive4elements.river.artifacts.states.DefaultState;
 
 /**
@@ -89,10 +88,12 @@
 
         if (!resultList.isEmpty()) {
             final BezugswstMainCalculationResult result = (BezugswstMainCalculationResult) resultList.get(0);
-            facets.add(BezugswstHeightProcessor.createWFacet(context, hash, this.id, facetIndex++, 0, result.getWstLabel()));
             facets.add(BezugswstHeightProcessor.createChannelminFacet(context, hash, this.id, facetIndex++, 0));
             facets.add(BezugswstHeightProcessor.createBedheightFacet(context, hash, this.id, facetIndex++, 0, result.getBedHeightLabel()));
-            facets.add(new WaterlevelFacet(facetIndex++, FacetTypes.LONGITUDINAL_Q, result.getWstLabel(), ComputeType.ADVANCE, this.id, hash));
+            final String nameQ = result.getWstLabel();
+            final String nameW = "W(" + nameQ + ")";
+            facets.add(new BezugswstFixationFacet(0, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, this.id));
+            facets.add(new BezugswstFixationFacet(0, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, this.id));
 
             facets.add(BezugswstDepthProcessor.createFlowdepthFilteredFacet(context, hash, this.id, facetIndex++, 0, result.getBedHeightLabel()));
             facets.add(BezugswstDepthProcessor.createChanneldepthFacet(context, hash, this.id, facetIndex++, 0));
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Mon Aug 20 16:05:06 2018 +0200
@@ -149,7 +149,9 @@
         STKH("sinfo_tkk"), //
         SFW("sinfo_flood_height"), //
         SFDC("sinfo_floodduration_curve"), //
-        USL("uinfo_salix_line");
+        USL("uinfo_salix_line"), //
+        BUUBZWS_W("bundu_wspl_longitudinal_section"), //
+        BUUBZWS_H("bundu_depth_longitudinal_section");
 
         private final String chartTypeString;
 
--- a/artifacts/src/main/resources/messages.properties	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Mon Aug 20 16:05:06 2018 +0200
@@ -1309,11 +1309,8 @@
 bundu.wst.gauge_timeranges_disjoint = Der Bezugszeitraum konnte nicht auf die vorhandenen Abflusswerte eingeschr\u00e4nkt werden. 
 
 bundu.chart.wspl.section.title = BZWS-L\u00e4ngsschnitt
-bundu_facet_w.description = Bezugswasserstand ({0})
 bundu_facet_bedheight.description = Mittlere Sohlh\u00f6he ({0}) 
 bundu_facet_channelmin.description = Sohle (Sollzustand)
-bundu_facet_q = Q [m\u00b3/s]
-bundu_facet_q.description = Q [m\u00b3/s]
 bundu.chart.depth.section.title = h-L\u00e4ngsschnitt
 bundu_facet_flowdepth.filtered.description = h (BZWS, {0})
 bundu_facet_channeldepth.description = h (Solltiefe)
--- a/artifacts/src/main/resources/messages_de.properties	Mon Aug 20 15:53:33 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Mon Aug 20 16:05:06 2018 +0200
@@ -1309,11 +1309,8 @@
 bundu.wst.gauge_timeranges_disjoint = Der Bezugszeitraum konnte nicht auf die vorhandenen Abflusswerte eingeschr\u00e4nkt werden. 
 
 bundu.chart.wspl.section.title = BZWS-L\u00e4ngsschnitt
-bundu_facet_w.description = Bezugswasserstand ({0})
 bundu_facet_bedheight.description = Mittlere Sohlh\u00f6he ({0}) 
 bundu_facet_channelmin.description = Sohle (Sollzustand)
-bundu_facet_q = Q [m\u00b3/s]
-bundu_facet_q.description = Q [m\u00b3/s]
 bundu.chart.depth.section.title = h-L\u00e4ngsschnitt
 bundu_facet_flowdepth.filtered.description = h (BZWS, {0})
 bundu_facet_channeldepth.description = h (Solltiefe)

http://dive4elements.wald.intevation.org