[Dive4elements-commits] [PATCH 1 of 2] FixWQCurveGenerator: issue1149, show calculated wq as points
Wald Commits
scm-commit at wald.intevation.org
Wed Apr 17 09:17:40 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1366181645 -7200
# Node ID 9950cbb7dba3d89d00a69d5116ab1fb4c9d31a88
# Parent 54077c9c93051de844fa78209a2898774237cf47
FixWQCurveGenerator: issue1149, show calculated wq as points.
diff -r 54077c9c9305 -r 9950cbb7dba3 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Tue Apr 16 18:55:52 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Wed Apr 17 08:54:05 2013 +0200
@@ -83,6 +83,8 @@
public static final String I18N_YAXIS_LABEL_DEFAULT =
"W [NN + m]";
+ public static final double EPSILON = 0.001d;
+
public static enum YAXIS {
W(0),
Q(1);
@@ -253,9 +255,13 @@
XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
Double ckm = (Double) context.getContextValue(CURRENT_KM);
WQKms wqkms = (WQKms) aaf.getData(context);
+ if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
+ logger.info("doEventsOut: No event data to show.");
+ return;
+ }
double[] kms = wqkms.getKms();
for (int i = 0 ; i< kms.length; i++) {
- if (Math.abs(kms[i] - ckm) <= 0.01d) {
+ if (Math.abs(kms[i] - ckm) <= EPSILON) {
series.add(wqkms.getQ(i), wqkms.getW(i));
addAxisSeries(series, YAXIS.W.idx, visible);
return;
@@ -453,12 +459,27 @@
) {
logger.debug("FixWQCurveGenerator: doWQOut");
if (wqkms instanceof WQKms) {
- WQKms data = (WQKms) wqkms;
+ // TODO As in doEventsOut, the value-searching should
+ // be delivered by the facet already (instead of in the Generator).
+ logger.debug("FixWQCurveGenerator: doWQOut: WQKms");
XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
- StyledSeriesBuilder.addPointsQW(series, data);
-
- addAxisSeries(series, YAXIS.W.idx, visible);
+ WQKms data = (WQKms) wqkms;
+ Double ckm = (Double) context.getContextValue(CURRENT_KM);
+ if (data == null || data.getKms().length == 0 || ckm == null) {
+ logger.info("doWQOut: No event data to show.");
+ return;
+ }
+ // Search for a close match.
+ double[] kms = data.getKms();
+ for (int i = 0 ; i< kms.length; i++) {
+ if (Math.abs(kms[i] - ckm) <= EPSILON) {
+ series.add(data.getQ(i), data.getW(i));
+ addAxisSeries(series, YAXIS.W.idx, visible);
+ return;
+ }
+ }
+ logger.info("doWQOut: No W/Q data for this km " + ckm);
}
else {
double [][] data = (double [][]) wqkms;
More information about the Dive4elements-commits
mailing list