Mercurial > dive4elements > river
changeset 6999:3e93f29281bc
Fix for flys/issue1479: The indices of the dates of the analysis periods where re-mapped wrong.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 12 Sep 2013 16:35:07 +0200 |
parents | e96d3f6c7c42 |
children | 7a7cb22395b4 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsOverview.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java |
diffstat | 4 files changed, 46 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsOverview.java Thu Sep 12 11:50:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsOverview.java Thu Sep 12 16:35:07 2013 +0200 @@ -770,14 +770,21 @@ protected Date end; public DateRangeFilter(Date start, Date end) { - this.start = start; - this.end = end; + if (start.before(end)) { + this.start = start; + this.end = end; + } + else { + this.start = end; + this.end = start; + } } @Override public boolean accept(Fixing.Column column) { Date date = column.getStartTime(); - return start.compareTo(date) <= 0 && end.compareTo(date) >= 0; + // start <= date <= end + return !(date.before(start) || date.after(end)); } } // class DateRangeFilter
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java Thu Sep 12 11:50:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java Thu Sep 12 16:35:07 2013 +0200 @@ -126,7 +126,7 @@ Function function, Parameters parameters, FixingsOverview overview, - ColumnCache cc + ColumnCache cc ) { Range range = new Range(from, to); @@ -150,15 +150,28 @@ TIntIntHashMap [] col2indices = new TIntIntHashMap[analysisPeriods.length]; + DateRangeFilter [] drfs = new DateRangeFilter[analysisPeriods.length]; + + boolean debug = log.isDebugEnabled(); + for (int i = 0; i < analysisPeriods.length; ++i) { col2indices[i] = new TIntIntHashMap(); + drfs[i] = new DateRangeFilter( + analysisPeriods[i].getFrom(), + analysisPeriods[i].getTo()); + + if (debug) { + log.debug("Analysis period " + (i+1) + " date range: " + + analysisPeriods[i].getFrom() + " - " + + analysisPeriods[i].getTo()); + } } for (int row = 0, R = parameters.size(); row < R; ++row) { double km = parameters.get(row, kmIndex); parameters.get(row, parameterIndices, parameterValues); - // This is the paraterized function for a given km. + // This is the parameterized function for a given km. org.dive4elements.river.artifacts.math.Function instance = function.instantiate(parameterValues); @@ -171,9 +184,7 @@ DateRange analysisPeriod = analysisPeriods[ap]; TIntIntHashMap col2index = col2indices[ap]; - DateRangeFilter drf = new DateRangeFilter( - analysisPeriod.getFrom(), - analysisPeriod.getTo()); + DateRangeFilter drf = drfs[ap]; QWD [] qSectorAverages = new QWD[4]; double [] qSectorStdDevs = new double[4]; @@ -291,8 +302,9 @@ parameters.set(row, maxQIndex, maxQ); } - results.add(km, periodResults.toArray( - new AnalysisPeriod[periodResults.size()])); + AnalysisPeriod [] rap = new AnalysisPeriod[periodResults.size()]; + periodResults.toArray(rap); + results.add(km, rap); } return results;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java Thu Sep 12 11:50:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java Thu Sep 12 16:35:07 2013 +0200 @@ -8,6 +8,8 @@ package org.dive4elements.river.artifacts.model.fixings; +import gnu.trove.TIntObjectHashMap; + import java.util.Collection; import java.util.Date; import java.util.TreeMap; @@ -56,17 +58,22 @@ public void makeAnalysisEventsUnique() { - // Actually it would be enough to make dates - // unique in one analysis period but to simplify things - // we make them unique in all periods. - DateUniqueMaker dum = new DateUniqueMaker(); + TIntObjectHashMap dums = new TIntObjectHashMap(); + for (KMIndex.Entry<AnalysisPeriod []> entry: analysisPeriods) { - for (AnalysisPeriod ap: entry.getValue()) { + AnalysisPeriod [] aps = entry.getValue(); + for (int i = 0; i < aps.length; ++i) { + AnalysisPeriod ap = aps[i]; QWD [] qwds = ap.getQWDs(); - if (qwds != null) { - for (QWD qwd: qwds) { - dum.makeUnique(qwd); - } + if (qwds == null) { + continue; + } + DateUniqueMaker dum = (DateUniqueMaker)dums.get(i); + if (dum == null) { + dums.put(i, dum = new DateUniqueMaker()); + } + for (QWD qwd: qwds) { + dum.makeUnique(qwd); } } }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java Thu Sep 12 11:50:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java Thu Sep 12 16:35:07 2013 +0200 @@ -173,7 +173,7 @@ int qsE = access.getQSectorEnd(); DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy"); - DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyy'T'HH:mm"); + DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm"); DateRange [] periods = access.getAnalysisPeriods();