Mercurial > dive4elements > river
changeset 2557:adb8641f5b5d
WstValueTable: Added method to find the w extent for a given km.
flys-artifacts/trunk@4076 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 17 Feb 2012 11:29:14 +0000 |
parents | efb2038783f9 |
children | 33e4481933e2 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java |
diffstat | 3 files changed, 51 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 17 11:03:28 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 17 11:29:14 2012 +0000 @@ -1,3 +1,12 @@ +2012-02-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxW): + Added method to find the w extent for a given km. Useful + for validating "W auf freier Strecke". + + * src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java: + Removed superfluous import. + 2012-02-17 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java Fri Feb 17 11:03:28 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java Fri Feb 17 11:29:14 2012 +0000 @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import java.math.BigDecimal; - import java.io.Serializable; import net.sf.ehcache.Cache;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 11:03:28 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 11:29:14 2012 +0000 @@ -496,6 +496,27 @@ return qs.toNativeArray(); } + + public double [] getMinMaxW() { + double minW = Double.MAX_VALUE; + double maxW = -Double.MAX_VALUE; + for (int i = 0; i < ws.length; ++i) { + double w = ws[i]; + if (w < minW) minW = w; + if (w > maxW) maxW = w; + } + return new double [] { minW, maxW }; + } + + public double [] getMinMaxW(Row other, double km) { + double [] m1 = this .getMinMaxW(); + double [] m2 = other.getMinMaxW(); + double factor = Linear.factor(km, this.km, other.km); + return new double [] { + Linear.weight(factor, m1[0], m2[0]), + Linear.weight(factor, m1[1], m2[1]) + }; + } } // class Row /** Rows in table. */ @@ -585,6 +606,27 @@ return ws; } + public double [] getMinMaxW(double km) { + int rowIndex = Collections.binarySearch(rows, new Row(km)); + + if (rowIndex >= 0) { + return rows.get(rowIndex).getMinMaxW(); + } + + rowIndex = -rowIndex -1; + + if (rowIndex < 1 || rowIndex >= rows.size()) { + // do not extrapolate + return null; + } + + Row r1 = rows.get(rowIndex-1); + Row r2 = rows.get(rowIndex); + + return r1.getMinMaxW(r2, km); + } + + /** * Interpolate W and Q values at a given km. */