changeset 2281:08811a335baf

"Bezugslinienverfahren": Do normalisation of reference curves. flys-artifacts/trunk@3943 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 06 Feb 2012 17:40:36 +0000
parents ba7ecb20a344
children 4d30e38600b8
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearFunction.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java
diffstat 3 files changed, 49 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Feb 06 16:35:55 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Feb 06 17:40:36 2012 +0000
@@ -1,4 +1,12 @@
-2012-02-06  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+2012-02-06	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/math/LinearFunction.java:
+	  New. Linear function f(x) = m*x + b.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java:
+	  Do the normalizing. Cascading functions is not required.
+
+2012-02-06	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveInfoGenerator.java:
 	  Added missing chart info generator for the normalized reference curves.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearFunction.java	Mon Feb 06 17:40:36 2012 +0000
@@ -0,0 +1,19 @@
+package de.intevation.flys.artifacts.math;
+
+public class LinearFunction 
+implements   Function
+{
+    protected double m;
+    protected double b;
+
+    public LinearFunction(double m, double b) {
+        this.m = m;
+        this.b = b;
+    }
+
+    @Override
+    public double value(double x) {
+        return x*m + b;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java	Mon Feb 06 16:35:55 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java	Mon Feb 06 17:40:36 2012 +0000
@@ -2,7 +2,7 @@
 
 import de.intevation.flys.artifacts.math.Function;
 import de.intevation.flys.artifacts.math.Identity;
-import de.intevation.flys.artifacts.math.LinearFilterFunction;
+import de.intevation.flys.artifacts.math.LinearFunction;
 
 public class WWAxisTypes
 {
@@ -44,15 +44,28 @@
     }
 
     public WW.ApplyFunctionIterator transform(WW ww, boolean normalized) {
-        // TODO: Do normalising.
 
-        Function function1 = inCm1
-            ? new LinearFilterFunction(100d, -ww.getStartDatum())
-            : Identity.IDENTITY;
+        Function function1;
+        Function function2;
 
-        Function function2 = inCm2
-            ? new LinearFilterFunction(100d, -ww.getEndDatum())
-            : Identity.IDENTITY;
+        if (!normalized) {
+            function1 = inCm1
+                ? new LinearFunction(100d, -ww.getStartDatum())
+                : Identity.IDENTITY;
+
+            function2 = inCm2
+                ? new LinearFunction(100d, -ww.getEndDatum())
+                : Identity.IDENTITY;
+        }
+        else {
+            double minW1 = ww.minWs();
+            double minW2 = ww.minWs2();
+            double scale1 = inCm1 ? 100d : 1d;
+            double scale2 = inCm2 ? 100d : 1d;
+            function1 = new LinearFunction(scale1, -minW1);
+            function2 = new LinearFunction(scale1, -minW2);
+        }
+
 
         return new WW.ApplyFunctionIterator(ww, function1, function2);
     }

http://dive4elements.wald.intevation.org