comparison 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
comparison
equal deleted inserted replaced
4090:d556e29592f5 4091:a91c7e982c32
1 package de.intevation.aft;
2
3 import java.util.Comparator;
4
5 public class WQ
6 {
7 public static final double EPSILON = 1e-4;
8
9 public static final Comparator<WQ> WQ_EPS_CMP = new Comparator<WQ>() {
10 @Override
11 public int compare(WQ a, WQ b) {
12 int cmp = compareEpsilon(a.w, b.w);
13 if (cmp != 0) return cmp;
14 return compareEpsilon(a.q, b.q);
15 }
16 };
17
18 protected int id;
19
20 protected double w;
21 protected double q;
22
23 public WQ() {
24 }
25
26 public WQ(double w, double q) {
27 this.w = w;
28 this.q = q;
29 }
30
31 public WQ(int id, double w, double q) {
32 this.id = id;
33 this.w = w;
34 this.q = q;
35 }
36
37 public static final int compareEpsilon(double a, double b) {
38 double diff = a - b;
39 if (diff < -EPSILON) return -1;
40 return diff > EPSILON ? +1 : 0;
41 }
42
43 public int getId() {
44 return id;
45 }
46
47 public void setId(int id) {
48 this.id = id;
49 }
50
51 public double getW() {
52 return w;
53 }
54
55 public void setW(double w) {
56 this.w = w;
57 }
58
59 public double getQ() {
60 return q;
61 }
62
63 public void setQ(double q) {
64 this.q = q;
65 }
66 }
67 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org