Mercurial > dive4elements > river
changeset 8549:1cff4c98df76
(issue1754) Extend WKms interface for KM filtering
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 16 Feb 2015 15:28:22 +0100 |
parents | 0011508d2f9d |
children | 532da345d4a7 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKms.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKmsImpl.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java |
diffstat | 3 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKms.java Mon Feb 16 15:27:39 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKms.java Mon Feb 16 15:28:22 2015 +0100 @@ -21,6 +21,9 @@ TDoubleArrayList allKms(); + /** A new list of values between the km's from and to. */ + WKms filteredKms(double from, double to); + TDoubleArrayList allWs(); boolean guessWaterIncreasing();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKmsImpl.java Mon Feb 16 15:27:39 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKmsImpl.java Mon Feb 16 15:28:22 2015 +0100 @@ -108,5 +108,17 @@ public TDoubleArrayList allWs() { return ws; } + + @Override + public WKms filteredKms(double from, double to) { + WKmsImpl retval = new WKmsImpl(getName()); + for (int i = 0; i < size(); i++) { + double km = kms.getQuick(i); + if (km >= from && km <= to) { + retval.add(ws.getQuick(i), km); + } + } + return retval; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Mon Feb 16 15:27:39 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Mon Feb 16 15:28:22 2015 +0100 @@ -137,6 +137,18 @@ return qs; } + @Override + public WKms filteredKms(double from, double to) { + WQKms retval = new WQKms(getName()); + for (int i = 0; i < size(); i++) { + double km = kms.getQuick(i); + if (km >= from && km <= to) { + retval.add(ws.getQuick(i), qs.getQuick(i), km); + } + } + return retval; + } + public double[] getKms() { return kms.toNativeArray(); }