annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java @ 4869:d5f5bdaca316

DatacageWindow: Doc.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 28 Jan 2013 00:46:19 +0100
parents c79b98085096
children
rev   line source
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
8 import de.intevation.artifacts.Artifact;
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.common.utils.DateUtils;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.flys.model.BedHeightEpoch;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.model.BedHeightEpochValue;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.model.BedHeightSingle;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.model.BedHeightSingleValue;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.model.TimeInterval;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
17 import de.intevation.flys.artifacts.access.BedHeightAccess;
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 public class MiddleBedHeightCalculation extends Calculation {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 private static final Logger logger =
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 Logger.getLogger(MiddleBedHeightCalculation.class);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
26 public CalculationResult calculate(BedHeightAccess access) {
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 logger.info("MiddleBedHeightCalculation.calculate");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
29 int[] singleIds = access.getBedHeightSingleIDs();
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
30 int[] epochIds = access.getBedHeightEpochIDs();
3232
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
31
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 if (logger.isDebugEnabled()) {
3258
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
34 Artifact artifact = access.getArtifact();
3232
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
35
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 logger.debug("Artifact '" + artifact.identifier() + "' contains:");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 if (singleIds != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 logger.debug(" " + singleIds.length + " single bedheight ids");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 if (epochIds != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 logger.debug(" " + epochIds.length + " epoch bedheight ids");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
46 List<BedHeightSingle> singles = getSingles(access, singleIds);
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
47 List<BedHeightEpoch> epochs = getEpochs(access, epochIds);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
49 return buildCalculationResult(access, singles, epochs);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
53 protected List<BedHeightSingle> getSingles(
3258
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
54 BedHeightAccess access,
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
55 int[] ids
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
56 ) {
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 List<BedHeightSingle> singles = new ArrayList<BedHeightSingle>();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 for (int id: ids) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 if (s != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 singles.add(s);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 else {
3924
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
66 logger.warn("Cannot find Single by id: " + id);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 // TODO ADD WARNING
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 return singles;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
75 protected List<BedHeightEpoch> getEpochs(
3258
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
76 BedHeightAccess access,
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
77 int[] ids
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
78 ) {
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 List<BedHeightEpoch> epochs = new ArrayList<BedHeightEpoch>();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 for (int id: ids) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 BedHeightEpoch e = BedHeightEpoch.getBedHeightEpochById(id);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 if (e != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 epochs.add(e);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 else {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 logger.warn("Cannot find Epoch by id: " + id);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 // TODO ADD WARNING
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 return epochs;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 protected CalculationResult buildCalculationResult(
3931
c79b98085096 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3926
diff changeset
98 BedHeightAccess access,
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 List<BedHeightSingle> singles,
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 List<BedHeightEpoch> epochs
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 ) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 logger.info("MiddleBedHeightCalculation.buildCalculationResult");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
104 double kmLo = access.getLowerKM();
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
105 double kmHi = access.getUpperKM();
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 List<MiddleBedHeightData> data = new ArrayList<MiddleBedHeightData>();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 for (BedHeightSingle single: singles) {
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
110 MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 if (d != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 data.add(d);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 for (BedHeightEpoch epoch: epochs) {
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
118 MiddleBedHeightData d = prepareEpochData(epoch, kmLo, kmHi);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 if (d != null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 data.add(d);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 logger.debug("Calculation results in " + data.size() + " data objects.");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 return new CalculationResult((MiddleBedHeightData[])
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 data.toArray(new MiddleBedHeightData[data.size()]), this);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
132 protected MiddleBedHeightData prepareSingleData(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
133 BedHeightSingle single,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
134 double kmLo,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
135 double kmHi
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
136 ) {
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 logger.debug("Prepare data for single: " + single.getDescription());
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
139 List<BedHeightSingleValue> values =
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
140 BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 MiddleBedHeightData data = new MiddleBedHeightData(
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 single.getYear(),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 single.getYear(),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 single.getEvaluationBy(),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 single.getDescription());
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 for (BedHeightSingleValue value: values) {
3924
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
149 if (value.getHeight() != null) {
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
150 data.addAll(value.getStation().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
151 value.getHeight().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
152 value.getUncertainty().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
153 value.getSoundingWidth().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
154 value.getDataGap().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
155 value.getWidth().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
156 false);
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
157 }
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
158 else {
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
159 data.addAll(value.getStation().doubleValue(),
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
160 0,
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
161 0,
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
162 0,
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
163 0,
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
164 0,
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
165 true);
5fced192b95c Towards fix of issue863 (gaps in middle heigh bed data).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
166 }
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 logger.debug("Single contains " + values.size() + " values");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 return data;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174
3926
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
175 /** Create MiddleBedHeightData to return. */
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
176 protected MiddleBedHeightData prepareEpochData(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
177 BedHeightEpoch epoch,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
178 double kmLo,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
179 double kmHi
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
180 ) {
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 logger.debug("Prepare data for epoch: " + epoch.getDescription());
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 TimeInterval ti = epoch.getTimeInterval();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
185 List<BedHeightEpochValue> values =
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
186 BedHeightEpochValue.getBedHeightEpochValues(epoch, kmLo, kmHi);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 MiddleBedHeightData data = new MiddleBedHeightData(
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 DateUtils.getYearFromDate(ti.getStartTime()),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 DateUtils.getYearFromDate(ti.getStopTime()),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 epoch.getEvaluationBy(),
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 epoch.getDescription()
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 );
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 for (BedHeightEpochValue value: values) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 data.addKM(value.getStation().doubleValue());
3926
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
197 if (value.getHeight() != null) {
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
198 data.addMiddleHeight(value.getHeight().doubleValue());
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
199 data.addIsEmpty(false);
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
200 }
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
201 else {
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
202 data.addMiddleHeight(Double.NaN);
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
203 data.addIsEmpty(true);
e20307be4cc3 Fix issue863.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3924
diff changeset
204 }
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 logger.debug("Epoch contains " + values.size() + " values");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 return data;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org