annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation5.java @ 2268:bad9a0313824

Added a second Y axis for ReferenceCurveGenerator.q flys-artifacts/trunk@3925 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 06 Feb 2012 13:59:28 +0000
parents 46918e6a831d
children 3973a2451cf7
rev   line source
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
2256
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
4 import java.util.Map;
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 public class Calculation5
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 extends Calculation
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 private static Logger log = Logger.getLogger(Calculation5.class);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 protected double startKm;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 protected double [] endKms;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public Calculation5() {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public Calculation5(double startKm, double [] endKms) {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 this.startKm = startKm;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 this.endKms = endKms;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
2256
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
25 public CalculationResult calculate(
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
26 WstValueTable wst,
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
27 Map<Double, Double> kms2gaugeDatums
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
28 ) {
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 ArrayList<WW> results = new ArrayList<WW>();
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 int numProblems = numProblems();
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 for (double endKm: endKms) {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 double [][] wws = wst.relateWs(startKm, endKm, this);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 int newNumProblems = numProblems();
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
2267
46918e6a831d Return the Qs from the "Bezugslinienverfahren, too."
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2256
diff changeset
38 if (wws.length == 4) {
46918e6a831d Return the Qs from the "Bezugslinienverfahren, too."
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2256
diff changeset
39 // TODO: Create WQWQ instead.
2201
4e3bfa2d9584 "Bezugslinienverfahren": Add start and end km to WW to determine if kms are at gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2192
diff changeset
40 WW ww = new WW(
4e3bfa2d9584 "Bezugslinienverfahren": Add start and end km to WW to determine if kms are at gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2192
diff changeset
41 generateName(startKm, endKm),
2256
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2201
diff changeset
42 startKm, kms2gaugeDatums.get(startKm), wws[0],
2267
46918e6a831d Return the Qs from the "Bezugslinienverfahren, too."
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2256
diff changeset
43 endKm, kms2gaugeDatums.get(endKm), wws[2]);
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
2192
922c672ec6c1 'Bezugslinienverfahren': Fixed stupid bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2186
diff changeset
45 if (newNumProblems > numProblems) {
2186
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 ww.removeNaNs();
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 results.add(ww);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 numProblems = newNumProblems;
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 return new CalculationResult(
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 results.toArray(new WW[results.size()]),
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 this);
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 protected static String generateName(double startKm, double endKm) {
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 // TODO: I18N
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 return "W(km " + startKm + ") ~ W(km " + endKm + ")";
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 }
ec2574eb2d32 Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org