# HG changeset patch # User mschaefer # Date 1527232219 -7200 # Node ID a0feac6ea1ba523db7df3fd7fdd6a82a819fef8c # Parent 89c1bb914f4e52842298673b3aaccd1ac061054a Fixed d50 query, added log.trace diff -r 89c1bb914f4e -r a0feac6ea1ba artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/BedQualityD50KmValueFinder.java --- 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)