changeset 9631:6ecd1a28017f

Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
author mschaefer
date Tue, 15 Oct 2019 12:26:13 +0200
parents 8da911b5169c
children 9c07a33c2d62
files artifacts/doc/conf/artifacts/sinfo.xml artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml artifacts/doc/conf/themes.xml artifacts/doc/conf/themes/default.xml artifacts/doc/conf/themes/second.xml artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodQProcessor.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 11 files changed, 126 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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" />
 
--- 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"/>
--- 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"/>
--- 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"/>
--- 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" />
--- 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;
             }
--- 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
--- 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));
 
             }
 
--- /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
--- 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})
 
--- 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})
 

http://dive4elements.wald.intevation.org