annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 4802:7dd5baca4f53

W80Parser: Cosmetics, whitespace, TODO resolved, logging improved.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 16 Jan 2013 10:11:06 +0100
parents e3532c7850b9
children 65bfb6faa538
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
bfbd478bd607 FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3439
diff changeset
8 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
9
bfbd478bd607 FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3439
diff changeset
10 import de.intevation.flys.model.River;
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.utils.DoubleUtil;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
4798
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
14 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
15 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
16 import java.util.List;
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.Logger;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public class Calculation4
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
21 extends Calculation
655
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 private static Logger logger = Logger.getLogger(Calculation4.class);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 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
26
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 protected List<Segment> segments;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected boolean isQ;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public Calculation4() {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 public Calculation4(List<Segment> segments, River river, boolean isQ) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 this.segments = segments;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 this.isQ = isQ;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
3441
bfbd478bd607 FixA: Moved Q -> W conversion code into segments to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3439
diff changeset
39 Segment.setReferencePointConvertQ(segments, river, isQ, this);
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
42 public CalculationResult calculate(
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 WstValueTable table,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 double from, double to, double step
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 ) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 boolean debug = logger.isDebugEnabled();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 if (debug) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 logger.debug(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 "calculate from " + from + " to " + to + " step " + step);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 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
52 for (Segment segment: segments) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
53 logger.debug(" " + segment);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
54 }
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 if (segments.isEmpty()) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 logger.debug("no segments found");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
59 addProblem("no.segments.found");
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
60 return new CalculationResult(new WQKms[0], this);
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 int numResults = segments.get(0).values.length;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 if (numResults < 1) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 logger.debug("no values given");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
67 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
68 return new CalculationResult(new WQKms[0], this);
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 WQKms [] results = new WQKms[numResults];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 for (int i = 0; i < results.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 results[i] = new WQKms();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 if (Math.abs(step) < MINIMAL_STEP_WIDTH) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 step = MINIMAL_STEP_WIDTH;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 if (from > to) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 step = -step;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 QPosition [] qPositions = new QPosition[numResults];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 Function [] functions = new Function[numResults];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 double [] out = new double[2];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 Segment sentinel = new Segment(Double.MAX_VALUE);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 Segment s1 = sentinel, s2 = sentinel;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 for (double pos = from;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 from < to ? pos <= to : pos >= to;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 pos = DoubleUtil.round(pos + step)
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 ) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 if (pos < s1.referencePoint || pos > s2.referencePoint) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 if (debug) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 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
101 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 // find new interval
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 if (pos <= segments.get(0).referencePoint) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 // before first segment -> "gleichwertig"
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 if (debug) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 logger.debug("before first segment -> gleichwertig");
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 Segment first = segments.get(0);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 double [] values = first.values;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 double refPos = first.referencePoint;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 for (int i = 0; i < qPositions.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 qPositions[i] = table.getQPosition(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 refPos, values[i]);
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 sentinel.setReferencePoint(-Double.MAX_VALUE);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 s1 = sentinel;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 s2 = segments.get(0);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 Arrays.fill(functions, Identity.IDENTITY);
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 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
121 // after last segment -> "gleichwertig"
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 if (debug) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 logger.debug("after last segment -> gleichwertig");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 Segment last = segments.get(segments.size()-1);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 double [] values = last.values;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 double refPos = last.referencePoint;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 for (int i = 0; i < qPositions.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 qPositions[i] = table.getQPosition(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 refPos, values[i]);
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 sentinel.setReferencePoint(Double.MAX_VALUE);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 s1 = last;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 s2 = sentinel;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 Arrays.fill(functions, Identity.IDENTITY);
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 else { // "ungleichwertig"
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 // find matching interval
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 if (debug) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 logger.debug("in segments -> ungleichwertig");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 s1 = s2 = null;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 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
144 Segment si1 = segments.get(i-1);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 Segment si = segments.get(i);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 if (debug) {
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 739
diff changeset
147 logger.debug("check " + pos + " in " +
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 si1.referencePoint + " - " + si.referencePoint);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 }
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 739
diff changeset
150 if (pos >= si1.referencePoint
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 && pos <= si. referencePoint) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 s1 = si1;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 s2 = si;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 break;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 }
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 if (s1 == null) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 throw new IllegalStateException("no interval found");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 Segment anchor, free;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 if (from > to) { anchor = s1; free = s2; }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 else { anchor = s2; free = s1; }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 // build transforms based on "gleichwertiger" phase
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 for (int i = 0; i < qPositions.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 QPosition qi = table.getQPosition(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 anchor.referencePoint,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171 anchor.values[i]);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
172
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173 if ((qPositions[i] = qi) == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
174 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
175 functions[i] = Identity.IDENTITY;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 else {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 double qA = table.getQ(qi, anchor.referencePoint);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 double qF = table.getQ(qi, free .referencePoint);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 functions[i] = Double.isNaN(qA) || Double.isNaN(qF)
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 ? Identity.IDENTITY
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 : new Linear(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 qA, qF,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 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
186
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
187 if (debug) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
188 logger.debug(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 739
diff changeset
189 anchor.referencePoint + ": " +
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
190 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
191 " / " + free.referencePoint + ": " +
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
192 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
193 }
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 } // build transforms
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 } // "ungleichwertiges" interval
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 } // find matching interval
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 for (int i = 0; i < qPositions.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 QPosition qPosition = qPositions[i];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 if (qPosition == null) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 continue;
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
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 if (table.interpolate(pos, out, qPosition, functions[i])) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 results[i].add(out[0], out[1], pos);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 else {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
210 addProblem(pos, "cannot.interpolate.w.q");
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 // Backjump correction
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 for (int i = 0; i < results.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 BackJumpCorrector bjc = new BackJumpCorrector();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 double [] ws = results[i].getWs();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220 double [] kms = results[i].getKms();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
222 if (bjc.doCorrection(kms, ws, this)) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 results[i] = new WQCKms(results[i], bjc.getCorrected());
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 // name the curves
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 for (int i = 0; i < results.length; ++i) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229 results[i].setName(createName(i));
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231
4798
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
232 // 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
233 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
234
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
235 return new CalculationResult(results, this);
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237
4798
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
238 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
239 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
240 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
241 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
242 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
243 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
244 ) {
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
245 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
246
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
247 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
248 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
249
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
250 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
251
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
252 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
253 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
254 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
255 continue;
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
256 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
257 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
258 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
259 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
260 continue;
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
261 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
262 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
263 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
264 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
265 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
266 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
267
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
268 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
269 // 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
270 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
271 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
272 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
273 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
274 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
275
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
276 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
277 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
278 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
279 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
280 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
281 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
282 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
283 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
284 }
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
285
39885bdfc6fc Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3450
diff changeset
286 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
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
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289 protected String createName(int index) {
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3441
diff changeset
290 // TODO: i18n
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
291 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
292 sb.append(" benutzerdefiniert (");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293 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
294 if (i > 0) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
295 sb.append("; ");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
296 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
297 Segment segment = segments.get(i);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
298 sb.append((segment.backup != null
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
299 ? segment.backup
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
300 : segment.values)[index]);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
301 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
302 sb.append(')');
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
303 return sb.toString();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
304 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
305 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
306 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org