[PATCH 4 of 6] issue1020: Make WQKms able to build from WKms

Wald Commits scm-commit at wald.intevation.org
Thu Dec 5 15:38:46 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1386254104 -3600
# Node ID 7e5d4a0d9bad4b5e696ae446bdf7b10e8fa66b2e
# Parent  f2f34d72280735deb2c541907e8df003a252289c
issue1020: Make WQKms able to build from WKms.

diff -r f2f34d722807 -r 7e5d4a0d9bad artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java	Wed Dec 04 10:21:08 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java	Thu Dec 05 15:35:04 2013 +0100
@@ -66,12 +66,26 @@
         this(kms, wq.getQs(), wq.getWs(), wq.getName(), wq.getReferenceSystem());
     }
 
+    public WQKms(TDoubleArrayList kms, TDoubleArrayList qs, TDoubleArrayList ws, String name) {
+        super(qs, ws, name);
+        this.kms = kms;
+        setReferenceSystem(0);
+    }
+
     public WQKms(double [] kms, double [] qs, double [] ws, String name, int wReferenceSystem) {
         super(qs, ws, name);
         this.kms = new TDoubleArrayList(kms);
         setReferenceSystem(wReferenceSystem);
     }
 
+    /** Create a WQKms from WKms, filling the Qs with given q. */
+    public static WQKms fromWKms(WKms wkms, double q) {
+        TDoubleArrayList qs = new TDoubleArrayList(wkms.allKms().size());
+        qs.fill(q);
+        WQKms wqkms = new WQKms(wkms.allKms(), qs, wkms.allWs(), wkms.getName());
+        return wqkms;
+    }
+
     @Override
     public void removeNaNs() {
         DoubleUtil.removeNaNs(new TDoubleArrayList [] { ws, qs, kms });


More information about the Dive4elements-commits mailing list