[PATCH] issue1841 Only include loads where value != NaN in info service
Wald Commits
scm-commit at wald.intevation.org
Thu Aug 20 19:22:55 CEST 2015
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1440090896 -7200
# Node ID ef0ec2498dd0b2db8b884383133124bd16d39a82
# Parent d0f2250b552165c5598b5fa44d1baa426b44d223
issue1841 Only include loads where value != NaN in info service
diff -r d0f2250b5521 -r ef0ec2498dd0 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Thu Aug 20 14:21:54 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Thu Aug 20 19:14:56 2015 +0200
@@ -222,22 +222,24 @@
this.station = station;
}
- public void allLoads(Collection<Load> loads) {
+ public void allLoadsWithValue(Collection<Load> loads) {
for (List<Value> values: grainFractions) {
if (values != null) {
for (Value value: values) {
- loads.add(value.getLoad());
+ if (!Double.isNaN(value.getValue())) {
+ loads.add(value.getLoad());
+ }
}
}
}
}
- public void allNonEpochLoads(Collection<Load> loads) {
+ public void allNonEpochLoadsWithValue(Collection<Load> loads) {
for (List<Value> values: grainFractions) {
if (values != null) {
for (Value value: values) {
Load load = value.getLoad();
- if (load.isEpoch()) {
+ if (load.isEpoch() || Double.isNaN(value.getValue())) {
continue;
}
loads.add(value.getLoad());
@@ -246,26 +248,16 @@
}
}
- public void allOfficialLoads(Collection<Load> loads) {
- for (List<Value> values: grainFractions) {
- if (values != null) {
- for (Value value: values) {
- Load load = value.getLoad();
- if (load.getKind() == 1) {
- loads.add(value.getLoad());
- }
- }
- }
- }
- }
-
- public void allLoads(Collection<Load> loads, Integer sqRelationTimeInterval) {
+ public void allLoadsWithValue(Collection<Load> loads, Integer sqRelationTimeInterval) {
for (List<Value> values: grainFractions) {
if (values == null) {
continue;
}
for (Value value: values) {
+ if (Double.isNaN(value.getValue())) {
+ continue;
+ }
Load load = value.getLoad();
Integer sqId = load.getSQRelationTimeIntervalId();
if ((sqRelationTimeInterval == null)
@@ -519,13 +511,13 @@
};
/** Find all loads in the range a/b with the according sq_time_interval */
- public Collection<Load> findLoads(double a, double b, final Integer sqRelationTimeInterval) {
+ public Collection<Load> findLoadsWithValue(double a, double b, final Integer sqRelationTimeInterval) {
final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
findStations(a, b, new Visitor() {
@Override
public void visit(Station station) {
- station.allLoads(loads, sqRelationTimeInterval);
+ station.allLoadsWithValue(loads, sqRelationTimeInterval);
}
});
@@ -536,26 +528,26 @@
*
* This is mainly a convenience function for the SedimentLoadInfoService.
*/
- public Collection<Load> findDistinctSQTimeIntervalNonEpochLoads(double a, double b) {
+ public Collection<Load> findDistinctSQTimeIntervalNonEpochLoadsWithValue(double a, double b) {
final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP);
findStations(a, b, new Visitor() {
@Override
public void visit(Station station) {
- station.allNonEpochLoads(loads);
+ station.allNonEpochLoadsWithValue(loads);
}
});
return loads;
}
- public Collection<Load> findLoads(double a, double b) {
+ public Collection<Load> findLoadsWithValue(double a, double b) {
final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
findStations(a, b, new Visitor() {
@Override
public void visit(Station station) {
- station.allLoads(loads);
+ station.allLoadsWithValue(loads);
}
});
diff -r d0f2250b5521 -r ef0ec2498dd0 artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Thu Aug 20 14:21:54 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Thu Aug 20 19:14:56 2015 +0200
@@ -85,7 +85,7 @@
log.debug("Requested type: " + type + " with sq_ti_id: " + sq_ti_id);
Collection <Load> loads;
if (type.equals("sq_time_intervals")) {
- loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoads(fromD, toD);
+ loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoadsWithValue(fromD, toD);
for (Iterator<Load> it = loads.iterator(); it.hasNext();) {
/* Skip loads without time interval for this info type. */
@@ -97,9 +97,9 @@
} else {
if (!sq_ti_id.isEmpty()) {
Integer id = Integer.parseInt(sq_ti_id);
- loads = allLoadData.findLoads(fromD, toD, id);
+ loads = allLoadData.findLoadsWithValue(fromD, toD, id);
} else {
- loads = allLoadData.findLoads(fromD, toD);
+ loads = allLoadData.findLoadsWithValue(fromD, toD);
}
for (Iterator<Load> it = loads.iterator(); it.hasNext();) {
/* Skip epochs . */
More information about the Dive4Elements-commits
mailing list