[PATCH] Fixed/changed some FIXMEs/TODOs

Wald Commits scm-commit at wald.intevation.org
Wed May 2 12:19:37 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1525256371 -7200
# Node ID 5294114b1df4c1baf2fb125e001526526efa9f5e
# Parent  13b5b515c61ffe8c1ab3e8a4ebf9c82404b0c892
Fixed/changed some FIXMEs/TODOs

diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java	Wed May 02 12:19:31 2018 +0200
@@ -65,7 +65,7 @@
         if (this.yAxisLabel != null && !this.yAxisLabel.isEmpty()) {
             // REMARK/UNINTENDED: yAxisLabel may also be a resolved message (side-effect of StyledXYSeries#putMetadata),
             // and cannot be resolved, so we need to give the resolved value as default
-            // FIXME: In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here,
+            // TODO: In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here,
             // probably the English version will also show German (CHECK)
             return generator.msg(this.yAxisLabel, this.yAxisLabel);
         }
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/DatacagePairSelectState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/DatacagePairSelectState.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/DatacagePairSelectState.java	Wed May 02 12:19:31 2018 +0200
@@ -92,7 +92,7 @@
     }
 
     /**
-     * Creats the data element used for the static part of DESCRIBE document.
+     * Creates the data element used for the static part of DESCRIBE document.
      */
     @Override
     protected final Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
@@ -107,7 +107,6 @@
         final String[] labels = WaterlevelPairSelectState.getLabels(cc, value);
         final Object[] obj = new Object[] { labels[0] };
 
-        // TODO own i18n
         final String attrValue = Resources.getMsg(cc.getMeta(), "wsp.selected.string", "wsp.selected.string", obj);
 
         creator.addAttr(itemElement, "label", attrValue, true);
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthPairSelectState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthPairSelectState.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthPairSelectState.java	Wed May 02 12:19:31 2018 +0200
@@ -15,7 +15,7 @@
  * @author Gernot Belger
  *
  */
-// FIXME: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
+// REMARK: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
 // abstraction
 public final class FlowDepthPairSelectState extends DatacagePairSelectState {
 
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java	Wed May 02 12:19:31 2018 +0200
@@ -43,7 +43,6 @@
 
     @Override
     public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
-        // FIXME: why is this necessary?
         if (artifact instanceof ChartArtifact) {
             facets.add(new EmptyFacet());
             return null;
diff -r 13b5b515c61f -r 5294114b1df4 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 May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java	Wed May 02 12:19:31 2018 +0200
@@ -96,9 +96,6 @@
         if (historicalSounding == null)
             return null;
 
-        // FIXME: check current/hist wst have same discharge...
-        // FIXME: what means 'same discharge'
-
         final BedHeightInfo currentSoundingInfo = currentSounding.getInfo();
         final BedHeightInfo historicalSoundingInfo = historicalSounding.getInfo();
 
@@ -117,7 +114,6 @@
             return null;
         }
 
-        // FIXME: distinguish error messages
         FlowDepthUtils.checkYearDifference(Resources.getMsg(this.context.getMeta(), "flowdepthdevelopmentcalculation.yearDifferenceCurrent"), currentWstYear,
                 currentSoundingYear, problems);
         FlowDepthUtils.checkYearDifference(Resources.getMsg(this.context.getMeta(), "flowdepthdevelopmentcalculation.yearDifferenceHistorical"),
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java	Wed May 02 12:19:31 2018 +0200
@@ -35,7 +35,7 @@
 
     public FlowDepthDevelopmentCalculationResult(final String label, final WstInfo currentWst, final WstInfo historicalWst, final BedHeightInfo currentSounding,
             final BedHeightInfo historicalSounding, final Collection< ResultRow> rows) {
-        // FIXME: bad abstraction if we give null here...
+        // TODO: bad abstraction if we give null here...
         super(label, null, rows);
 
         this.currentWst = currentWst;
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingCurrentPairSelectState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingCurrentPairSelectState.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingCurrentPairSelectState.java	Wed May 02 12:19:31 2018 +0200
@@ -15,7 +15,7 @@
  * @author Gernot Belger
  *
  */
-// FIXME: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
+// REMARK: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
 // abstraction
 public final class WaterlevelSoundingCurrentPairSelectState extends DatacagePairSelectState {
 
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingHistoricalPairSelectState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingHistoricalPairSelectState.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/WaterlevelSoundingHistoricalPairSelectState.java	Wed May 02 12:19:31 2018 +0200
@@ -13,9 +13,8 @@
 
 /**
  * @author Gernot Belger
- *
  */
-// FIXME: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
+// REAMRK: very ugly; but probably we will break the serialization of WaterlevelPairSelectState if we introduce an
 // abstraction
 public final class WaterlevelSoundingHistoricalPairSelectState extends DatacagePairSelectState {
 
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java	Wed May 02 12:19:31 2018 +0200
@@ -79,7 +79,6 @@
     private BedQualityD50KmValueFinder(final Calculation problems, final double[] kms, final double[] values) {
         this.problems = problems;
 
-        // FIXME: check: max distance prüfen? dann D4E-LinearInterpolator verwenden
         this.interpolator = new LinearInterpolator().interpolate(kms, values);
     }
 
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/DischargeValuesFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/DischargeValuesFinder.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/DischargeValuesFinder.java	Wed May 02 12:19:31 2018 +0200
@@ -77,8 +77,6 @@
     public double getDischarge(final double station) {
 
         try {
-            // FIXME: check: ich dachte wir interpolieren den abfluss nicht linear?
-
             // IMPORTANT: we first try to retrieve the exact value if it is present, to avoid rounding changes due to interpolation.
             // This is important because in the WaterlevelExporter code, these values are double-compared (with '==' ...) in order
             // to find the corresponding main-value.
@@ -90,7 +88,8 @@
 
             return this.qInterpolator.value(station);
         }
-        catch (final FunctionEvaluationException e) {
+        catch (@SuppressWarnings("unused") final FunctionEvaluationException e) {
+            // ignore exception because this can/will happen regularly
             return Double.NaN;
         }
     }
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java	Wed May 02 12:19:31 2018 +0200
@@ -38,7 +38,6 @@
  *
  * @author Matthias Schäfer
  */
-// TODO: noch mal prüfen, ob wir eine interpolationsschranke brauchen (max. km-abstand)
 final class FlowVelocityModelKmValueFinder {
     /***** FIELDS *****/
 
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelDescriptionBuilder.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelDescriptionBuilder.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelDescriptionBuilder.java	Wed May 02 12:19:31 2018 +0200
@@ -29,6 +29,13 @@
  */
 public final class WaterlevelDescriptionBuilder {
 
+    private static final String CSV_META_Q = "export.waterlevel.csv.meta.q";
+
+    // FIXME: unit 'NN + m' is wrong:
+    // - use river-elevation system in case of absolute heights
+    // - use 'cm am Pegel' in other cases
+    private static final String CSV_META_W = "export.waterlevel.csv.meta.w";
+
     private static final String CSV_Q_DESC_HEADER = "export.waterlevel.csv.header.q.desc";
 
     // FIXME: missing in resource-files! hence always the default is used...
@@ -63,6 +70,64 @@
         return this.atGauge;
     }
 
+    public String getMetadata() {
+
+        switch (this.mode) {
+        case QFREE:
+        case QGAUGE: {
+            final String data = getMetadataQ();
+            if (data == null)
+                return null;
+
+            return Resources.getMsg(this.context.getMeta(), CSV_META_Q, CSV_META_Q, data);
+        }
+
+        // TODO: probably none, default is wrong here, but this how it was implemented in WaterlevelExporter.
+        case WFREE:
+        case WGAUGE:
+        case NONE:
+        default:
+            final double[] ws = RiverUtils.getWs(this.artifact);
+
+            if (ws == null || ws.length <= 0)
+                return null;
+
+            // FIXME: we also have here a case single?!
+
+            // FIXME: use correct wst unit!
+
+            // FIXME: bad formatting ofd values. Use the correct Formatter!
+            final String lower = String.valueOf(ws[0]);
+            final String upper = String.valueOf(ws[ws.length - 1]);
+
+            return Resources.getMsg(this.context.getMeta(), CSV_META_W, CSV_META_W, lower, upper);
+        }
+    }
+
+    private String getMetadataQ() {
+
+        final double[] qs = RiverUtils.getQs(this.artifact);
+        if (qs == null || qs.length == 0)
+            return null;
+
+        final RiverUtils.WQ_INPUT input = RiverUtils.getWQInputMode(this.artifact);
+
+        switch (input) {
+        case ADAPTED:
+        case RANGE:
+            return String.valueOf(qs[0]) + " - " + String.valueOf(qs[qs.length - 1]);
+
+        case SINGLE:
+            String data = String.valueOf(qs[0]);
+            for (int i = 1; i < qs.length; i++)
+                data += ", " + String.valueOf(qs[i]);
+            return data;
+
+        default:
+            return null;
+        }
+    }
+
     public String getColumnHeader() {
 
         if (!this.atGauge)
diff -r 13b5b515c61f -r 5294114b1df4 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Wed May 02 12:16:47 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Wed May 02 12:19:31 2018 +0200
@@ -493,6 +493,7 @@
                 new Object[] { RiverUtils.getGaugename(flys) })
         });
 
+        // TODO: code extracted into WaterlevelDescriptionBuilder, should be used instead.
         RiverUtils.WQ_MODE wq = RiverUtils.getWQMode(flys);
         if (wq == RiverUtils.WQ_MODE.QFREE || wq == RiverUtils.WQ_MODE.QGAUGE) {
             double[] qs  = RiverUtils.getQs(flys);


More information about the Dive4Elements-commits mailing list