Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java @ 3056:0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
flys-artifacts/trunk@4632 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 10 Jun 2012 11:12:38 +0000 |
parents | 1fbf8462f808 |
children | 7660cfe5e8f6 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Sat Jun 09 13:46:04 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Sun Jun 10 11:12:38 2012 +0000 @@ -20,7 +20,6 @@ import de.intevation.flys.artifacts.states.DefaultState.ComputeType; - /** * Facet to show the W|Q values. * @@ -69,12 +68,21 @@ FixResult result = (FixResult) res.getData(); double km = access.getCurrentKm(); + logger.debug("FixWQCurveFacet.getData: km = " + km); String function = access.getFunction(); Function ff = FunctionFactory.getInstance().getFunction(function); Parameters params = result.getParameters(); - int row = 0; //params.binarySearch("km", km, Math.pow(10, -4)); //FIXME: search failes as access.getCurrentKm() always returns 13.37... + String[] columnNames = params.getColumnNames(); + for(String columnName : columnNames) { + logger.debug("FixWQCurveFacet.getData: columnName = '" + columnName + "'"); + } + int row = params.binarySearch("km", km /*, Math.pow(10, -4)*/); //FIXME Use epsilon as soon access.getCurrentKm() is fixed + if(row < 0) { + row = -row - 1; + logger.debug("getData: no direct hit in params.binarySearch"); + } String[] paramNames = ff.getParameterNames(); int[] paramInd = params.columnIndices(paramNames); double[] coeffs = new double[paramNames.length]; @@ -83,7 +91,8 @@ de.intevation.flys.artifacts.math.Function mf = ff.instantiate(coeffs); - double maxQ = 100; //getMaxQ(result, km); //FIXME + double maxQ = getMaxQ(result, km); + logger.debug("getData: maxQ = " + maxQ); FixFunction fix = new FixFunction( ff.getName(), @@ -105,29 +114,39 @@ KMIndex<QW []> kmQWRef = result.getReferenced(); - QW[] qwRef = kmQWRef.binarySearch(km).getValue(); - if (qwRef != null) { - for (int i = 0; i < qwRef.length; i++) { - if (qwRef[i].getQ() > maxQ) { - maxQ = qwRef[i].getQ(); + KMIndex.Entry<QW []> qwEntry = kmQWRef.binarySearch(km); + if(qwEntry != null) { + QW[] qwRef = qwEntry.getValue(); + if (qwRef != null) { + for (int i = 0; i < qwRef.length; i++) { + if (qwRef[i].getQ() > maxQ) { + maxQ = qwRef[i].getQ(); + } } } + } else { + logger.debug("getMaxQ: qwEntry is null, that's odd..."); } KMIndex<AnalysisPeriod []> kmQWDAna = result.getAnalysisPeriods(); - AnalysisPeriod[] periods = kmQWDAna.binarySearch(km).getValue(); + KMIndex.Entry<AnalysisPeriod []> periodsEntry = kmQWDAna.binarySearch(km); - if(periods != null) { - for (int i = 0; i < periods.length; i++) { - QWD[] qwdAna = periods[i].getQWDs(); - if (qwdAna != null) { - for (int j = 0; j < qwdAna.length; j++) { - if (qwdAna[j].getQ() > maxQ) { - maxQ = qwdAna[j].getQ(); + if(periodsEntry != null) { + AnalysisPeriod[] periods = kmQWDAna.binarySearch(km).getValue(); + if(periods != null) { + for (int i = 0; i < periods.length; i++) { + QWD[] qwdAna = periods[i].getQWDs(); + if (qwdAna != null) { + for (int j = 0; j < qwdAna.length; j++) { + if (qwdAna[j].getQ() > maxQ) { + maxQ = qwdAna[j].getQ(); + } } } } } + } else { + logger.debug("getMaxQ: periodsEntry is null, that's odd..."); } return maxQ; }