annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WW.java @ 2199:7bac5afb9892

Skip 'inactive' points in output generation. flys-artifacts/trunk@3815 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 30 Jan 2012 08:37:01 +0000
parents 672a41efe222
children 4e3bfa2d9584
rev   line source
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
2198
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
3 import de.intevation.flys.artifacts.math.Function;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
4 import de.intevation.flys.artifacts.math.Identity;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
5
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import gnu.trove.TDoubleArrayList;
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 public class WW
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 extends W
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 {
2198
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
11 public static class ApplyFunctionIterator
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
12 {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
13 protected Function function1;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
14 protected Function function2;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
15 protected int pos;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
16 protected WW ww;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
17
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
18 public ApplyFunctionIterator(WW ww) {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
19 this.ww = ww;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
20 this.function1 = Identity.IDENTITY;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
21 this.function2 = Identity.IDENTITY;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
22 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
23
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
24 public boolean hasNext() {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
25 return pos < ww.size();
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
26 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
27
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
28 public int size() {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
29 return ww.size();
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
30 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
31
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
32 public void reset() {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
33 pos = 0;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
34 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
35
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
36 public WW getWW() {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
37 return ww;
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
38 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
39
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
40 public void get(int idx, double [] wwPair) {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
41 wwPair[0] = function1.value(ww.getW(idx));
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
42 wwPair[1] = function2.value(ww.getW2(idx));
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
43 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
44
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
45 public void next(double [] wwPair) {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
46 get(pos++, wwPair);
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
47 }
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
48 } // class FunctionIterator
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
49
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 protected TDoubleArrayList ws2;
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 public WW() {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 public WW(String name) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 super(name);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 public WW(int capacity) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 this(capacity, "");
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 public WW(int capacity, String name) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 super(capacity, name);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 ws2 = new TDoubleArrayList(capacity);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
68 public WW(String name, double [] ws, double [] ws2) {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
69 this.name = name;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
70 this.ws = new TDoubleArrayList(ws);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
71 this.ws2 = new TDoubleArrayList(ws2);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
72 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2182
diff changeset
73
2197
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
74 public WW(String name, TDoubleArrayList ws, TDoubleArrayList ws2) {
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
75 this.name = name;
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
76 this.ws = ws;
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
77 this.ws2 = ws2;
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
78 }
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
79
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 public void add(double w1, double w2) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 ws .add(w1);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 ws2.add(w2);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 public double getW2(int idx) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 return ws2.getQuick(idx);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 public double [] getWs2() {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 return ws2.toNativeArray();
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 @Override
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 public double [] get(int idx) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 return get(idx, new double[2]);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 @Override
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 public double [] get(int idx, double [] dst) {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 dst[0] = ws .getQuick(idx);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 dst[1] = ws2.getQuick(idx);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 return dst;
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 @Override
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 public void removeNaNs() {
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 removeNaNs(new TDoubleArrayList [] { ws, ws2 });
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 }
2197
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
109
2198
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
110 public double minWs2() {
672a41efe222 "Bezugslinienverfahren": Replaced normalized curve generation with a better and needed solution.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2197
diff changeset
111 return ws2.min();
2197
5781847433d8 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
112 }
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 }
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org