Mercurial > dive4elements > river
changeset 8238:be3c11bef6e8
(issue1448) Finally use the sq time interval as filter in the calculation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 08 Sep 2014 19:01:26 +0200 |
parents | 25c3a62863d2 |
children | b207eeb66edd |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java |
diffstat | 2 files changed, 36 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Mon Sep 08 19:00:30 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Mon Sep 08 19:01:26 2014 +0200 @@ -24,6 +24,7 @@ import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects; import org.dive4elements.river.utils.DoubleUtil; @@ -151,6 +152,8 @@ private int [] years; private double from; private double to; + /* The sq time interval to use. 0 means this is ignored. */ + private int sqTiId; public SedimentLoadDataCalculation() { @@ -169,6 +172,8 @@ double from = access.getLowerKM(); double to = access.getUpperKM(); + int sqTiId = access.getSQTiId(); + if (yearEpoch.equals("year")) { years = access.getPeriod(); } @@ -196,6 +201,7 @@ this.epochs = epochs; this.from = from; this.to = to; + this.sqTiId = sqTiId; return internalCalculate(); } @@ -227,6 +233,8 @@ Not notEpochs = new Not(IsEpoch.INSTANCE); + SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId); + Sum sum = new Sum(); SedimentDensity sd = getSedimentDensity(); @@ -236,7 +244,7 @@ for (int year = min; year <= max; ++year) { Value.Filter filter = new And(notEpochs) - .add(new TimeRangeIntersects(year)); + .add(new TimeRangeIntersects(year)).add(sqTiFilter); String period = Integer.toString(year); for (LoadSum ls: LOAD_SUMS) { @@ -278,6 +286,8 @@ // They are not epochs, they are single years! Not notEpochs = new Not(IsEpoch.INSTANCE); + SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId); + for (int [] epoch: epochs) { int min = Math.min(epoch[0], epoch[1]); int max = Math.max(epoch[0], epoch[1]); @@ -291,7 +301,7 @@ for (int year = min; year <= max; ++year) { Value.Filter filter = new And(notEpochs) - .add(new TimeRangeIntersects(year)); + .add(new TimeRangeIntersects(year)).add(sqTiFilter); double [][] result = sum( sld, ls.getGrainFractions(), ls.getStationType(),
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Mon Sep 08 19:00:30 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Mon Sep 08 19:01:26 2014 +0200 @@ -110,6 +110,30 @@ } } // class Year + public static final class SQTimeInterval implements Filter { + + private int sqTiId; + + public SQTimeInterval(int sqTiId) { + this.sqTiId = sqTiId; + } + + @Override + public boolean accept(Value value) { + if (sqTiId == 0) { + /* Nothing set, nothing filtered */ + return true; + } + if (value.getLoad().getSQRelationTimeIntervalId() == 0) { + /* Loads without sqRelationTimeInterval are "Schwebstoffe" and should + * be included. */ + return true; + } + /* All other values should be filtered accordingly. */ + return value.getLoad().getSQRelationTimeIntervalId() == sqTiId; + } + } // class SQTimeInterval + public static final class IsEpoch implements Filter { public static final IsEpoch INSTANCE = new IsEpoch();