annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWQQ.java @ 5151:240ff7aeb6de

DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 01 Mar 2013 10:04:57 +0100
parents bcf25d8c183e
children
rev   line source
2271
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import de.intevation.flys.artifacts.math.Identity;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
4821
bcf25d8c183e Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3076
diff changeset
5 import de.intevation.flys.utils.DoubleUtil;
bcf25d8c183e Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3076
diff changeset
6
2271
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import gnu.trove.TDoubleArrayList;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 public class WWQQ
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 extends WW
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 public static class ApplyFunctionIterator
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 extends WW.ApplyFunctionIterator
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 public ApplyFunctionIterator(WWQQ ww) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 super(ww, Identity.IDENTITY, Identity.IDENTITY);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 @Override
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public void get(int idx, double [] wwqqPair) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 WWQQ wwqq = (WWQQ)ww;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 wwqqPair[0] = function1.value(wwqq.getW(idx));
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 wwqqPair[1] = function2.value(wwqq.getW2(idx));
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 wwqqPair[2] = wwqq.getQ1(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 wwqqPair[3] = wwqq.getQ2(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 } // class ApplyFunctionIterator
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected TDoubleArrayList qs1;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 protected TDoubleArrayList qs2;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public WWQQ() {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 this("");
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public WWQQ(String name) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 super(name);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public WWQQ(int capacity) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 this(capacity, "");
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 public WWQQ(int capacity, String name) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 super(capacity, name);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 public WWQQ(
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2271
diff changeset
49 String name,
2271
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 double startKm,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 Double startDatum,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 double [] ws1,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 double [] qs1,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 double endKm,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 Double endDatum,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 double [] ws2,
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 double [] qs2
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 ) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 super(name, startKm, startDatum, ws1, endKm, endDatum, ws2);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 this.qs1 = new TDoubleArrayList(qs1);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 this.qs2 = new TDoubleArrayList(qs2);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 public double getQ1(int idx) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 return qs1.getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 public double getQ2(int idx) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 return qs2.getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 public double [] getQs1() {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 return qs1.toNativeArray();
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 public double [] getQs2() {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 return qs2.toNativeArray();
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 @Override
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 public double [] get(int idx) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 return get(idx, new double[4]);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 @Override
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 public double [] get(int idx, double [] dst) {
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 dst[0] = ws .getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 dst[1] = ws2.getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 dst[2] = qs1.getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 dst[3] = qs2.getQuick(idx);
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 return dst;
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 @Override
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 public void removeNaNs() {
4821
bcf25d8c183e Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3076
diff changeset
96 DoubleUtil.removeNaNs(new TDoubleArrayList [] { ws, ws2, qs1, qs2 });
2271
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 }
3973a2451cf7 "Bezugslinienverfahren": Store Qs of calculation, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org