[PATCH] Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo

Wald Commits scm-commit at wald.intevation.org
Mon Oct 6 19:08:02 CEST 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1412615277 -7200
# Node ID 4de385d58a3ee58f3835eb4a4f1a9683e3d3d0fb
# Parent  15f4e4785288fde51b12af4b984ed69c8a6b895d
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.

diff -r 15f4e4785288 -r 4de385d58a3e artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java	Mon Oct 06 15:33:52 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java	Mon Oct 06 19:07:57 2014 +0200
@@ -47,7 +47,7 @@
 import org.dive4elements.river.utils.RiverUtils;
 import org.dive4elements.river.utils.Formatter;
 
-import static org.dive4elements.river.exports.injector.InjectorConstants.PNP;
+import static org.dive4elements.river.exports.injector.InjectorConstants.GAUGE_EPSILON;
 
 /**
  * @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
@@ -112,7 +112,8 @@
             double[] kms = rangeAccess.getKmRange();
 
             Gauge gauge = river.determineGaugeByPosition(kms[0]);
-            if (context.getContextValue(PNP) instanceof Number) {
+            if (Math.abs(kms[0] - gauge.getStation().doubleValue())
+                < GAUGE_EPSILON) {
                 wUnit = "cm";
                 gaugeName = gauge.getName();
                 gaugeDatum = gauge.getDatum().doubleValue();
@@ -121,11 +122,15 @@
                 List<WQKms> newData = new ArrayList<WQKms>();
                 for (WQKms d2: data) {
                     newData.add(new WQKms(d2.getKms(),
-                                WQ.getFixedWQforExportAtGauge((WQ)d2, gauge.getDatum())));
+                            WQ.getFixedWQforExportAtGauge(
+                                (WQ)d2,
+                                gauge.getDatum()
+                            )));
                 }
                 data = newData; // All hail the garbage collector
 
-                validSince = gauge.fetchMasterDischargeTable().getTimeInterval().getStartTime();
+                validSince = gauge.fetchMasterDischargeTable()
+                    .getTimeInterval().getStartTime();
             } else {
                 gaugeName = "";
                 validSince = null;
@@ -261,7 +266,7 @@
         source.addMetaData("range",
                 Formatter.getCalculationKm(context.getMeta()).format(kms[0]));
 
-        if (!(context.getContextValue(PNP) instanceof Number)) {
+        if (!"cm".equals(wUnit)) {
             source.addMetaData("valid_since", "");
             source.addMetaData("calculation", Resources.getMsg(
                                                 locale,


More information about the Dive4Elements-commits mailing list