changeset 8383:4de385d58a3e

Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
author Tom Gottfried <tom@intevation.de>
date Mon, 06 Oct 2014 19:07:57 +0200
parents 15f4e4785288
children d4a2c7b83087
files artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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@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,

http://dive4elements.wald.intevation.org