# HG changeset patch # User Sascha L. Teichmann # Date 1309099608 0 # Node ID 5abdb2fa8eb18d08ec65434eaf29367a7cc974ed # Parent 6b38b84884010ffc0bbc53f229f42b95be2f424c Fix for flys/issue147 flys-artifacts/trunk@2234 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6b38b8488401 -r 5abdb2fa8eb1 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sun Jun 26 13:07:44 2011 +0000 +++ b/flys-artifacts/ChangeLog Sun Jun 26 14:46:48 2011 +0000 @@ -1,3 +1,17 @@ +2011-06-26 Sascha L. Teichmann + + Fix for flys/issue147 + + * src/main/java/de/intevation/flys/artifacts/model/Calculation1.java: + Removed the 'kmUp' flag. It was an left over from former + WSP calculations (w/o ref km) leading to wrong results now. + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Don't pass the kmUp flag to the calculation. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Added debug output to see the value of 'wq_free'. + 2011-06-26 Sascha L. Teichmann Fix for flys/issue86 diff -r 6b38b8488401 -r 5abdb2fa8eb1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Sun Jun 26 13:07:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Sun Jun 26 14:46:48 2011 +0000 @@ -772,7 +772,9 @@ StateData mode = getData("wq_free"); String value = mode != null ? (String) mode.getValue() : null; - if (mode == null) { + logger.debug("isFreeQ: " + value); + + if (value == null) { return false; } diff -r 6b38b8488401 -r 5abdb2fa8eb1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sun Jun 26 13:07:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sun Jun 26 14:46:48 2011 +0000 @@ -344,14 +344,19 @@ return error(new WQKms[0], "No Wst found for selected river."); } - double refKm = Double.NaN; - if (!isFreeQ()) { - double [] range = getDistance(); - if (range == null) { - return error(new WQKms[0], "No range found"); - } + double [] range = getDistance(); + if (range == null) { + return error(new WQKms[0], "No range found"); + } + double refKm; + + if (isFreeQ()) { + refKm = range[0]; + logger.debug("'free' calculation (km " + refKm + ")"); + } + else { Gauge gauge = river.determineGaugeByPosition(range[0]); if (gauge == null) { return error( @@ -364,8 +369,7 @@ "reference gauge: " + gauge.getName() + " (km " + refKm + ")"); } - return computeWaterlevelData( - kms, qs, ws, wst, refKm, river.getKmUp()); + return computeWaterlevelData(kms, qs, ws, wst, refKm); } /** @@ -383,12 +387,11 @@ double [] qs, double [] ws, WstValueTable wst, - double refKm, - boolean up + double refKm ) { logger.info("WINFOArtifact.computeWaterlevelData"); - Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm, up); + Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm); return calc1.calculate(wst); } diff -r 6b38b8488401 -r 5abdb2fa8eb1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java Sun Jun 26 13:07:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java Sun Jun 26 14:46:48 2011 +0000 @@ -12,7 +12,6 @@ protected double [] kms; protected double [] qs; protected double [] ws; - protected boolean up; protected double refKm; public Calculation1() { @@ -22,24 +21,18 @@ double [] kms, double [] qs, double [] ws, - double refKm, - boolean up + double refKm ) { this.kms = kms; this.qs = qs; this.ws = ws; this.refKm = refKm; - this.up = up; } public CalculationResult calculate(WstValueTable wst) { ArrayList results = new ArrayList(); - double ref = Double.isNaN(refKm) - ? kms[up ? 0 : kms.length-1] - : refKm; - String prefix; double [] origData; @@ -54,7 +47,7 @@ double [] ows = new double[kms.length]; boolean success = - wst.interpolate(qs[i], ref, kms, ows, oqs, this) != null; + wst.interpolate(qs[i], refKm, kms, ows, oqs, this) != null; int newNumProblems = numProblems();