[PATCH] Try to determine gauge by km in gauge discharge facet for exporter

Wald Commits scm-commit at wald.intevation.org
Tue Oct 7 13:43:05 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1412682114 -7200
# Node ID a9d493aba9267581de6a272e937828c4db31a0e3
# Parent  24d3370af00bd601ca281991829ad14e670bcbac
Try to determine gauge by km in gauge discharge facet for exporter.

diff -r 24d3370af00b -r a9d493aba926 artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java	Tue Oct 07 11:24:13 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java	Tue Oct 07 13:41:54 2014 +0200
@@ -17,7 +17,7 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 
 import org.dive4elements.river.artifacts.D4EArtifact;
-
+import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.model.Gauge;
 
 import org.dive4elements.river.utils.RiverUtils;
@@ -25,6 +25,7 @@
 import org.apache.log4j.Logger;
 
 import static org.dive4elements.river.exports.injector.InjectorConstants.PNP;
+import static org.dive4elements.river.exports.injector.InjectorConstants.GAUGE_EPSILON;
 
 /**
  * A Facet that returns discharge curve data at a gauge
@@ -82,10 +83,24 @@
 
         Object pnpObject = context.getContextValue(PNP);
         if (!(pnpObject instanceof Number)) {
+            RangeAccess access = new RangeAccess(flys);
+            double km = Double.NaN;
+            if (access.getLocations() != null &&
+                access.getLocations().length > 0) {
+                km = access.getLocations()[0];
+            }
+            Gauge g = access.getRiver().determineGaugeByStation(
+                    km - GAUGE_EPSILON,
+                    km + GAUGE_EPSILON);
+            if (g != null) {
+                return new WQKms(
+                    kms,
+                    values[0],
+                    transformToM(values[1], g.getDatum().doubleValue()));
+            }
             return new WQKms(kms, values[0], values[1], name);
         }
-        double pnp = ((Number)pnpObject).doubleValue();
-        double[] ws = transformToM(values[1], pnp);
+        double[] ws = transformToM(values[1], ((Number)pnpObject).doubleValue());
 
         return new WQKms(kms, values[0], ws, name);
     }


More information about the Dive4Elements-commits mailing list