Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 5334:b296d435fc69
Doc and whitespace fixes.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 19 Mar 2013 10:25:23 +0100 |
parents | fe987587ebc9 |
children |
rev | line source |
---|---|
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Linear; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.util.Arrays; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.io.Serializable; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 public class FixingsColumn |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 implements Serializable |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 protected double [] kms; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 protected double [] ws; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 protected QRangeTree qs; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public FixingsColumn() { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public FixingsColumn( |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
21 double [] kms, |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
22 double [] ws, |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
23 QRangeTree qs |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 ) { |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
25 this.kms = kms; |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
26 this.ws = ws; |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
27 this.qs = qs; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
30 public boolean getW(double km, double [] w) { |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
31 return getW(km, w, 0); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
32 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
33 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
34 public boolean getW(double km, double [] w, int index) { |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
36 if (kms.length == 0 || km < kms[0] || km > kms[kms.length-1]) { |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
37 w[index] = Double.NaN; |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
38 return true; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 int idx = Arrays.binarySearch(kms, km); |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
43 if (idx >= 0) { |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2619
diff
changeset
|
44 w[index] = ws[idx]; |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
45 return true; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
46 } |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 idx = -idx - 1; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
2792
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2729
diff
changeset
|
50 w[index] = Linear.linear(km, kms[idx-1], kms[idx], ws[idx-1], ws[idx]); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
51 return false; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 public double getQ(double km) { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 return qs.findQ(km); |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
2792
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2729
diff
changeset
|
57 |
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2729
diff
changeset
|
58 public QRangeTree getQRanges() { |
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2729
diff
changeset
|
59 return qs; |
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2729
diff
changeset
|
60 } |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |