Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKms.java @ 3814:8083f6384023
merged flys-artifacts/pre2.6-2012-01-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:56 +0200 |
parents | 03fbf1b30e72 |
children | 5ff481ab24a1 |
comparison
equal
deleted
inserted
replaced
1491:2a00f4849738 | 3814:8083f6384023 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import gnu.trove.TDoubleArrayList; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 | |
8 /** | |
9 * This class represents a pool of data triples that consists of 'W', 'Q' and | |
10 * 'KM' data. | |
11 * | |
12 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
13 */ | |
14 public class WQKms | |
15 extends WQ | |
16 implements WKms | |
17 { | |
18 private static Logger logger = Logger.getLogger(WQKms.class); | |
19 | |
20 /** The array that contains the 'KMs' values. */ | |
21 protected TDoubleArrayList kms; | |
22 | |
23 | |
24 public WQKms() { | |
25 this(""); | |
26 } | |
27 | |
28 | |
29 public WQKms(String name) { | |
30 super(name); | |
31 this.kms = new TDoubleArrayList(); | |
32 } | |
33 | |
34 | |
35 public WQKms(int capacity) { | |
36 this(capacity, ""); | |
37 } | |
38 | |
39 | |
40 public WQKms(int capacity, String name) { | |
41 super(name); | |
42 this.kms = new TDoubleArrayList(capacity); | |
43 } | |
44 | |
45 public WQKms(double [] kms, double [] qs, double [] ws) { | |
46 this(kms, qs, ws, ""); | |
47 } | |
48 | |
49 | |
50 public WQKms(double [] kms, double [] qs, double [] ws, String name) { | |
51 super(qs, ws, name); | |
52 this.kms = new TDoubleArrayList(kms); | |
53 } | |
54 | |
55 @Override | |
56 public void removeNaNs() { | |
57 removeNaNs(new TDoubleArrayList [] { w, q, kms }); | |
58 } | |
59 | |
60 /** | |
61 * Adds a new row to this data pool. | |
62 * | |
63 * @param w a W. | |
64 * @param q a Q. | |
65 * @param kms a Kms. | |
66 */ | |
67 public void add(double w, double q, double km) { | |
68 super.add(w, q); | |
69 kms.add(km); | |
70 } | |
71 | |
72 /** | |
73 * This method returns a triple of W, Q and Kms in a single 3dim array. | |
74 * | |
75 * @param idx The position of the triple. | |
76 * @param dst destination array | |
77 * | |
78 * @return a triple of [W, Q, Kms] in dst. | |
79 */ | |
80 @Override | |
81 public double[] get(int idx, double [] dst) { | |
82 dst[0] = w .getQuick(idx); | |
83 dst[1] = q .getQuick(idx); | |
84 dst[2] = kms.getQuick(idx); | |
85 return dst; | |
86 } | |
87 | |
88 @Override | |
89 public double getKm(int idx) { | |
90 return kms.getQuick(idx); | |
91 } | |
92 | |
93 @Override | |
94 public TDoubleArrayList allKms() { | |
95 return kms; | |
96 } | |
97 | |
98 @Override | |
99 public TDoubleArrayList allWs() { | |
100 return w; | |
101 } | |
102 | |
103 public double[] getKms() { | |
104 return kms.toNativeArray(); | |
105 } | |
106 | |
107 /** | |
108 * Returns a string that consist of the first and last kilometer. | |
109 * | |
110 * @return a string that consist of the first and last kilometer. | |
111 */ | |
112 public String toString() { | |
113 double from = getKm(0); | |
114 double to = getKm(size()-1); | |
115 return from + " - " + to; | |
116 } | |
117 } | |
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |