# HG changeset patch # User Sascha L. Teichmann # Date 1327340391 0 # Node ID 637dd38d0e2f405e594c73805293692410b3bf83 # Parent d548e2e13524552e310e5360fe31e3b1925da25e Handle the case in "W auf freier Strecke" where more than ne Q is related to a W. flys-artifacts/trunk@3753 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d548e2e13524 -r 637dd38d0e2f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Jan 23 16:55:42 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jan 23 17:39:51 2012 +0000 @@ -1,3 +1,9 @@ +2012-01-23 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Handle the case in "W auf freier Strecke" where more than + one Q is related to a W. TODO: Generate user report. + 2012-01-23 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: diff -r d548e2e13524 -r 637dd38d0e2f flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon Jan 23 16:55:42 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon Jan 23 17:39:51 2012 +0000 @@ -364,10 +364,16 @@ logger.debug("Determine Q values based on a set of W values."); qSel = false; ws = getWs(); - qs = getQsForWs(ws); - if (qs == null) { + double [][] qws = getQsForWs(ws); + if (qws == null) { return error(new WQKms[0], "conversion ws to qs failed."); } + qs = qws[0]; + + if (qws[1] != null) { // If new ws where generated. + // TODO: Inform user! + ws = qws[1]; + } } WstValueTable wst = WstValueTableFactory.getTable(river); @@ -714,7 +720,7 @@ * * @return an array of Q values. */ - public double[] getQsForWs(double[] ws) { + public double [][] getQsForWs(double[] ws) { boolean debug = logger.isDebugEnabled(); @@ -735,6 +741,8 @@ } if (isFreeW()) { + // The simple case of the "Bezugslinienverfahren" + // "W auf freier Strecke". WstValueTable wst = WstValueTableFactory.getTable(r); if (wst == null) { logger.warn("no wst value table found"); @@ -742,22 +750,24 @@ } double km = range[0]; - double [] outQs = new double[ws.length]; + TDoubleArrayList outQs = new TDoubleArrayList(ws.length); + TDoubleArrayList outWs = new TDoubleArrayList(ws.length); + + boolean generatedWs = false; for (int i = 0; i < ws.length; ++i) { + // There could bemore than one Q per W. double [] qs = wst.findQsForW(km, ws[i]); - if (qs.length < 1) { - logger.warn("no q found for w = " + ws[i]); - outQs[i] = Double.NaN; + for (int j = 0; j < qs.length; ++j) { + outWs.add(ws[i]); + outQs.add(qs[j]); } - 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]; + generatedWs |= qs.length != 1; } - return outQs; + return new double [][] { + outQs.toNativeArray(), + generatedWs ? outWs.toNativeArray() : null }; } if (debug) { @@ -787,7 +797,7 @@ } } - return qs; + return new double [][] { qs, null }; }