[PATCH] "Kein Bezugspegel" AWSPL PDF-Export-Fix

Wald Commits scm-commit at wald.intevation.org
Wed Oct 17 13:57:38 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1539777454 -7200
# Node ID fb80fc7ec610ca2108de15b2dd691d9ce0333948
# Parent  bf6b63208f340aefd5adb299e54ff088e6118dc8
"Kein Bezugspegel" AWSPL PDF-Export-Fix

diff -r bf6b63208f34 -r fb80fc7ec610 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Wed Oct 17 11:23:17 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Wed Oct 17 13:57:34 2018 +0200
@@ -437,7 +437,9 @@
         final double[] kms = rangeAccess.getKmRange();
         writer.writeNext(new String[] { Resources.getMsg(meta, CSV_META_RANGE, CSV_META_RANGE, new Object[] { kms[0], kms[kms.length - 1] }) });
 
-        writer.writeNext(new String[] { Resources.getMsg(meta, CSV_META_GAUGE, CSV_META_GAUGE, new Object[] { RiverUtils.getGaugename(flys) }) });
+        final String gaugeName = RiverUtils.getGaugename(flys);
+        writer.writeNext(new String[] {
+                Resources.getMsg(meta, CSV_META_GAUGE, CSV_META_GAUGE, new Object[] { gaugeName != null ? gaugeName : Resources.getMsg(meta, "-") }) });
 
         // TODO: code extracted into WaterlevelDescriptionBuilder, should be used instead.
         final RiverUtils.WQ_MODE wq = RiverUtils.getWQMode(flys);
@@ -876,12 +878,12 @@
 
         final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
 
-        final String gaugeName = gauge.getName();
+        final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
+        final String gaugeName = gauge != null ? gauge.getName() : notinrange;
         String desc = "";
-        final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
 
-        final double a = gauge.getRange().getA().doubleValue();
-        final double b = gauge.getRange().getB().doubleValue();
+        final Double a = gauge != null ? gauge.getRange().getA().doubleValue() : Double.NaN;
+        final Double b = gauge != null ? gauge.getRange().getB().doubleValue() : Double.NaN;
         final WaterlevelDescriptionBuilder wldb = new WaterlevelDescriptionBuilder(flys, this.context);
 
         desc = wldb.getDesc(wqkms);// class getDesc(wqkms, isQ);
@@ -1077,8 +1079,8 @@
 
     private Double getWforGaugeAndQ(final Gauge gauge, final double q) {
 
-        final String key = gauge.getName() + String.valueOf(q);
-        if (!this.gaugeQ_W_Map.containsKey(key)) {
+        final String key = gauge != null ? gauge.getName() + String.valueOf(q) : null;
+        if (!this.gaugeQ_W_Map.containsKey(key) && key != null) {
 
             final DischargeTable dt = gauge.fetchMasterDischargeTable();
             final double[][] table = DischargeTables.loadDischargeTableValues(dt);


More information about the Dive4Elements-commits mailing list