Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java @ 680:bcd62609c936
Write top 'Oberkante' and bottom 'Unterkante' to out going XML if they exist.
flys-artifacts/trunk@2109 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 14 Jun 2011 13:53:25 +0000 |
parents | 19a3185822a4 |
children | 757ff56b43b3 |
rev | line source |
---|---|
678
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 public class Calculation1 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 extends Calculation |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 private static Logger logger = Logger.getLogger(Calculation1.class); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 protected double [] kms; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 protected double [] qs; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 protected double [] ws; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 protected boolean up; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public Calculation1() { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public Calculation1( |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 double [] kms, |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 double [] qs, |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 double [] ws, |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 boolean up |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 ) { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 this.kms = kms; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 this.qs = qs; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 this.ws = ws; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 this.up = up; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 public WQKms [] calculate(WstValueTable wst) { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 ArrayList<WQKms> results = new ArrayList<WQKms>(); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 double ref = kms[up ? 0 : kms.length-1]; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 String prefix; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 double [] origData; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 if (ws != null) { prefix = "W="; origData = ws; } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 else { prefix = "Q="; origData = qs; } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 int oldNumProblems = numProblems(); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 for (int i = 0; i < qs.length; i++) { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 double [] oqs = new double[kms.length]; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 double [] ows = new double[kms.length]; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 boolean success = |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 wst.interpolate(qs[i], ref, kms, ows, oqs, this) != null; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 int newNumProblems = numProblems(); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 if (success) { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 WQKms result = new WQKms(kms, oqs, ows, prefix + origData[i]); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 if (oldNumProblems != newNumProblems) { |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 logger.debug( |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 qs[i] + " caused " + (newNumProblems-oldNumProblems) + |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 " new problem(s)."); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 result.removeNaNs(); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 results.add(result); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 oldNumProblems = newNumProblems; |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 return results.toArray(new WQKms[results.size()]); |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |