[PATCH 1 of 3] Added calculation of salix hw5 and salix line w

Wald Commits scm-commit at wald.intevation.org
Mon Aug 20 09:46:20 CEST 2018


# HG changeset patch
# User mschaefer
# Date 1534750867 -7200
# Node ID e8b1255fc89e3601e17e70bd333d6496a5356951
# Parent  bd5f5d2220fab42e3a50b75a0830f38ce37bc87f
Added calculation of salix hw5 and salix line w

diff -r bd5f5d2220fa -r e8b1255fc89e artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java	Fri Aug 17 17:48:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java	Mon Aug 20 09:41:07 2018 +0200
@@ -187,9 +187,7 @@
         if (row == null)
             return Double.NaN;
 
-        // FIXME: hier wird die geodätische Höhe der SalixLinie benötigt; am besten auch schon in die Ergebnistzeilen einbauen
-        return 84.0;
-        // return row.getDoubleValue(UInfoResultType.salixline);
+        return row.getDoubleValue(UInfoResultType.salixw);
     }
 
     public final double getSalixScenarioValue(final double currentKm, final double nextKm, final double prevKm, final int scenarioIndex) {
@@ -202,9 +200,7 @@
         if (salixScenario == null)
             return Double.NaN;
 
-        // FIXME: hier wird die geodätische Höhe der SalixLinie benötigt; ggf schon als weiteres Feld an SalixScenario dranbauen
-        return 89;
-        // return salixScenario.getSalixValue();
+        return salixScenario.getSalixW();
     }
 
     public final double getWaterlevelValue(final double currentKm, final double nextKm, final double prevKm, final SalixWaterlevel waterlevel) {
@@ -220,7 +216,7 @@
             return row.getDoubleValue(UInfoResultType.waterlevelMW);
         case mhw:
             return row.getDoubleValue(UInfoResultType.waterlevelMHW);
-        case mh5:
+        case hw5:
             return row.getDoubleValue(UInfoResultType.waterlevelMH5);
 
         default:
diff -r bd5f5d2220fa -r e8b1255fc89e artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java	Fri Aug 17 17:48:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java	Mon Aug 20 09:41:07 2018 +0200
@@ -52,9 +52,11 @@
     private final Map<Gauge, QPosition> gaugeMwPos;
     private final Map<Gauge, QPosition> gaugeMnwPos;
     private final Map<Gauge, QPosition> gaugeMhwPos;
+    private final Map<Gauge, QPosition> gaugeHw5Pos;
     private QPosition refGaugeMwPos;
     private QPosition refGaugeMnwPos;
     private QPosition refGaugeMhwPos;
+    private QPosition refGaugeHw5Pos;
     private Gauge firstGauge;
 
     private Calculation problems;
@@ -66,6 +68,7 @@
         this.gaugeMwPos = new HashMap<>();
         this.gaugeMnwPos = new HashMap<>();
         this.gaugeMhwPos = new HashMap<>();
+        this.gaugeHw5Pos = new HashMap<>();
     }
 
     /**
@@ -103,11 +106,14 @@
         this.gaugeMwPos.clear();
         this.gaugeMnwPos.clear();
         this.gaugeMhwPos.clear();
+        this.gaugeHw5Pos.clear();
+
         this.firstGauge = null;
         for (final Gauge gauge : this.riverInfoProvider.getGauges()) {
             this.gaugeMwPos.put(gauge, null);
             this.gaugeMnwPos.put(gauge, null);
             this.gaugeMhwPos.put(gauge, null);
+            this.gaugeHw5Pos.put(gauge, null);
             final double gaugeKm = gauge.getStation().doubleValue();
             for (final MainValue mv : MainValue.getValuesOfGaugeAndType(gauge, MainValueTypeKey.Q)) {
                 if (mv.getMainValue().getName().equalsIgnoreCase("mq"))
@@ -116,11 +122,14 @@
                     this.gaugeMnwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
                 else if (mv.getMainValue().getName().equalsIgnoreCase("mhq"))
                     this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
+                else if (mv.getMainValue().getName().equalsIgnoreCase("hq5"))
+                    this.gaugeHw5Pos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
             }
             if (this.firstGauge == null) {
                 this.refGaugeMwPos = this.gaugeMwPos.get(gauge);
                 this.refGaugeMnwPos = this.gaugeMnwPos.get(gauge);
                 this.refGaugeMhwPos = this.gaugeMhwPos.get(gauge);
+                this.refGaugeHw5Pos = this.gaugeHw5Pos.get(gauge);
                 this.firstGauge = gauge;
             }
         }
@@ -150,22 +159,23 @@
         final double mnw = interpolateW(station, this.refGaugeMnwPos);
         final double mw = interpolateW(station, this.refGaugeMwPos);
         final double mhw = interpolateW(station, this.refGaugeMhwPos);
+        final double hw5 = interpolateW(station, this.refGaugeHw5Pos);
         row.putValue(UInfoResultType.waterlevelMNW, mnw);
         row.putValue(UInfoResultType.waterlevelMW, mw);
         row.putValue(UInfoResultType.waterlevelMHW, mhw);
-        // TODO: hier noch den W(HQ5)
-        row.putValue(UInfoResultType.waterlevelMH5, Double.NaN);
+        row.putValue(UInfoResultType.waterlevelMH5, hw5);
 
         // Calc salix-line and mw-mnw
         row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw));
         row.putValue(UInfoResultType.salix_mw_mnw, calcMwmnw(mw, mnw));
+        row.putValue(UInfoResultType.salixw, mhw - SALIX_DISTANCE.doubleValue());
         // Calc scenario values (always all scenario types set, Result variant extracts the fields needed)
         final List<SalixScenario> scenarios = new ArrayList<>();
         final List<Double> deltaws = getDeltaWs(station, rangeScenarios);
         for (final Double deltaw : deltaws) {
             if (deltaw != null) {
                 final double salix = calcSalix(mhw, mw + deltaw);
-                scenarios.add(new SalixScenario((int) (deltaw * 100), salix));
+                scenarios.add(new SalixScenario((int) (deltaw * 100), salix, mhw + deltaw - SALIX_DISTANCE.doubleValue()));
             }
             else {
                 scenarios.add(null);
diff -r bd5f5d2220fa -r e8b1255fc89e artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCrossSectionIndexData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCrossSectionIndexData.java	Fri Aug 17 17:48:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCrossSectionIndexData.java	Mon Aug 20 09:41:07 2018 +0200
@@ -24,7 +24,7 @@
      * Known waterlevels of the salix computation
      */
     public enum SalixWaterlevel {
-        mnw, mw, mhw, mh5
+        mnw, mw, mhw, hw5
     }
 
     private static final long serialVersionUID = 1L;
diff -r bd5f5d2220fa -r e8b1255fc89e artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenario.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenario.java	Fri Aug 17 17:48:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenario.java	Mon Aug 20 09:41:07 2018 +0200
@@ -24,10 +24,12 @@
 
     private final double salix_value;
     private final int deltaW;
+    private final double salixW;
 
-    public SalixScenario(final int deltaW, final double salix_value) {
+    public SalixScenario(final int deltaW, final double salix_value, final double salixW) {
         this.deltaW = deltaW;
         this.salix_value = salix_value;
+        this.salixW = salixW;
     }
 
     public double getSalixValue() {
@@ -39,8 +41,8 @@
     }
 
     public String getDeltaWFormatted() {
-        if (Double.isNaN(this.deltaW))
-            return StringUtils.EMPTY;
+        // if (Double.isNaN(this.deltaW))
+        // return StringUtils.EMPTY;
 
         return String.valueOf(this.deltaW);
     }
@@ -52,6 +54,17 @@
         return formatter.format(this.salix_value);
     }
 
+    public double getSalixW() {
+        return this.salixW;
+    }
+
+    public String getSalixWFormatted() {
+        if (Double.isNaN(this.salixW))
+            return StringUtils.EMPTY;
+
+        return String.valueOf(this.salixW);
+    }
+
     public static final String getScenarioValueHeader() {
         return "uinfo.export.salix_line.csv.header.scenario";
     }


More information about the Dive4Elements-commits mailing list