comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java @ 5739:9950cbb7dba3

FixWQCurveGenerator: issue1149, show calculated wq as points.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 08:54:05 +0200
parents 0152d639d7a7
children 0516c1f8f674
comparison
equal deleted inserted replaced
5738:54077c9c9305 5739:9950cbb7dba3
81 "Q [m\u00B3/s]"; 81 "Q [m\u00B3/s]";
82 82
83 public static final String I18N_YAXIS_LABEL_DEFAULT = 83 public static final String I18N_YAXIS_LABEL_DEFAULT =
84 "W [NN + m]"; 84 "W [NN + m]";
85 85
86 public static final double EPSILON = 0.001d;
87
86 public static enum YAXIS { 88 public static enum YAXIS {
87 W(0), 89 W(0),
88 Q(1); 90 Q(1);
89 public int idx; 91 public int idx;
90 private YAXIS(int c) { 92 private YAXIS(int c) {
251 logger.debug("doEventsOut"); 253 logger.debug("doEventsOut");
252 // Find W/Q at km. 254 // Find W/Q at km.
253 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); 255 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
254 Double ckm = (Double) context.getContextValue(CURRENT_KM); 256 Double ckm = (Double) context.getContextValue(CURRENT_KM);
255 WQKms wqkms = (WQKms) aaf.getData(context); 257 WQKms wqkms = (WQKms) aaf.getData(context);
258 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
259 logger.info("doEventsOut: No event data to show.");
260 return;
261 }
256 double[] kms = wqkms.getKms(); 262 double[] kms = wqkms.getKms();
257 for (int i = 0 ; i< kms.length; i++) { 263 for (int i = 0 ; i< kms.length; i++) {
258 if (Math.abs(kms[i] - ckm) <= 0.01d) { 264 if (Math.abs(kms[i] - ckm) <= EPSILON) {
259 series.add(wqkms.getQ(i), wqkms.getW(i)); 265 series.add(wqkms.getQ(i), wqkms.getW(i));
260 addAxisSeries(series, YAXIS.W.idx, visible); 266 addAxisSeries(series, YAXIS.W.idx, visible);
261 return; 267 return;
262 } 268 }
263 } 269 }
451 Document theme, 457 Document theme,
452 boolean visible 458 boolean visible
453 ) { 459 ) {
454 logger.debug("FixWQCurveGenerator: doWQOut"); 460 logger.debug("FixWQCurveGenerator: doWQOut");
455 if (wqkms instanceof WQKms) { 461 if (wqkms instanceof WQKms) {
462 // TODO As in doEventsOut, the value-searching should
463 // be delivered by the facet already (instead of in the Generator).
464 logger.debug("FixWQCurveGenerator: doWQOut: WQKms");
465
466 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
456 WQKms data = (WQKms) wqkms; 467 WQKms data = (WQKms) wqkms;
457 468 Double ckm = (Double) context.getContextValue(CURRENT_KM);
458 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); 469 if (data == null || data.getKms().length == 0 || ckm == null) {
459 StyledSeriesBuilder.addPointsQW(series, data); 470 logger.info("doWQOut: No event data to show.");
460 471 return;
461 addAxisSeries(series, YAXIS.W.idx, visible); 472 }
473 // Search for a close match.
474 double[] kms = data.getKms();
475 for (int i = 0 ; i< kms.length; i++) {
476 if (Math.abs(kms[i] - ckm) <= EPSILON) {
477 series.add(data.getQ(i), data.getW(i));
478 addAxisSeries(series, YAXIS.W.idx, visible);
479 return;
480 }
481 }
482 logger.info("doWQOut: No W/Q data for this km " + ckm);
462 } 483 }
463 else { 484 else {
464 double [][] data = (double [][]) wqkms; 485 double [][] data = (double [][]) wqkms;
465 486
466 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); 487 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);

http://dive4elements.wald.intevation.org