Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java @ 9585:aa6ee96071b7
Punkt 6.2.1 Sprünge auf vollen HM
author | gernotbelger |
---|---|
date | Wed, 09 Jan 2019 18:07:51 +0100 |
parents | 392745cccede |
children | 1d4262a68f1f |
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 | |
9585 | 15 import org.apache.commons.collections.PredicateUtils; |
9170 | 16 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
9000 | 17 import org.dive4elements.river.artifacts.common.ResultRow; |
8946 | 18 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind; |
19 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
20 | |
21 import gnu.trove.TDoubleArrayList; | |
22 | |
23 /** | |
24 * @author Gernot Belger | |
25 */ | |
9170 | 26 |
9195 | 27 public abstract class AbstractTkhCalculationResult extends AbstractCalculationExportableResult { |
8946 | 28 |
29 private static final long serialVersionUID = 1L; | |
30 | |
31 private final boolean hasTkh; | |
9170 | 32 private final WstInfo wst; |
8946 | 33 |
9000 | 34 public AbstractTkhCalculationResult(final String label, final WstInfo wst, final boolean hasTkh, final Collection<ResultRow> rows) { |
9170 | 35 super(label, rows); |
36 this.wst = wst; | |
8946 | 37 this.hasTkh = hasTkh; |
38 } | |
39 | |
40 public final boolean hasTkh() { | |
41 return this.hasTkh; | |
42 } | |
9585 | 43 |
9362
392745cccede
Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents:
9195
diff
changeset
|
44 public boolean isShowRefGauges() { |
392745cccede
Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents:
9195
diff
changeset
|
45 return this.wst.isShowRefGauges(); |
392745cccede
Fixed: waterlevels from database should not get the "Bezugspegel" column in the result output.
gernotbelger
parents:
9195
diff
changeset
|
46 } |
8946 | 47 |
48 public final double[][] getTkhUpPoints() { | |
49 | |
8948 | 50 final double[][] points = getStationPoints(SInfoResultType.tkhup); |
9585 | 51 final List<SoilKind> kinds = getValues(SInfoResultType.soilkind, PredicateUtils.truePredicate()); |
8946 | 52 |
8948 | 53 final double[] xPoints = points[0]; |
54 final double[] yPoints = points[1]; | |
8946 | 55 |
56 return adjustTkhVisualization(xPoints, yPoints, kinds); | |
57 } | |
58 | |
59 public final double[][] getTkhDownPoints() { | |
60 | |
8948 | 61 final double[][] points = getStationPoints(SInfoResultType.tkhdown); |
9585 | 62 final List<SoilKind> kinds = getValues(SInfoResultType.soilkind, PredicateUtils.truePredicate()); |
8946 | 63 |
8948 | 64 final double[] xPoints = points[0]; |
65 final double[] yPoints = points[1]; | |
8946 | 66 |
67 return adjustTkhVisualization(xPoints, yPoints, kinds); | |
68 } | |
69 | |
70 /** | |
71 * the up and down points must be further adjusted for visualization, see Mail Hr. Reiß | |
72 * basically we need to introduce extra points when the kind changes, so we get vertical lines in that case | |
73 */ | |
8948 | 74 private double[][] adjustTkhVisualization(final double[] xPoints, final double[] yPoints, final List<SoilKind> kinds) { |
8946 | 75 |
8948 | 76 final TDoubleArrayList adjustedX = new TDoubleArrayList(xPoints.length); |
77 final TDoubleArrayList adjustedY = new TDoubleArrayList(yPoints.length); | |
8946 | 78 |
8948 | 79 adjustedX.add(xPoints[0]); |
80 adjustedY.add(yPoints[0]); | |
8946 | 81 |
8948 | 82 for (int i = 1; i < xPoints.length; i++) { |
8946 | 83 |
84 final SoilKind kind1 = kinds.get(i - 1); | |
85 final SoilKind kind2 = kinds.get(i); | |
86 | |
87 if (kind1 != kind2) { | |
88 /* introduce two extra points in order to create a vertical line in the middle of the two adjacent points */ | |
8948 | 89 final double x1 = xPoints[i - 1]; |
90 final double y1 = yPoints[i - 1]; | |
91 final double x2 = xPoints[i]; | |
92 final double y2 = yPoints[i]; | |
8946 | 93 |
94 final double middleX = (x1 + x2) / 2; | |
95 | |
96 // REMARK: we can't produce a 100% vertical line, as the area-renderer will not work correctly | |
97 adjustedX.add(middleX - 0.0001); | |
98 adjustedY.add(y1); | |
99 | |
100 adjustedX.add(middleX + 0.0001); | |
101 adjustedY.add(y2); | |
102 } | |
103 | |
104 /* always add the real point now */ | |
8948 | 105 adjustedX.add(xPoints[i]); |
106 adjustedY.add(yPoints[i]); | |
8946 | 107 } |
108 | |
109 return new double[][] { adjustedX.toNativeArray(), adjustedY.toNativeArray() }; | |
110 } | |
9170 | 111 |
112 public final WstInfo getWst() { | |
113 return this.wst; // TODO: Meta-Data export hier hin | |
114 } | |
8946 | 115 } |