# HG changeset patch # User Andre Heinecke # 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 loads) { + public void allLoadsWithValue(Collection loads) { for (List 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 loads) { + public void allNonEpochLoadsWithValue(Collection loads) { for (List 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 loads) { - for (List 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 loads, Integer sqRelationTimeInterval) { + public void allLoadsWithValue(Collection loads, Integer sqRelationTimeInterval) { for (List 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 findLoads(double a, double b, final Integer sqRelationTimeInterval) { + public Collection findLoadsWithValue(double a, double b, final Integer sqRelationTimeInterval) { final TreeSet loads = new TreeSet(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 findDistinctSQTimeIntervalNonEpochLoads(double a, double b) { + public Collection findDistinctSQTimeIntervalNonEpochLoadsWithValue(double a, double b) { final TreeSet loads = new TreeSet(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 findLoads(double a, double b) { + public Collection findLoadsWithValue(double a, double b) { final TreeSet loads = new TreeSet(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 loads; if (type.equals("sq_time_intervals")) { - loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoads(fromD, toD); + loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoadsWithValue(fromD, toD); for (Iterator 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 it = loads.iterator(); it.hasNext();) { /* Skip epochs . */