diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java @ 8884:7a8c12706834

Work on SINFO-FlowDepth
author gernotbelger
date Tue, 13 Feb 2018 14:53:23 +0100
parents a536e1aacf0f
children cc86b0f9b3c3
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Fri Feb 09 18:07:22 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Tue Feb 13 14:53:23 2018 +0100
@@ -75,8 +75,7 @@
 
         final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name());
 
-        final FlowDepthCalculationResults results = new FlowDepthCalculationResults(calcModeLabel, user, river, from,
-                to, useTkh);
+        final FlowDepthCalculationResults results = new FlowDepthCalculationResults(calcModeLabel, user, river, from, to, useTkh);
 
         for (final DifferencesPair diffPair : diffPairs) {
             final FlowDepthCalculationResult result = calculateResult(river, from, to, diffPair, problems, gaugeIndex);
@@ -87,8 +86,8 @@
         return new CalculationResult(results, problems);
     }
 
-    private FlowDepthCalculationResult calculateResult(final River river, final double from, final double to,
-            final DifferencesPair diffPair, final Calculation problems, final GaugeIndex gaugeIndex) {
+    private FlowDepthCalculationResult calculateResult(final River river, final double from, final double to, final DifferencesPair diffPair,
+            final Calculation problems, final GaugeIndex gaugeIndex) {
 
         /* access real input data from database */
         final String soundingId = diffPair.getSoundingId();
@@ -96,18 +95,15 @@
 
         final BedHeight bedHeight = loadBedHeight(soundingId, from, to);
         if (bedHeight == null) {
-            final String message = Resources.format(this.context.getMeta(), "Failed to access sounding with id '{0}'",
-                    soundingId);
+            final String message = Resources.format(this.context.getMeta(), "Failed to access sounding with id '{0}'", soundingId);
             problems.addProblem(message);
             return null;
         }
 
         /* REMARK: fetch ALL wst kms, because we want to determine the original reference gauge */
-        final WaterlevelData waterlevel = new WaterlevelFetcher().findWaterlevel(this.context, wstId, Double.NaN,
-                Double.NaN);
+        final WaterlevelData waterlevel = new WaterlevelFetcher().findWaterlevel(this.context, wstId, Double.NaN, Double.NaN);
         if (waterlevel == null) {
-            final String message = Resources.format(this.context.getMeta(), "Failed to access waterlevel with id '{0}'",
-                    wstId);
+            final String message = Resources.format(this.context.getMeta(), "Failed to access waterlevel with id '{0}'", wstId);
             problems.addProblem(message);
             return null;
         }
@@ -121,8 +117,7 @@
         checkWaterlevelDiscretisation(wstKms, problems);
 
         /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */
-        final String notinrange = Resources.getMsg(this.context.getMeta(), CSV_NOT_IN_GAUGE_RANGE,
-                CSV_NOT_IN_GAUGE_RANGE);
+        final String notinrange = Resources.getMsg(this.context.getMeta(), CSV_NOT_IN_GAUGE_RANGE, CSV_NOT_IN_GAUGE_RANGE);
 
         final Gauge refGauge = waterlevel.findReferenceGauge(river);
         final String refGaugeName = refGauge == null ? notinrange : refGauge.getName();
@@ -136,23 +131,23 @@
         // FIXME: nur prüfen/beschaffen wenn TKH Berechnung aktiv
         /* Abflusswerte vorhanden? */
         if (!(wstKms instanceof QKms)) {
-            final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingQ",
-                    null, label);
+            final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingQ", null, label);
             problems.addProblem(message);
             // TODO: keine Berechnung TKH
         }
 
+        // FIXME
         // - Sohlbeschaffenheit (D50 Korndurchmesser aus Seddb)
         // - Abhängig von Peiljahr
         // - kein D50 vorhanden --> Fehler
 
+        // FIXME
         // - Art der Gewässersohle (starr/mobil)
 
         final String bedHeightLabel = bedHeight.getDescription();
         final String wstLabel = wstKms.getName();
 
-        final UnivariateRealFunction wstInterpolator = DoubleUtil.getLinearInterpolator(wstKms.allKms(),
-                wstKms.allWs());
+        final UnivariateRealFunction wstInterpolator = DoubleUtil.getLinearInterpolator(wstKms.allKms(), wstKms.allWs());
 
         // FIXME: sort by station first, but in what direction?
         final List<BedHeightValue> values = bedHeight.getValues();
@@ -195,8 +190,7 @@
 
                 final String gaugeLabel = gauge == null ? notinrange : gauge.getName();
 
-                resultData.addRow(km, flowDepth, flowDepthTkh, tkh, wst, discharge, wstLabel, gaugeLabel, meanBedHeight,
-                        bedHeightLabel, location);
+                resultData.addRow(km, flowDepth, flowDepthTkh, tkh, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel, location);
             }
             catch (final FunctionEvaluationException e) {
                 /* should only happen if out of range */
@@ -218,8 +212,7 @@
      * 1918 ≤ X < 1958 ± 12
      * X < 1918 ± 25
      */
-    private void checkYearDifference(final String label, final WaterlevelData waterlevel, final BedHeight sounding,
-            final Calculation problems) {
+    private void checkYearDifference(final String label, final WaterlevelData waterlevel, final BedHeight sounding, final Calculation problems) {
 
         final Integer soundingYear = sounding.getYear();
         if (soundingYear == null)
@@ -233,8 +226,7 @@
 
         final int difference = Math.abs(soundingYear - wstYear);
         if (difference > maxDifference) {
-            final String message = Resources.getMsg(this.context.getMeta(),
-                    "sinfo_calc_flow_depth.warning.year_difference", null, label, difference);
+            final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.year_difference", null, label, difference);
             problems.addProblem(message);
         }
     }
@@ -254,8 +246,7 @@
         return 3;
     }
 
-    private Gauge findGauge(final WaterlevelData waterlevel, final Gauge refGauge, final GaugeIndex gaugeIndex,
-            final double km) {
+    private Gauge findGauge(final WaterlevelData waterlevel, final Gauge refGauge, final GaugeIndex gaugeIndex, final double km) {
 
         // REMARK: using same logic as in WaterlevelExporter here
 
@@ -271,6 +262,7 @@
     }
 
     /* Checks if the discretisation of the waterlevel exceeds 1000m */
+    // FIXME: vermutlich sollten wir diesen check auf den gültigkeitsbereich einschränken
     private void checkWaterlevelDiscretisation(final WKms wstKms, final Calculation problems) {
         final int size = wstKms.size();
         for (int i = 0; i < size - 2; i++) {
@@ -280,8 +272,7 @@
             if (Math.abs(kmPrev - kmNext) > 1) {
                 final String label = wstKms.getName();
 
-                final String message = Resources.getMsg(this.context.getMeta(),
-                        "sinfo_calc_flow_depth.warning.waterlevel_discretisation", null, label);
+                final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.waterlevel_discretisation", null, label);
                 problems.addProblem(kmPrev, message);
             }
         }
@@ -314,4 +305,4 @@
 
         return BedHeight.getBedHeightById(bedheightId);
     }
-}
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org