Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 2164:d548e2e13524
Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
flys-artifacts/trunk@3752 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 23 Jan 2012 16:55:42 +0000 |
parents | d626ae185305 |
children | 637dd38d0e2f |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon Jan 23 14:18:53 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon Jan 23 16:55:42 2012 +0000 @@ -383,7 +383,7 @@ double refKm; - if (isFreeQ()) { + if (isFreeQ() || isFreeW()) { refKm = range[0]; logger.debug("'free' calculation (km " + refKm + ")"); } @@ -734,6 +734,32 @@ return null; } + if (isFreeW()) { + WstValueTable wst = WstValueTableFactory.getTable(r); + if (wst == null) { + logger.warn("no wst value table found"); + return null; + } + double km = range[0]; + + double [] outQs = new double[ws.length]; + + for (int i = 0; i < ws.length; ++i) { + double [] qs = wst.findQsForW(km, ws[i]); + if (qs.length < 1) { + logger.warn("no q found for w = " + ws[i]); + outQs[i] = Double.NaN; + } + if (qs.length > 1) { + // TODO: Generate more than w/q line! + logger.warn("more than one q found for w = " + ws[i]); + } + outQs[i] = qs[0]; + } + + return outQs; + } + if (debug) { logger.debug("range: " + Arrays.toString(range)); } @@ -939,6 +965,11 @@ return mode != null && mode.getValue().equals("Q"); } + public boolean isFreeW() { + StateData mode = getData("wq_mode"); + return mode != null && mode.getValue().equals("FREEW"); + } + /** * Returns true, if the parameter is set to compute data on a free range. @@ -954,11 +985,7 @@ logger.debug("isFreeQ: " + value); - if (value == null) { - return false; - } - - return Boolean.valueOf(value); + return value != null && Boolean.valueOf(value); }