[PATCH] Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output

Wald Commits scm-commit at wald.intevation.org
Thu Aug 2 09:57:38 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1533141657 -7200
# Node ID 392745cccedefbbca58c2e488187f9e41c759523
# Parent  2aec052d40886d7c2ed5de5223785d0dc507c257
Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.

diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java	Wed Aug 01 18:40:57 2018 +0200
@@ -39,6 +39,10 @@
     public final boolean hasTkh() {
         return this.hasTkh;
     }
+    
+    public boolean isShowRefGauges() {
+        return this.wst.isShowRefGauges();
+    }
 
     public final double[][] getTkhUpPoints() {
 
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Wed Aug 01 18:40:57 2018 +0200
@@ -106,7 +106,7 @@
         final RiverInfoProvider riverInfoProvider = infoProvider.forWaterlevel(waterlevel);
 
         final int wspYear = waterlevel.getYear();
-        final WstInfo wstInfo = new WstInfo(wspLabel, wspYear, riverInfoProvider.getReferenceGauge());
+        final WstInfo wstInfo = new WstInfo(wspLabel, wspYear, riverInfoProvider.getReferenceGauge(), waterlevel.isShowRefGauges());
 
         final WaterlevelValuesFinder waterlevelProvider = WaterlevelValuesFinder.fromKms(problems, wstKms);
         final DischargeValuesFinder dischargeProvider = DischargeValuesFinder.fromKms(wstKms);
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java	Wed Aug 01 18:40:57 2018 +0200
@@ -123,8 +123,8 @@
         final RiverInfoProvider currentRiverInfoProvider = infoProvider.forWaterlevel(currentWaterlevel);
         final RiverInfoProvider histRiverInfoProvider = infoProvider.forWaterlevel(historicalWaterlevel);
 
-        final WstInfo currentWstInfo = new WstInfo(currentWaterlevel.getName(), currentWstYear, currentRiverInfoProvider.getReferenceGauge());
-        final WstInfo historicalWstInfo = new WstInfo(historicalWaterlevel.getName(), historicalWstYear, histRiverInfoProvider.getReferenceGauge());
+        final WstInfo currentWstInfo = new WstInfo(currentWaterlevel.getName(), currentWstYear, currentRiverInfoProvider.getReferenceGauge(), true);
+        final WstInfo historicalWstInfo = new WstInfo(historicalWaterlevel.getName(), historicalWstYear, histRiverInfoProvider.getReferenceGauge(), true);
 
         final WKms currentWkms = currentWaterlevel.getWkms();
         final WaterlevelValuesFinder currentWstProvider = WaterlevelValuesFinder.fromKms(problems, currentWkms);
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java	Wed Aug 01 18:40:57 2018 +0200
@@ -113,7 +113,7 @@
         final RiverInfoProvider riverInfoProvider = infoProvider.forWaterlevel(waterlevel);
 
         final int wspYear = waterlevel.getYear();
-        final WstInfo wstInfo = new WstInfo(waterlevel.getName(), wspYear, riverInfoProvider.getReferenceGauge());
+        final WstInfo wstInfo = new WstInfo(waterlevel.getName(), wspYear, riverInfoProvider.getReferenceGauge(), true);
 
         final WaterlevelValuesFinder waterlevelProvider = WaterlevelValuesFinder.fromKms(problems, wstKms);
         final DischargeValuesFinder dischargeProvider = DischargeValuesFinder.fromKms(wstKms);
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Wed Aug 01 18:40:57 2018 +0200
@@ -153,13 +153,13 @@
         final int wspYear = -1;
         // Remark: showAllGauges only true for Fixierungsanalyse, false for WInfo, so false here as well
         final boolean showAllGauges = false;
-        final WaterlevelData waterlevel = new WaterlevelData(wkms, wspYear, showAllGauges);
+        final WaterlevelData waterlevel = new WaterlevelData(wkms, wspYear, showAllGauges, true);
 
         final RiverInfoProvider riverInfoProvider = riverInfo.forWaterlevel(waterlevel);
 
         final String waterlevelLabel = descBuilder.getDesc(wkms);
 
-        final WstInfo wstInfo = new WstInfo(waterlevelLabel, wspYear, riverInfoProvider.getReferenceGauge());
+        final WstInfo wstInfo = new WstInfo(waterlevelLabel, wspYear, riverInfoProvider.getReferenceGauge(), true);
 
         /* build tkh calculators per bedheight */
         final Map<NumberRange, TkhCalculator> calculatorsByRanges = buildCalculators(calcRange, wkms, bedHeights, problems, riverInfoProvider, waterlevelLabel);
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/util/WstInfo.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/util/WstInfo.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/util/WstInfo.java	Wed Aug 01 18:40:57 2018 +0200
@@ -24,10 +24,13 @@
 
     private final String gauge;
 
-    public WstInfo(final String label, final int year, final String refGauge) {
+    private boolean showRefGauges;
+
+    public WstInfo(final String label, final int year, final String refGauge, boolean showRefGauges) {
         this.label = label;
         this.year = year;
         this.gauge = refGauge;
+        this.showRefGauges = showRefGauges;
     }
 
     public String getLabel() {
@@ -41,4 +44,8 @@
     public String getGauge() {
         return this.gauge;
     }
+    
+    public boolean isShowRefGauges() {
+        return this.showRefGauges;
+    }
 }
\ No newline at end of file
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java	Wed Aug 01 18:40:57 2018 +0200
@@ -29,19 +29,18 @@
     /** If <code>true</code>, tabular export will show gauges for every station, else only for the first gauge */
     private final boolean showAllGauges;
 
-    public WaterlevelData(final WKms wkms, final int year) {
-        this(wkms, year, false);
+    private boolean showRefGauges;
+
+    public WaterlevelData(final WKms wkms, final int year, final boolean showAllGauges, boolean showRefGauges) {
+        this(wkms.getName(), wkms, year, showAllGauges, showRefGauges);
     }
 
-    public WaterlevelData(final WKms wkms, final int year, final boolean showAllGauges) {
-        this(wkms.getName(), wkms, year, showAllGauges);
-    }
-
-    private WaterlevelData(final String name, final WKms wkms, final int year, final boolean showAllGauges) {
+    private WaterlevelData(final String name, final WKms wkms, final int year, final boolean showAllGauges, boolean showRefGauges) {
         this.name = name;
         this.wkms = wkms;
         this.year = year;
         this.showAllGauges = showAllGauges;
+        this.showRefGauges = showRefGauges;
     }
 
     public WaterlevelData filterByRange(final double from, final double to) {
@@ -50,11 +49,11 @@
         }
 
         final WKms filteredWkms = this.wkms.filteredKms(from, to);
-        return new WaterlevelData(this.name, filteredWkms, this.year, this.showAllGauges);
+        return new WaterlevelData(this.name, filteredWkms, this.year, this.showAllGauges ,showRefGauges);
     }
 
     public WaterlevelData withName(final String nameToSet) {
-        return new WaterlevelData(nameToSet, this.wkms, this.year, this.showAllGauges);
+        return new WaterlevelData(nameToSet, this.wkms, this.year, this.showAllGauges, showRefGauges);
     }
 
     public String getName() {
@@ -68,6 +67,10 @@
     public boolean isShowAllGauges() {
         return this.showAllGauges;
     }
+    
+    public boolean isShowRefGauges() {
+        return this.showRefGauges;
+    }
 
     public int getYear() {
         return this.year;
diff -r 2aec052d4088 -r 392745cccede artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelFetcher.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelFetcher.java	Wed Aug 01 18:01:11 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelFetcher.java	Wed Aug 01 18:40:57 2018 +0200
@@ -78,13 +78,11 @@
     private WaterlevelData fetchWaterlevelFromArtifact(final CallContext context, final D4EArtifact d4eArtifact, final int idx, final double from,
             final double to) {
 
-        if (d4eArtifact instanceof StaticWKmsArtifact) {
+        if (d4eArtifact instanceof StaticWKmsArtifact)
             return fetchStaticWKmsArtifactWaterlevel((StaticWKmsArtifact) d4eArtifact, idx, from, to);
-        }
 
-        if (d4eArtifact instanceof StaticWQKmsArtifact) {
+        if (d4eArtifact instanceof StaticWQKmsArtifact)
             return fetchStaticWQKmsArtifactWaterlevel((StaticWQKmsArtifact) d4eArtifact, from, to);
-        }
 
         if (d4eArtifact instanceof WINFOArtifact)
             return fetchWINFOArtifactWaterlevel(context, (WINFOArtifact) d4eArtifact, idx, from, to);
@@ -108,7 +106,7 @@
 
         if (wkms != null) {
             final int year = fetchStaticWKmsYear(staticWKms);
-            return new WaterlevelData(wkms, year);
+            return new WaterlevelData(wkms, year, false, false);
         }
 
         log.error("No WKms from Static artifact for this range.");
@@ -123,7 +121,7 @@
 
         if (wkms != null) {
             final int year = fetchStaticWKmsYear(staticWKms);
-            return new WaterlevelData(wkms, year);
+            return new WaterlevelData(wkms, year, false, false);
         }
 
         log.error("No WKms from Static artifact for this range.");
@@ -148,7 +146,7 @@
 
         // REAMRK: W_INFO results does not know any 'year'
         final int year = -1;
-        return new WaterlevelData(wkms[idx], year).filterByRange(from, to);
+        return new WaterlevelData(wkms[idx], year, false, true).filterByRange(from, to);
     }
 
     private WaterlevelData fetchFixationArtifactWaterlevel(final CallContext context, final FixationArtifact fixation, final int idx, final double from,
@@ -171,7 +169,7 @@
         // REMARK: same logic as in WaterlevelExporter
         final boolean showAllGauges = isFixRealize;
 
-        return new WaterlevelData(frR.getWQKms()[idx], year, showAllGauges).filterByRange(from, to);
+        return new WaterlevelData(frR.getWQKms()[idx], year, showAllGauges, true).filterByRange(from, to);
     }
 
     /**


More information about the Dive4Elements-commits mailing list