Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/math/BackJumpCorrector.java @ 7051:c4bacc5ddd9b generator-refactoring
Parse config when setup a new diagram.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 19 Sep 2013 11:39:00 +0200 |
parents | af13ceeba52a |
children | 0a5239a1e46e |
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 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
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 |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
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:
3076
diff
changeset
|
9 package org.dive4elements.river.artifacts.math; |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.io.Serializable; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.apache.commons.math.ArgumentOutsideDomainException; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
22 import org.apache.commons.math.exception.MathIllegalArgumentException; |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
23 |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import org.apache.log4j.Logger; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3076
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.Calculation; |
674
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
27 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3076
diff
changeset
|
28 import org.dive4elements.river.utils.DoubleUtil; |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
29 |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 public class BackJumpCorrector |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 implements Serializable |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 private static Logger log = Logger.getLogger(BackJumpCorrector.class); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 protected ArrayList<Double> backjumps; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 protected double [] corrected; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 public BackJumpCorrector() { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 backjumps = new ArrayList<Double>(); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public boolean hasBackJumps() { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 return !backjumps.isEmpty(); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 public List<Double> getBackJumps() { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 return backjumps; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 public double [] getCorrected() { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 return corrected; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
674
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
55 public boolean doCorrection( |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
56 double [] km, |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
57 double [] ws, |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
58 Calculation errors |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
59 ) { |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
60 boolean wsUp = DoubleUtil.isIncreasing(ws); |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
61 |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
62 if (wsUp) { |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
63 km = DoubleUtil.swapClone(km); |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
64 ws = DoubleUtil.swapClone(ws); |
406
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
65 } |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
66 |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
67 boolean kmUp = DoubleUtil.isIncreasing(km); |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
68 |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
69 if (!kmUp) { |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
70 km = DoubleUtil.sumDiffs(km); |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
71 } |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
72 |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
73 if (log.isDebugEnabled()) { |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
74 log.debug("BackJumpCorrector.doCorrection ------- enter"); |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
75 log.debug(" km increasing: " + DoubleUtil.isIncreasing(km)); |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
76 log.debug(" ws increasing: " + DoubleUtil.isIncreasing(ws)); |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
77 log.debug("BackJumpCorrector.doCorrection ------- leave"); |
406
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
78 } |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
79 |
674
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
80 boolean hasBackJumps = doCorrectionClean(km, ws, errors); |
406
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
81 |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
82 if (hasBackJumps && wsUp) { |
406
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
83 // mirror back |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
84 DoubleUtil.swap(corrected); |
406
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
85 } |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
86 |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
87 return hasBackJumps; |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
88 } |
663aa18bee7f
Back jump correction should work now for both flow directions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
343
diff
changeset
|
89 |
674
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
90 protected boolean doCorrectionClean( |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
91 double [] km, |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
92 double [] ws, |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
93 Calculation errors |
d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
662
diff
changeset
|
94 ) { |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 int N = km.length; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 if (N != ws.length) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 throw new IllegalArgumentException("km.length != ws.length"); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 if (N < 2) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 return false; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 SplineInterpolator interpolator = null; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 for (int i = 1; i < N; ++i) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 if (ws[i] <= ws[i-1]) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 // no back jump |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 continue; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 backjumps.add(km[i]); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 if (corrected == null) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 // lazy cloning |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 ws = corrected = (double [])ws.clone(); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
119 double above = aboveWaterKM(km, ws, i); |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
121 if (Double.isNaN(above)) { // run over start km |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
122 // fill all previous |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 for (int j = 0; j < i; ++j) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 ws[j] = ws[i]; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 continue; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
129 double distance = Math.abs(km[i] - above); |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
130 |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 double quarterDistance = 0.25*distance; |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
133 double start = above - quarterDistance; |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
135 double startHeight = DoubleUtil.interpolateSorted(km, ws, start); |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
136 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
137 if (Double.isNaN(startHeight)) { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
138 // run over start km |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
139 startHeight = ws[0]; |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
142 double between = above + quarterDistance; |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 |
1676
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
144 double aboveHeight = ws[i] + 0.25*(startHeight - ws[i]); |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 |
1676
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
146 double [] x = { start, above, between }; |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
147 double [] y = { startHeight, aboveHeight, ws[i] }; |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
149 if (log.isDebugEnabled()) { |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
150 for (int j = 0; j < x.length; ++j) { |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
151 log.debug(" " + x[j] + " -> " + y[j]); |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
152 } |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
153 } |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
406
diff
changeset
|
154 |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
155 if (interpolator == null) { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
156 interpolator = new SplineInterpolator(); |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
157 } |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
158 |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
159 PolynomialSplineFunction spline; |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
160 |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
161 try { |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
162 spline = interpolator.interpolate(x, y); |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
163 } |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
164 catch (MathIllegalArgumentException miae) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1676
diff
changeset
|
165 errors.addProblem("spline.creation.failed"); |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
166 log.error(miae); |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
167 continue; |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
168 } |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 try { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 if (log.isDebugEnabled()) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 log.debug("spline points:"); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 for (int j = 0; j < x.length; ++j) { |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 log.debug(x[j] + " " + y[j] + " " + spline.value(x[j])); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 |
1676
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
178 int j = i-1; |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
179 |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
180 for (; j >= 0 && km[j] >= between; --j) { |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
181 ws[j] = ws[i]; |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
182 } |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
183 |
6e840e213fdf
Backjump correction: Finally looks fine.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1674
diff
changeset
|
184 for (; j >= 0 && ws[j] < startHeight; --j) { |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
185 ws[j] = spline.value(km[j]); |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 catch (ArgumentOutsideDomainException aode) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1676
diff
changeset
|
189 errors.addProblem("spline.interpolation.failed"); |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 log.error("spline interpolation failed", aode); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 } // for all km |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 return !backjumps.isEmpty(); |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 } |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
196 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
197 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
198 protected static double aboveWaterKM( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
199 double [] km, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
200 double [] ws, |
1674
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
201 int wIndex |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
202 ) { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
203 double w = ws[wIndex]; |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
204 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
205 while (--wIndex >= 0) { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
206 // still under water |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
207 if (ws[wIndex] < w) continue; |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
208 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
209 if (ws[wIndex] > w) { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
210 // f(ws[wIndex]) = km[wIndex] |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
211 // f(ws[wIndex+1]) = km[wIndex+1] |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
212 return Linear.linear( |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
213 w, |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
214 ws[wIndex], ws[wIndex+1], |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
215 km[wIndex], km[wIndex+1]); |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
216 } |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
217 else { |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
218 return km[wIndex]; |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
219 } |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
220 } |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
221 |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
222 return Double.NaN; |
b5209452f6bb
flys/issue31: Simplified the back jump correction code a lot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
223 } |
343
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 } |
f165c7d5d6db
Implementation of the "Ruecksprungkorrektur" to be done in "W fuer angepassten Abflusslaengschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |