[PATCH 3 of 3] (issue1448) Finally use the sq time interval as filter in the calculation
Wald Commits
scm-commit at wald.intevation.org
Mon Sep 8 19:01:33 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1410195686 -7200
# Node ID be3c11bef6e83589dc686cb57e207ee343ea40e1
# Parent 25c3a62863d267b781f72e3d13e4e6f5effa62ba
(issue1448) Finally use the sq time interval as filter in the calculation.
diff -r 25c3a62863d2 -r be3c11bef6e8 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
--- 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(),
diff -r 25c3a62863d2 -r be3c11bef6e8 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java
--- 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();
More information about the Dive4Elements-commits
mailing list