diff flys-aft/src/main/java/de/intevation/aft/WQ.java @ 4091:a91c7e982c32

Make W/Q values from AFT and FLYS loadable. flys-aft/trunk@3601 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 05 Jan 2012 16:41:26 +0000
parents
children 82f5266f881b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/WQ.java	Thu Jan 05 16:41:26 2012 +0000
@@ -0,0 +1,67 @@
+package de.intevation.aft;
+
+import java.util.Comparator;
+
+public class WQ
+{
+    public static final double EPSILON = 1e-4;
+
+    public static final Comparator<WQ> WQ_EPS_CMP = new Comparator<WQ>() {
+        @Override
+        public int compare(WQ a, WQ b) {
+            int cmp = compareEpsilon(a.w, b.w);
+            if (cmp != 0) return cmp;
+            return compareEpsilon(a.q, b.q);
+        }
+    };
+
+    protected int id;
+
+    protected double w;
+    protected double q;
+
+    public WQ() {
+    }
+
+    public WQ(double w, double q) {
+        this.w = w;
+        this.q = q;
+    }
+
+    public WQ(int id, double w, double q) {
+        this.id = id;
+        this.w  = w;
+        this.q  = q;
+    }
+
+    public static final int compareEpsilon(double a, double b) {
+        double diff = a - b;
+        if (diff < -EPSILON) return -1;
+        return diff > EPSILON ? +1 : 0;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public double getW() {
+        return w;
+    }
+
+    public void setW(double w) {
+        this.w = w;
+    }
+
+    public double getQ() {
+        return q;
+    }
+
+    public void setQ(double q) {
+        this.q = q;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org