annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java @ 9556:9b8e8fc1f408

Use facetName in all processors as themeType for legend aggregation.
author gernotbelger
date Tue, 23 Oct 2018 16:26:58 +0200
parents 392745cccede
children aa6ee96071b7
rev   line source
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
2 * Software engineering by
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
5 *
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
9 */
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
10 package org.dive4elements.river.artifacts.sinfo.common;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
11
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
12 import java.util.Collection;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
13 import java.util.List;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
14
9170
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
9000
50cc99579a46 Work on uinfo
gernotbelger
parents: 8948
diff changeset
16 import org.dive4elements.river.artifacts.common.ResultRow;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
17 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
18 import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
19
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
20 import gnu.trove.TDoubleArrayList;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
21
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
22 /**
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
23 * @author Gernot Belger
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
24 */
9170
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
25
9195
a4121ec450d6 'ca.'-issue
gernotbelger
parents: 9170
diff changeset
26 public abstract class AbstractTkhCalculationResult extends AbstractCalculationExportableResult {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
27
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
28 private static final long serialVersionUID = 1L;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
29
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
30 private final boolean hasTkh;
9170
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
31 private final WstInfo wst;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
32
9000
50cc99579a46 Work on uinfo
gernotbelger
parents: 8948
diff changeset
33 public AbstractTkhCalculationResult(final String label, final WstInfo wst, final boolean hasTkh, final Collection<ResultRow> rows) {
9170
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
34 super(label, rows);
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
35 this.wst = wst;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
36 this.hasTkh = hasTkh;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
37 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
38
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
39 public final boolean hasTkh() {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
40 return this.hasTkh;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
41 }
9362
392745cccede Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents: 9195
diff changeset
42
392745cccede Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents: 9195
diff changeset
43 public boolean isShowRefGauges() {
392745cccede Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents: 9195
diff changeset
44 return this.wst.isShowRefGauges();
392745cccede Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents: 9195
diff changeset
45 }
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
46
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
47 public final double[][] getTkhUpPoints() {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
48
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
49 final double[][] points = getStationPoints(SInfoResultType.tkhup);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
50 final List<SoilKind> kinds = getValues(SInfoResultType.soilkind);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
51
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
52 final double[] xPoints = points[0];
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
53 final double[] yPoints = points[1];
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
54
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
55 return adjustTkhVisualization(xPoints, yPoints, kinds);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
56 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
57
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
58 public final double[][] getTkhDownPoints() {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
59
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
60 final double[][] points = getStationPoints(SInfoResultType.tkhdown);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
61 final List<SoilKind> kinds = getValues(SInfoResultType.soilkind);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
62
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
63 final double[] xPoints = points[0];
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
64 final double[] yPoints = points[1];
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
65
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
66 return adjustTkhVisualization(xPoints, yPoints, kinds);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
67 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
68
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
69 /**
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
70 * the up and down points must be further adjusted for visualization, see Mail Hr. Reiß
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
71 * basically we need to introduce extra points when the kind changes, so we get vertical lines in that case
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
72 */
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
73 private double[][] adjustTkhVisualization(final double[] xPoints, final double[] yPoints, final List<SoilKind> kinds) {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
74
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
75 final TDoubleArrayList adjustedX = new TDoubleArrayList(xPoints.length);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
76 final TDoubleArrayList adjustedY = new TDoubleArrayList(yPoints.length);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
77
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
78 adjustedX.add(xPoints[0]);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
79 adjustedY.add(yPoints[0]);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
80
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
81 for (int i = 1; i < xPoints.length; i++) {
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
82
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
83 final SoilKind kind1 = kinds.get(i - 1);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
84 final SoilKind kind2 = kinds.get(i);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
85
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
86 if (kind1 != kind2) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
87 /* introduce two extra points in order to create a vertical line in the middle of the two adjacent points */
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
88 final double x1 = xPoints[i - 1];
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
89 final double y1 = yPoints[i - 1];
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
90 final double x2 = xPoints[i];
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
91 final double y2 = yPoints[i];
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
92
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
93 final double middleX = (x1 + x2) / 2;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
94
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
95 // REMARK: we can't produce a 100% vertical line, as the area-renderer will not work correctly
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
96 adjustedX.add(middleX - 0.0001);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
97 adjustedY.add(y1);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
98
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
99 adjustedX.add(middleX + 0.0001);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
100 adjustedY.add(y2);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
101 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
102
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
103 /* always add the real point now */
8948
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
104 adjustedX.add(xPoints[i]);
a4f1ac81f26d Work on SINFO-FlowDepthMinMax.
gernotbelger
parents: 8946
diff changeset
105 adjustedY.add(yPoints[i]);
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
106 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
107
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
108 return new double[][] { adjustedX.toNativeArray(), adjustedY.toNativeArray() };
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
109 }
9170
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
110
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
111 public final WstInfo getWst() {
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
112 return this.wst; // TODO: Meta-Data export hier hin
9b2e46090099 tkh cast exception fix
gernotbelger
parents: 9000
diff changeset
113 }
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
diff changeset
114 }

http://dive4elements.wald.intevation.org