# HG changeset patch # User Andre Heinecke # Date 1386860500 -3600 # Node ID f4b3861712a4bef8d82017ad7efe1480d855ab4e # Parent 7484132b2fbb1380f9f66eac4f683197dd7f7a0f (issue1666) Calculate wRow after rounding the first value. This also fixes negative waterlevels in the export. diff -r 7484132b2fbb -r f4b3861712a4 artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixATWriter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixATWriter.java Thu Dec 12 07:57:13 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixATWriter.java Thu Dec 12 16:01:40 2013 +0100 @@ -26,6 +26,7 @@ import java.io.Writer; import java.util.Locale; +import java.util.Arrays; import org.apache.log4j.Logger; @@ -118,21 +119,24 @@ double wMinCM = wMin * 100d - subtractPNP; double wMaxCM = wMax * 100d; - int wRow = ((int)wMinCM / 10) * 10; - if ((wMinCM - (int)wMinCM) > 0d) { wMinCM = (int)wMinCM + 1d; } + int wRow = ((int)wMinCM / 10) * 10; + double w = (wMinCM + subtractPNP) / 100.0; int wcm = ((int)wMinCM) % 10; if (log.isDebugEnabled()) { + log.debug("km: " + km); log.debug("wMinCM: " + wMinCM); log.debug("wMaxCM: " + wMaxCM); log.debug("wcm: " + wcm); log.debug("subtractPNP: " + subtractPNP); + log.debug("coeffs: " + Arrays.toString(coeffs)); + log.debug("function description: " + inverse.getDescription()); } out.printf(Locale.US, "%8d", wRow); @@ -205,6 +209,11 @@ for (int i = 0; i < MAX_ITERATIONS; ++i) { double w = lastW - stepWidth; + + if (w <= 0) { + return 0; + } + double q = function.value(w); if (Double.isNaN(q) || q > lastQ || q < MIN_Q) {