annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WKmsImpl.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children af13ceeba52a
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2422
diff changeset
9 package org.dive4elements.river.artifacts.model;
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import gnu.trove.TDoubleArrayList;
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2422
diff changeset
13 import org.dive4elements.river.utils.DataUtil;
2420
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
14
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
15
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public class WKmsImpl
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 extends NamedObjectImpl
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 implements WKms
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 protected TDoubleArrayList kms;
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 protected TDoubleArrayList ws;
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 public WKmsImpl() {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 super("");
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 kms = new TDoubleArrayList();
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 ws = new TDoubleArrayList();
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
29
1720
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
30 /**
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
31 * Create named, empty WKms.
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
32 */
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
33 public WKmsImpl(String name) {
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
34 super(name);
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
35 kms = new TDoubleArrayList();
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
36 ws = new TDoubleArrayList();
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
37 }
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
38
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
39
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public WKmsImpl(int capacity) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 super("");
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 kms = new TDoubleArrayList(capacity);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 ws = new TDoubleArrayList(capacity);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
46
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 public WKmsImpl(TDoubleArrayList kms, TDoubleArrayList ws) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 this(kms, ws, "");
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
51
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 public WKmsImpl(
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 TDoubleArrayList kms,
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 TDoubleArrayList ws,
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 String name
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 ) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 super(name);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 this.kms = kms;
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 this.ws = ws;
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
62
1720
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
63 /**
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
64 * Add a W (in NN+m) for a km (in km).
fa932d618989 Added constructor that will be needed in creation of WKms for 'static' data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1678
diff changeset
65 */
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 public void add(double km, double w) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 kms.add(km);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 ws .add(w);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
71
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
72 @Override
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 public double getW(int index) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 return ws.getQuick(index);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
77
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
78 @Override
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 public double getKm(int index) {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 return kms.getQuick(index);
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82
2420
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
83 @Override
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
84 public boolean guessWaterIncreasing() {
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
85 return guessWaterIncreasing(0.05f);
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
86 }
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
87
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2420
diff changeset
88 protected boolean guessWaterIncreasing(float factor) {
2420
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
89 return DataUtil.guessWaterIncreasing(ws, factor);
65ff8ff20be4 Fix flys/issue150 ('water increasing').
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1720
diff changeset
90 }
1162
588798ef4791 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 925
diff changeset
91
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
92 @Override
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 public int size() {
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 return kms.size();
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 }
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
96
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
97 @Override
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
98 public TDoubleArrayList allKms() {
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
99 return kms;
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
100 }
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
101
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
102 @Override
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
103 public TDoubleArrayList allWs() {
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
104 return ws;
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1162
diff changeset
105 }
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org