changeset 9081:a0feac6ea1ba

Fixed d50 query, added log.trace
author mschaefer
date Fri, 25 May 2018 09:10:19 +0200
parents 89c1bb914f4e
children 42c15e2f95fb
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java	Fri May 25 07:59:38 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java	Fri May 25 09:10:19 2018 +0200
@@ -57,7 +57,7 @@
      * query.
      */
     private static final String SQL_BED_D50_SUBLAYER_MEASUREMENT = //
-            "SELECT t.km, t.datum, p.tiefevon, p.tiefebis, a.d50" //
+            "SELECT s.km, t.datum, p.tiefevon, p.tiefebis, a.d50" //
             + " FROM sohltest t INNER JOIN station s ON t.stationid = s.stationid" //
             + "    INNER JOIN gewaesser g ON s.gewaesserid = g.gewaesserid" //
             + "    INNER JOIN sohlprobe p ON t.sohltestid = p.sohltestid" //
@@ -121,15 +121,19 @@
         final TDoubleArrayList kmd50s = new TDoubleArrayList();
 
         // Median aggregate d50 values for each km
-        for (int i = 0; i <= rows.size() - 1; i++) {
-            kmd50s.add((double) rows.get(i)[4]);
-            if (((i == rows.size() - 1) || !Utils.epsilonEquals((double) rows.get(i)[0], (double) rows.get(i + 1)[0], 0.0001))) {
-                final int k = kmd50s.size() / 2;
-                values.add(((k + k < kmd50s.size()) ? kmd50s.get(k) : (kmd50s.get(k - 1) + kmd50s.get(k)) / 2) / 1000);
-                kms.add((double) rows.get(i)[0]);
-                log.debug(String.format("loadValues km %.3f d50(mm) %.1f count %d", kms.get(kms.size() - 1), values.get(values.size() - 1) * 1000,
-                        kmd50s.size()));
-                kmd50s.clear();
+        if (rows != null) {
+            for (int i = 0; i <= rows.size() - 1; i++) {
+                log.trace("loadValues rows(" + i + ") " + rows.get(i)[0] + " " + rows.get(i)[1] + " " + rows.get(i)[2] + " " + rows.get(i)[3] + " "
+                        + rows.get(i)[4]);
+                kmd50s.add((double) rows.get(i)[4]);
+                if (((i == rows.size() - 1) || !Utils.epsilonEquals((double) rows.get(i)[0], (double) rows.get(i + 1)[0], 0.0001))) {
+                    final int k = kmd50s.size() / 2;
+                    values.add(((k + k < kmd50s.size()) ? kmd50s.get(k) : (kmd50s.get(k - 1) + kmd50s.get(k)) / 2) / 1000);
+                    kms.add((double) rows.get(i)[0]);
+                    log.debug(String.format("loadValues km %.3f d50(mm) %.1f count %d", kms.get(kms.size() - 1), values.get(values.size() - 1) * 1000,
+                            kmd50s.size()));
+                    kmd50s.clear();
+                }
             }
         }
         if (kms.size() >= 1)

http://dive4elements.wald.intevation.org