[PATCH] Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)

Wald Commits scm-commit at wald.intevation.org
Tue Oct 15 12:26:30 CEST 2019


# HG changeset patch
# User mschaefer
# Date 1571135173 -7200
#      Tue Oct 15 12:26:13 2019 +0200
# Node ID 6ecd1a28017f2964e729dc5615baad77e4e0dc3b
# Parent  8da911b5169cda793411722279057ba06cf5385d
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)

diff -r 8da911b5169c -r 6ecd1a28017f artifacts/doc/conf/artifacts/sinfo.xml
--- a/artifacts/doc/conf/artifacts/sinfo.xml	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/doc/conf/artifacts/sinfo.xml	Tue Oct 15 12:26:13 2019 +0200
@@ -388,6 +388,7 @@
             <facet name="sinfo_facet_flood_height.left" description="flood heights of the left bank infrastructures (points)" />
             <facet name="sinfo_facet_flood_height.right" description="flood heights of the right bank infrastructures (points)" />
             <facet name="mainvalue.w" description="W of main value" />
+            <facet name="mainvalue.q" description="Q of main value" />
 
             <facet name="sinfo_flood_height.manualpoints" description="Manual Points" />
 
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml
--- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml	Tue Oct 15 12:26:13 2019 +0200
@@ -64,6 +64,7 @@
     <processor class="org.dive4elements.river.artifacts.sinfo.collision.CollisionCalcProcessor" axis="countAxis"/>
     <processor class="org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationProcessor" axis="durationAxis"/>
     <processor class="org.dive4elements.river.artifacts.sinfo.flood_duration.FloodHeightProcessor" axis="W"/>
+    <processor class="org.dive4elements.river.artifacts.sinfo.flood_duration.FloodQProcessor" axis="Q"/>
     
     <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedChannelWidthProcessor" axis="Width"/>
     <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedChannelDepthProcessor" axis="flowdepthAxis"/>
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/doc/conf/themes.xml
--- a/artifacts/doc/conf/themes.xml	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/doc/conf/themes.xml	Tue Oct 15 12:26:13 2019 +0200
@@ -459,6 +459,7 @@
         <mapping from="sinfo_facet_flood_height.left" to="SInfoInfrastructureHeightLeft"/>
         <mapping from="sinfo_facet_flood_height.right" to="SInfoInfrastructureHeightRight"/>
         <mapping from="mainvalue.w" to="SInfoMainValues"/>
+        <mapping from="mainvalue.q" to="SInfoHeightMainValuesQ"/>
         <mapping from="sinfo.mainvalues.q" to="SInfoMainValuesQ"/>
         <mapping from="sinfo.mainvalues.w" to="SInfoMainValuesW"/>
         <mapping from="infrastructure.w.left" to="InfrastructureWLeft"/>
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/doc/conf/themes/default.xml
--- a/artifacts/doc/conf/themes/default.xml	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/doc/conf/themes/default.xml	Tue Oct 15 12:26:13 2019 +0200
@@ -2922,6 +2922,16 @@
       <field name="showpointlabel" type="boolean" display="Punktbeschriftung anzeigen" default="false" hints="hidden"/>
     </fields>
   </theme>
+  <theme name="SInfoHeightMainValuesQ">
+    <inherits>
+      <inherit from="Lines"/>
+    </inherits>
+    <fields>
+      <field name="linecolor" type="Color" display="Farbe" default="32, 32, 32"/>
+      <field name="textorientation" type="boolean" display="Textausrichtung" default="true"/>
+      <field name="showlinelabel" type="boolean" display="Linienbeschriftung anzeigen" default="false" hints="hidden"/>
+    </fields>
+  </theme>
   <theme name="SInfoMainValuesQ">
     <inherits>
       <inherit from="Lines"/>
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/doc/conf/themes/second.xml
--- a/artifacts/doc/conf/themes/second.xml	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/doc/conf/themes/second.xml	Tue Oct 15 12:26:13 2019 +0200
@@ -2910,6 +2910,16 @@
       <field name="showpointlabel" type="boolean" display="Punktbeschriftung anzeigen" default="false" hints="hidden" />
     </fields>
   </theme>
+  <theme name="SInfoHeightMainValuesQ">
+    <inherits>
+      <inherit from="Lines"/>
+    </inherits>
+    <fields>
+      <field name="linecolor" type="Color" display="Farbe" default="32, 32, 32"/>
+      <field name="textorientation" type="boolean" display="Textausrichtung" default="true"/>
+      <field name="showlinelabel" type="boolean" display="Linienbeschriftung anzeigen" default="false" hints="hidden"/>
+    </fields>
+  </theme>
   <theme name="SInfoMainValuesQ">
     <inherits>
       <inherit from="Lines" />
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java	Tue Oct 15 12:26:13 2019 +0200
@@ -22,6 +22,7 @@
 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthWaterlevelProcessor;
 import org.dive4elements.river.artifacts.sinfo.common.TauProcessor;
 import org.dive4elements.river.artifacts.sinfo.common.VelocityProcessor;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodQProcessor;
 
 /**
  * The default SINFO artifact.
@@ -115,6 +116,8 @@
                 // return Boolean.FALSE;
                 // if (FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_Q.equals(name))
                 // return Boolean.FALSE;
+                if (FloodQProcessor.FACET_MAIN_VALUE_Q.equals(name))
+                    return Boolean.FALSE;
 
                 return null;
             }
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java	Tue Oct 15 12:26:13 2019 +0200
@@ -114,15 +114,23 @@
         final Set<FloodDurationInfrastructureChoice> infrastructures = new HashSet<>();
 
         // Create the result rows, and calculate and add the flood durations etc.
+        ResultRow row;
+        boolean starting;
         for (int i = 0; i <= stationsSorted.length - 1; i++) {
             final Gauge gauge = this.riverInfoProvider2.getGauge(stationsSorted[i], true);
+            row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i);
+            starting = true;
             if (this.stationInfras.containsKey(stationsSorted[i])) {
                 for (final InfrastructureValue infra : this.stationInfras.get(stationsSorted[i])) {
-                    final ResultRow row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i);
+                    if (!starting)
+                        row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i);
                     calculateInfrastructure(row, gauge, infra, wst, durFinders, infrastructures);
                     this.rows.add(row);
+                    starting = false;
                 }
             }
+            if (starting)
+                this.rows.add(row);
         }
 
         // Get the labels of the selected waterlevels
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java	Tue Oct 15 12:26:13 2019 +0200
@@ -105,6 +105,7 @@
                 // final int facetIndex, final int resultIndex, final int dataIndex
                 facets.add(FloodDurationProcessor.createMainValueDurationFacet(context, hash, this.id, result, themeCount++, resultIndex, j));
                 facets.add(FloodHeightProcessor.createMainValueHeightFacet(context, hash, this.id, result, themeCount++, resultIndex, j));
+                facets.add(FloodQProcessor.createMainValueQFacet(context, hash, this.id, result, themeCount++, resultIndex, j));
 
             }
 
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodQProcessor.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodQProcessor.java	Tue Oct 15 12:26:13 2019 +0200
@@ -0,0 +1,86 @@
+/** 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.sinfo.flood_duration;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.artifacts.common.AbstractProcessor;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult.ValueGetter;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.process.QOutProcessor;
+import org.dive4elements.river.themes.ThemeDocument;
+
+/**
+ * Processor to generate the facet and data series of mainvalue discharges
+ *
+ * @author Matthias Schäfer
+ *
+ */
+public final class FloodQProcessor extends AbstractProcessor {
+
+    private static final String FACET_MAIN_VALUE_Q_DESCRIPTION = "mainvalue.q.description";
+
+    public static final String FACET_MAIN_VALUE_Q = "mainvalue.q";
+
+    private static final String I18N_AXIS_LABEL = QOutProcessor.I18N_LONGITUDINAL_LABEL;
+
+    private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
+
+    static {
+        HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_Q);
+    }
+
+    public FloodQProcessor() {
+        super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
+    }
+
+    public static Facet createMainValueQFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result,
+            final int facetIndex, final int resultIndex, final int dataIndex) {
+        final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_Q_DESCRIPTION, FACET_MAIN_VALUE_Q_DESCRIPTION,
+                result.getWaterlevelLabel(dataIndex));
+
+        return new FloodDurationFacet(facetIndex, resultIndex, dataIndex, FACET_MAIN_VALUE_Q, description, ComputeType.ADVANCE, I18N_AXIS_LABEL, hash, id);
+    }
+
+    @Override
+    protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+        final String facetName = bundle.getFacetName();
+        if (FACET_MAIN_VALUE_Q.contentEquals(facetName)) {
+
+            final AbstractCalculationResult data = getResult(generator, bundle);
+
+            final FloodDurationFacet facet = (FloodDurationFacet) bundle.getFacet();
+            final int index = facet.getWaterlevelIndex();
+
+            if (data instanceof FloodDurationCalculationResult) {
+                final FloodDurationCalculationResult.ValueGetter valuegetter = new ValueGetter() {
+                    @Override
+                    public double getValue(final DurationWaterlevel waterlevel) {
+                        return waterlevel.getDischarge();
+                    }
+                };
+                final double[][] points = ((FloodDurationCalculationResult) data).getMainValueDurationPoints(valuegetter, index);
+                return buildSeriesForPoints(points, generator, bundle, theme, visible, null);
+            }
+        }
+
+        final String error = String.format("Unknown facet name: %s", facetName);
+        throw new UnsupportedOperationException(error);
+    }
+}
\ No newline at end of file
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/src/main/resources/messages.properties	Tue Oct 15 12:26:13 2019 +0200
@@ -1182,6 +1182,8 @@
 
 mainvalue.w = Waterlevel
 mainvalue.w.description = Waterlevel ({0})
+mainvalue.q = Discharge
+mainvalue.q.description = Discharge ({0})
 mainvalue.duration = Flooding Duration
 mainvalue.duration.description = Flooding Duration ({0})
 
diff -r 8da911b5169c -r 6ecd1a28017f artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Mon Oct 14 18:07:31 2019 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Tue Oct 15 12:26:13 2019 +0200
@@ -1182,6 +1182,8 @@
 
 mainvalue.w = Wasserstand/Wasserspiegellage
 mainvalue.w.description = Wasserstand/Wasserspiegellage ({0})
+mainvalue.q = Q
+mainvalue.q.description = Q ({0})
 mainvalue.duration = \u00dcberflutungsdauer
 mainvalue.duration.description = \u00dcberflutungsdauer ({0})
 


More information about the Dive4Elements-commits mailing list