# HG changeset patch # User Sascha L. Teichmann # Date 1329488210 0 # Node ID 0d8c97374dc9e8f0d14f30276597c7e76e5f7460 # Parent 407bbc74fe0b9c4beedeb61087fd08413027bbae WstValueTable: Forget to check in the range method of getMinMaxQ(). flys-artifacts/trunk@4086 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 407bbc74fe0b -r 0d8c97374dc9 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Feb 17 14:04:54 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 17 14:16:50 2012 +0000 @@ -1,3 +1,8 @@ +2012-02-17 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxQ): + Argh! Forget to check in the range method. + 2012-02-17 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxQ): diff -r 407bbc74fe0b -r 0d8c97374dc9 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 14:04:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 14:16:50 2012 +0000 @@ -632,6 +632,39 @@ return null; } + public double [] getMinMaxQ(double from, double to, double step) { + double [] result = new double[2]; + + double minQ = Double.MAX_VALUE; + double maxQ = -Double.MAX_VALUE; + + if (from > to) { + double tmp = from; + from = to; + to = tmp; + } + + step = Math.max(Math.abs(step), 0.0001); + + double d = from; + for (; d <= to; d += step) { + if (getMinMaxQ(d, result) != null) { + if (result[0] < minQ) minQ = result[0]; + if (result[1] > maxQ) maxQ = result[1]; + } + } + + if (d != to) { + if (getMinMaxQ(to, result) != null) { + if (result[0] < minQ) minQ = result[0]; + if (result[1] > maxQ) maxQ = result[1]; + } + } + + return minQ < Double.MAX_VALUE + ? new double [] { minQ, maxQ } + : null; + } public double [] getMinMaxW(double km) { return getMinMaxW(km, new double [2]);