Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKms.java @ 398:435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
flys-artifacts/trunk@1828 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 05 May 2011 05:27:41 +0000 |
parents | 5f55047a17e8 |
children | eb22ffe4d74c |
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 |
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
|
3 import java.io.Serializable; |
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
|
4 |
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
5 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
|
6 |
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 */ |
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
|
14 public class WQKms implements Serializable { |
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
|
15 |
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
|
16 /** The array that contains the 'W' 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
|
17 protected TDoubleArrayList w; |
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
|
18 |
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 'Q' 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 q; |
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 /** 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
|
23 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
|
24 |
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
|
25 |
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
|
26 public WQKms() { |
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
|
27 this.w = new TDoubleArrayList(); |
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
28 this.q = new TDoubleArrayList(); |
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
29 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
|
30 } |
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 |
380
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
32 public WQKms(int capacity) { |
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
33 this.w = 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
|
34 this.q = 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
|
35 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
|
36 } |
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
367
diff
changeset
|
37 |
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
|
38 |
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
|
39 /** |
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
|
40 * 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
|
41 * |
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
|
42 * @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
|
43 * @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
|
44 * @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
|
45 */ |
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
|
46 public void add(double w, double q, double kms) { |
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
|
47 this.w.add(w); |
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
48 this.q.add(q); |
c13ca9d632d6
Introduced GNU Trove to store WQKms values in a more performant data structure.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
361
diff
changeset
|
49 this.kms.add(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
|
50 } |
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
|
51 |
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
|
52 |
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
|
53 /** |
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
|
54 * Returns the number of triples stored in this data pool. |
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
|
55 * |
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
|
56 * @return the number of triples stored in this data pool. |
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
|
57 */ |
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
|
58 public int size() { |
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
|
59 return kms.size(); |
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
|
60 } |
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
|
61 |
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
|
62 /** |
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
|
63 * 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
|
64 * |
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
|
65 * @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
|
66 * @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
|
67 * |
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
|
68 * @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
|
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 public double[] get(int idx, double [] 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
|
71 dst[0] = w .get(idx); |
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 dst[1] = q .get(idx); |
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 dst[2] = kms.get(idx); |
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 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
|
75 } |
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
|
76 |
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
|
77 |
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
|
78 public double getKms(int idx) { |
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
|
79 return kms.get(idx); |
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
|
80 } |
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
|
81 } |
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
|
82 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |