annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java @ 4302:ce10b846bc86

ExtremeCompute: Generate LS-Facets.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 29 Oct 2012 13:46:39 +0100
parents 1f304cb5729b
children e7b923cf3a9c
rev   line source
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states.extreme;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import de.intevation.artifactdatabase.state.Facet;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.CallContext;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import de.intevation.flys.artifacts.FLYSArtifact;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import de.intevation.flys.artifacts.access.ExtremeAccess;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
11 import de.intevation.flys.artifacts.model.Calculation;
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.artifacts.model.CalculationResult;
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
13 import de.intevation.flys.artifacts.model.FacetTypes;
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.artifacts.model.ReportFacet;
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
15 import de.intevation.flys.artifacts.model.WaterlevelFacet;
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
16 import de.intevation.flys.artifacts.model.WQKms;
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.artifacts.model.extreme.ExtremeCalculation;
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
19 import de.intevation.flys.artifacts.model.extreme.ExtremeResult;
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.artifacts.states.DefaultState;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
23 import de.intevation.flys.utils.FLYSUtils;
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
24
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import java.util.List;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import org.apache.log4j.Logger;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
4043
eb5564662e19 Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3775
diff changeset
29 /** State in which to deliver extreme value analysis result. */
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 public class ExtremeCompute
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 extends DefaultState
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
32 implements FacetTypes
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 {
4043
eb5564662e19 Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3775
diff changeset
34 /** Private logger. */
4301
1f304cb5729b ExtremeCompute: Renamed log to logger.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4043
diff changeset
35 private static Logger logger = Logger.getLogger(ExtremeCompute.class);
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 public ExtremeCompute() {
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 @Override
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public Object computeAdvance(
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 FLYSArtifact artifact,
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 String hash,
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 CallContext context,
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 List<Facet> facets,
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 Object old
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 ) {
4301
1f304cb5729b ExtremeCompute: Renamed log to logger.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4043
diff changeset
48 logger.debug("ExtremeCompute.computeAdvance");
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 CalculationResult res;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 ExtremeAccess access = new ExtremeAccess(artifact);
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 if (old instanceof CalculationResult) {
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 res = (CalculationResult)old;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 else {
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 ExtremeCalculation calc = new ExtremeCalculation(access);
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 res = calc.calculate();
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 if (facets == null) {
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 return res;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 if (res.getReport().hasProblems()) {
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 facets.add(new ReportFacet());
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69
4302
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
70 ExtremeResult eres = (ExtremeResult) res.getData();
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
71 WQKms [] wqkms = (WQKms []) eres.getWQKms();
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
72
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
73 if (wqkms == null) {
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
74 logger.error("No computation result!");
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
75 }
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
76
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
77 for (int i = 0; i < wqkms.length; i++) {
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
78 String name = wqkms[i].getName();
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
79
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
80 // Ext.Calc has wqkmsName(i)
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
81 String nameW = "WW";//TODO: FLYSUtils.createWspWTitle(artifact, context, name);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
82 String nameQ = "QQ";//FLYSUtils.createWspQTitle(artifact, context, name);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
83
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
84 // Hotfix for theme names. Themes with the same name cause problems
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
85 // aggregating chart legend items.
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
86 if (i > 0 && name.equals(wqkms[i - 1].getName())) {
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
87 nameW += "; Q=" + wqkms[i].get(0, new double[3])[1];
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
88 nameQ += " = " + wqkms[i].get(0, new double[3])[1];
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
89 }
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
90
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
91 Facet w = new WaterlevelFacet(
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
92 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
93 Facet q = new WaterlevelFacet(
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
94 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
95
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
96 // TODO add more facets like:
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
97 // csv, data, pdf wst facet
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
98 // furthermore, waterlevel
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
99 //facets.add(new CrossSectionWaterLineFacet(i, nameW));
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
100
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
101 facets.add(w);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
102 facets.add(q);
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
103 }
ce10b846bc86 ExtremeCompute: Generate LS-Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4301
diff changeset
104
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 return res;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org