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