Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 4837:9e25c7523485
Fixed calculation of effective width in MINFO SQ relation.
* Get all (including empty datasets) from db.
* Filter empty datasets when processing data of the same date.
* Added debug outputs.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 11:14:41 +0100 |
parents | 65bfb6faa538 |
children | bcf25d8c183e |
rev | line source |
---|---|
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3441
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
3 import de.intevation.flys.artifacts.math.BackJumpCorrector; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
4 import de.intevation.flys.artifacts.math.Function; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
5 import de.intevation.flys.artifacts.math.Identity; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
6 import de.intevation.flys.artifacts.math.Linear; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
7 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
8 import de.intevation.flys.artifacts.model.RiverFactory; |
3441
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
9 import de.intevation.flys.artifacts.model.WstValueTable.QPosition; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
10 |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
11 import de.intevation.flys.model.River; |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.utils.DoubleUtil; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
15 import de.intevation.flys.artifacts.access.Calculation4Access; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
16 |
4798
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
17 import java.util.ArrayList; |
3441
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
18 import java.util.Arrays; |
bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3439
diff
changeset
|
19 import java.util.List; |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import org.apache.log4j.Logger; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 public class Calculation4 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
24 extends Calculation |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 private static Logger logger = Logger.getLogger(Calculation4.class); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public static final double MINIMAL_STEP_WIDTH = 1e-5; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 protected List<Segment> segments; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
32 protected boolean isQ; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
33 protected double from; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
34 protected double to; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
35 protected double step; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
36 protected String river; |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 public Calculation4() { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
41 public Calculation4(Calculation4Access access) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
42 String river = access.getRiver(); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
43 List<Segment> segments = access.getSegments(); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
44 double [] range = access.getFromToStep(); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
45 boolean isQ = access.isQ(); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
47 if (river == null) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
48 addProblem("no.river.selected"); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
49 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
51 if (range == null) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
52 addProblem("no.range.found"); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
53 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
54 |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
55 if (segments == null || segments.isEmpty()) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
56 addProblem("cannot.create.segments"); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
57 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
58 |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
59 if (!hasProblems()) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
60 this.river = river; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
61 this.segments = segments; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
62 this.from = range[0]; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
63 this.to = range[1]; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
64 this.step = range[2]; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
65 this.isQ = isQ; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
66 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
4812
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
69 public CalculationResult calculate() { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
70 if (hasProblems()) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
71 return new CalculationResult(new WQKms[0], this); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
72 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
73 |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
74 WstValueTable table = null; |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
75 River r = RiverFactory.getRiver(river); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
76 if (r == null) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
77 addProblem("no.river.found"); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
78 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
79 else { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
80 table = WstValueTableFactory.getTable(r); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
81 if (table == null) { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
82 addProblem("no.wst.for.river"); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
83 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
84 else { |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
85 Segment.setReferencePointConvertQ(segments, r, isQ, this); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
86 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
87 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
88 |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
89 return hasProblems() |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
90 ? new CalculationResult(new WQKms[0], this) |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
91 : innerCalculate(table); |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
92 } |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
93 |
65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4799
diff
changeset
|
94 protected CalculationResult innerCalculate(WstValueTable table) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 boolean debug = logger.isDebugEnabled(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 if (debug) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 logger.debug( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 "calculate from " + from + " to " + to + " step " + step); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 logger.debug("# segments: " + segments.size()); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
101 for (Segment segment: segments) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
102 logger.debug(" " + segment); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
103 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 int numResults = segments.get(0).values.length; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 if (numResults < 1) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 logger.debug("no values given"); |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
110 addProblem("no.values.given"); |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
111 return new CalculationResult(new WQKms[0], this); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 WQKms [] results = new WQKms[numResults]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 for (int i = 0; i < results.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 results[i] = new WQKms(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 if (Math.abs(step) < MINIMAL_STEP_WIDTH) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 step = MINIMAL_STEP_WIDTH; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 if (from > to) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 step = -step; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 QPosition [] qPositions = new QPosition[numResults]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 Function [] functions = new Function[numResults]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 double [] out = new double[2]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 Segment sentinel = new Segment(Double.MAX_VALUE); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 Segment s1 = sentinel, s2 = sentinel; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 for (double pos = from; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 from < to ? pos <= to : pos >= to; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 pos = DoubleUtil.round(pos + step) |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 ) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 if (pos < s1.referencePoint || pos > s2.referencePoint) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 if (debug) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 logger.debug("need to find new interval for " + pos); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 // find new interval |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 if (pos <= segments.get(0).referencePoint) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 // before first segment -> "gleichwertig" |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 if (debug) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 logger.debug("before first segment -> gleichwertig"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 Segment first = segments.get(0); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 double [] values = first.values; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 double refPos = first.referencePoint; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 for (int i = 0; i < qPositions.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 qPositions[i] = table.getQPosition( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 refPos, values[i]); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 sentinel.setReferencePoint(-Double.MAX_VALUE); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 s1 = sentinel; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 s2 = segments.get(0); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 Arrays.fill(functions, Identity.IDENTITY); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 else if (pos >= segments.get(segments.size()-1).referencePoint) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 // after last segment -> "gleichwertig" |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 if (debug) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 logger.debug("after last segment -> gleichwertig"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 Segment last = segments.get(segments.size()-1); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 double [] values = last.values; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 double refPos = last.referencePoint; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 for (int i = 0; i < qPositions.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 qPositions[i] = table.getQPosition( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 refPos, values[i]); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 sentinel.setReferencePoint(Double.MAX_VALUE); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 s1 = last; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 s2 = sentinel; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 Arrays.fill(functions, Identity.IDENTITY); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 else { // "ungleichwertig" |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 // find matching interval |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 if (debug) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 logger.debug("in segments -> ungleichwertig"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 s1 = s2 = null; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 for (int i = 1, N = segments.size(); i < N; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 Segment si1 = segments.get(i-1); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 Segment si = segments.get(i); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 if (debug) { |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
739
diff
changeset
|
190 logger.debug("check " + pos + " in " + |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 si1.referencePoint + " - " + si.referencePoint); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 } |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
739
diff
changeset
|
193 if (pos >= si1.referencePoint |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 && pos <= si. referencePoint) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 s1 = si1; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 s2 = si; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 break; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 if (s1 == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 throw new IllegalStateException("no interval found"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 Segment anchor, free; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 if (from > to) { anchor = s1; free = s2; } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 else { anchor = s2; free = s1; } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 // build transforms based on "gleichwertiger" phase |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 for (int i = 0; i < qPositions.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 QPosition qi = table.getQPosition( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 anchor.referencePoint, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 anchor.values[i]); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 if ((qPositions[i] = qi) == null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
217 addProblem(pos, "cannot.find.q", anchor.values[i]); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 functions[i] = Identity.IDENTITY; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 else { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 double qA = table.getQ(qi, anchor.referencePoint); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 double qF = table.getQ(qi, free .referencePoint); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 functions[i] = Double.isNaN(qA) || Double.isNaN(qF) |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 ? Identity.IDENTITY |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 : new Linear( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 qA, qF, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 anchor.values[i], free.values[i]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
229 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
230 if (debug) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
231 logger.debug( |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
739
diff
changeset
|
232 anchor.referencePoint + ": " + |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
233 qA + " -> " + functions[i].value(qA) + |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
234 " / " + free.referencePoint + ": " + |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
235 qF + " -> " + functions[i].value(qF)); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
236 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 } // build transforms |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 } // "ungleichwertiges" interval |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 } // find matching interval |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 for (int i = 0; i < qPositions.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 QPosition qPosition = qPositions[i]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 if (qPosition == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 continue; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 if (table.interpolate(pos, out, qPosition, functions[i])) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 results[i].add(out[0], out[1], pos); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 else { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
253 addProblem(pos, "cannot.interpolate.w.q"); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 // Backjump correction |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 for (int i = 0; i < results.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 BackJumpCorrector bjc = new BackJumpCorrector(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 double [] ws = results[i].getWs(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 double [] kms = results[i].getKms(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
656
diff
changeset
|
265 if (bjc.doCorrection(kms, ws, this)) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 results[i] = new WQCKms(results[i], bjc.getCorrected()); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
268 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
269 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 // name the curves |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
271 for (int i = 0; i < results.length; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
272 results[i].setName(createName(i)); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
274 |
4798
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
275 // Generate the "Umhuellende". |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
276 results = generateInfolding(table, results, from, to, step); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
277 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
278 return new CalculationResult(results, this); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
279 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
280 |
4798
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
281 protected WQKms [] generateInfolding( |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
282 WstValueTable wst, |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
283 WQKms [] results, |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
284 double from, |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
285 double to, |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
286 double step |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
287 ) { |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
288 WstValueTable.Column [] columns = wst.getColumns(); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
289 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
290 InfoldingColumns ic = new InfoldingColumns(columns); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
291 ic.markInfoldingColumns(results); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
292 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
293 List<WQKms> infoldings = new ArrayList<WQKms>(); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
294 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
295 boolean [] infoldingColumns = ic.getInfoldingColumns(); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
296 for (int i = 0; i < infoldingColumns.length; ++i) { |
4799
e3532c7850b9
Trivial typo in selecting infolding columns.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4798
diff
changeset
|
297 if (!infoldingColumns[i]) { |
4798
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
298 continue; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
299 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
300 double q = columns[i].getQRangeTree().findQ(from); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
301 if (Double.isNaN(q)) { |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
302 addProblem(from, "cannot.find.q"); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
303 continue; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
304 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
305 double [] kms = DoubleUtil.explode(from, to, step); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
306 double [] oqs = new double[kms.length]; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
307 double [] ows = new double[kms.length]; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
308 boolean success = |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
309 wst.interpolate(q, from, kms, ows, oqs, this) != null; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
310 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
311 if (success) { |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
312 // TODO: generate a better name. I18N. |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
313 String name = "Umh\u00fcllende " + columns[i].getName(); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
314 WQKms wqkms = new WQKms(kms, oqs, ows, name); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
315 infoldings.add(wqkms); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
316 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
317 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
318 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
319 int N = infoldings.size(); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
320 if (N > 0) { |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
321 WQKms [] newResults = new WQKms[results.length + N]; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
322 System.arraycopy(results, 0, newResults, 0, results.length); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
323 for (int i = 0; i < N; ++i) { |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
324 newResults[i+results.length] = infoldings.get(i); |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
325 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
326 results = newResults; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
327 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
328 |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
329 return results; |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
330 } |
39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3450
diff
changeset
|
331 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
332 protected String createName(int index) { |
3450
22790758b132
FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3441
diff
changeset
|
333 // TODO: i18n |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
334 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 sb.append(" benutzerdefiniert ("); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
336 for (int i = 0, N = segments.size(); i < N; ++i) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
337 if (i > 0) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
338 sb.append("; "); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
339 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 Segment segment = segments.get(i); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 sb.append((segment.backup != null |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
342 ? segment.backup |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
343 : segment.values)[index]); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
345 sb.append(')'); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
346 return sb.toString(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
348 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
349 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |