Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | c09c9e05ecfa |
children |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.ArrayList; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 public class Calculation1 | |
8 extends Calculation | |
9 { | |
10 private static Logger logger = Logger.getLogger(Calculation1.class); | |
11 | |
12 protected double [] kms; | |
13 protected double [] qs; | |
14 protected double [] ws; | |
15 protected double refKm; | |
16 | |
17 public Calculation1() { | |
18 } | |
19 | |
20 public Calculation1( | |
21 double [] kms, | |
22 double [] qs, | |
23 double [] ws, | |
24 double refKm | |
25 ) { | |
26 this.kms = kms; | |
27 this.qs = qs; | |
28 this.ws = ws; | |
29 this.refKm = refKm; | |
30 } | |
31 | |
32 public CalculationResult calculate(WstValueTable wst) { | |
33 | |
34 ArrayList<WQKms> results = new ArrayList<WQKms>(); | |
35 | |
36 String prefix; | |
37 double [] origData; | |
38 | |
39 if (ws != null) { prefix = "W="; origData = ws; } | |
40 else { prefix = "Q="; origData = qs; } | |
41 | |
42 int oldNumProblems = numProblems(); | |
43 | |
44 for (int i = 0; i < qs.length; i++) { | |
45 | |
46 double [] oqs = new double[kms.length]; | |
47 double [] ows = new double[kms.length]; | |
48 | |
49 boolean success = | |
50 wst.interpolate(qs[i], refKm, kms, ows, oqs, this) != null; | |
51 | |
52 int newNumProblems = numProblems(); | |
53 | |
54 if (success) { | |
55 WQKms result = new WQKms(kms, oqs, ows, prefix + origData[i]); | |
56 if (oldNumProblems != newNumProblems) { | |
57 logger.debug( | |
58 qs[i] + " caused " + (newNumProblems-oldNumProblems) + | |
59 " new problem(s)."); | |
60 result.removeNaNs(); | |
61 } | |
62 results.add(result); | |
63 } | |
64 | |
65 oldNumProblems = newNumProblems; | |
66 } | |
67 | |
68 return new CalculationResult( | |
69 results.toArray(new WQKms[results.size()]), | |
70 this); | |
71 } | |
72 } | |
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |