Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKms.java @ 743:e95e6df97e55
#177 Commented out the code that generates the series names in discharge curves. This code currently generates memory problems and stops the server accepting new http requests.
flys-artifacts/trunk@2245 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 27 Jun 2011 07:45:32 +0000 |
parents | c09c9e05ecfa |
children | 0cb1a70b8b92 |
rev | line source |
---|---|
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
365
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
3 import gnu.trove.TDoubleArrayList; |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
5 import org.apache.log4j.Logger; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
6 |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 /** |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * This class represents a pool of data triples that consists of 'W', 'Q' and |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 * 'KM' data. |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 * |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 */ |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
14 public class WQKms |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
15 extends WQ |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
16 { |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
17 private static Logger logger = Logger.getLogger(WQKms.class); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
18 |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 /** The array that contains the 'KMs' values.*/ |
365
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
20 protected TDoubleArrayList kms; |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public WQKms() { |
447
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
24 this(""); |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
25 } |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
26 |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
27 |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
28 public WQKms(String name) { |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
29 super(name); |
365
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
30 this.kms = new TDoubleArrayList(); |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 } |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
447
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
33 |
380
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
34 public WQKms(int capacity) { |
447
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
35 this(capacity, ""); |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
36 } |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
37 |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
38 |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
39 public WQKms(int capacity, String name) { |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
40 super(name); |
380
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
41 this.kms = new TDoubleArrayList(capacity); |
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
42 } |
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
43 |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
44 public WQKms(double [] kms, double [] qs, double [] ws) { |
447
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
45 this(kms, qs, ws, ""); |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
46 } |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
47 |
5606ba4139e0
WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
402
diff
changeset
|
48 |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
49 public WQKms(double [] kms, double [] qs, double [] ws, String name) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
50 super(qs, ws, name); |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
51 this.kms = new TDoubleArrayList(kms); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
52 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
53 |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
54 @Override |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
55 public void removeNaNs() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
56 removeNaNs(new TDoubleArrayList [] { w, q, kms }); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
57 } |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
58 |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 /** |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 * Adds a new row to this data pool. |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 * |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @param w a W. |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * @param q a Q. |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 * @param kms a Kms. |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 */ |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
66 public void add(double w, double q, double km) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
67 super.add(w, q); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
68 kms.add(km); |
366
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
69 } |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
70 |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
71 /** |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
72 * This method returns a triple of W, Q and Kms in a single 3dim array. |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
73 * |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
74 * @param idx The position of the triple. |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
75 * @param dst destination array |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
76 * |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
77 * @return a triple of [W, Q, Kms] in dst. |
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
78 */ |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
79 @Override |
366
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
80 public double[] get(int idx, double [] dst) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
81 dst[0] = w .getQuick(idx); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
82 dst[1] = q .getQuick(idx); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
83 dst[2] = kms.getQuick(idx); |
366
d64339f9f38f
WQKms model: Added a get() method which takes destination array as an argument.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
365
diff
changeset
|
84 return dst; |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
367
0960df8358ec
New method WQKms.size() to retrieve the number of elements in the data pool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
366
diff
changeset
|
86 |
0960df8358ec
New method WQKms.size() to retrieve the number of elements in the data pool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
366
diff
changeset
|
87 public double getKms(int idx) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
88 return kms.getQuick(idx); |
367
0960df8358ec
New method WQKms.size() to retrieve the number of elements in the data pool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
366
diff
changeset
|
89 } |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
90 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
91 public double[] getKms() { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
92 return kms.toNativeArray(); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
93 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
94 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
95 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
96 * Returns a string that consist of the first and last kilometer. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
97 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
98 * @return a string that consist of the first and last kilometer. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
99 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
100 public String toString() { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
101 double from = getKms(0); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
102 double to = getKms(size()-1); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
447
diff
changeset
|
103 return from + " - " + to; |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
380
diff
changeset
|
104 } |
361
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 } |
3e3ec9613883
Introduced a model class to store a set of triple data objects that consist of W, Q and Kms information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |