# HG changeset patch # User Sascha L. Teichmann # Date 1328550036 0 # Node ID 08811a335baf501090f11dc6ab762e26d6d2dcd1 # Parent ba7ecb20a344b139a266fd76f32a7a824a6e9b70 "Bezugslinienverfahren": Do normalisation of reference curves. flys-artifacts/trunk@3943 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ba7ecb20a344 -r 08811a335baf flys-artifacts/ChangeLog --- 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 +2012-02-06 Sascha L. Teichmann + + * 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 * src/main/java/de/intevation/flys/exports/NormalizedReferenceCurveInfoGenerator.java: Added missing chart info generator for the normalized reference curves. diff -r ba7ecb20a344 -r 08811a335baf flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearFunction.java --- /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 : diff -r ba7ecb20a344 -r 08811a335baf flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java --- 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); }