comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8768:ef0ec2498dd0

issue1841 Only include loads where value != NaN in info service
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 20 Aug 2015 19:14:56 +0200
parents d0f2250b5521
children 5e38e2924c07
comparison
equal deleted inserted replaced
8767:d0f2250b5521 8768:ef0ec2498dd0
220 } 220 }
221 this.type = type; 221 this.type = type;
222 this.station = station; 222 this.station = station;
223 } 223 }
224 224
225 public void allLoads(Collection<Load> loads) { 225 public void allLoadsWithValue(Collection<Load> loads) {
226 for (List<Value> values: grainFractions) { 226 for (List<Value> values: grainFractions) {
227 if (values != null) { 227 if (values != null) {
228 for (Value value: values) { 228 for (Value value: values) {
229 loads.add(value.getLoad()); 229 if (!Double.isNaN(value.getValue())) {
230 loads.add(value.getLoad());
231 }
230 } 232 }
231 } 233 }
232 } 234 }
233 } 235 }
234 236
235 public void allNonEpochLoads(Collection<Load> loads) { 237 public void allNonEpochLoadsWithValue(Collection<Load> loads) {
236 for (List<Value> values: grainFractions) { 238 for (List<Value> values: grainFractions) {
237 if (values != null) { 239 if (values != null) {
238 for (Value value: values) { 240 for (Value value: values) {
239 Load load = value.getLoad(); 241 Load load = value.getLoad();
240 if (load.isEpoch()) { 242 if (load.isEpoch() || Double.isNaN(value.getValue())) {
241 continue; 243 continue;
242 } 244 }
243 loads.add(value.getLoad()); 245 loads.add(value.getLoad());
244 } 246 }
245 } 247 }
246 } 248 }
247 } 249 }
248 250
249 public void allOfficialLoads(Collection<Load> loads) { 251 public void allLoadsWithValue(Collection<Load> loads, Integer sqRelationTimeInterval) {
250 for (List<Value> values: grainFractions) {
251 if (values != null) {
252 for (Value value: values) {
253 Load load = value.getLoad();
254 if (load.getKind() == 1) {
255 loads.add(value.getLoad());
256 }
257 }
258 }
259 }
260 }
261
262 public void allLoads(Collection<Load> loads, Integer sqRelationTimeInterval) {
263 252
264 for (List<Value> values: grainFractions) { 253 for (List<Value> values: grainFractions) {
265 if (values == null) { 254 if (values == null) {
266 continue; 255 continue;
267 } 256 }
268 for (Value value: values) { 257 for (Value value: values) {
258 if (Double.isNaN(value.getValue())) {
259 continue;
260 }
269 Load load = value.getLoad(); 261 Load load = value.getLoad();
270 Integer sqId = load.getSQRelationTimeIntervalId(); 262 Integer sqId = load.getSQRelationTimeIntervalId();
271 if ((sqRelationTimeInterval == null) 263 if ((sqRelationTimeInterval == null)
272 || sqId != null && sqId.equals(sqRelationTimeInterval)) { 264 || sqId != null && sqId.equals(sqRelationTimeInterval)) {
273 loads.add(load); 265 loads.add(load);
517 return a_id - b_id; 509 return a_id - b_id;
518 } 510 }
519 }; 511 };
520 512
521 /** Find all loads in the range a/b with the according sq_time_interval */ 513 /** Find all loads in the range a/b with the according sq_time_interval */
522 public Collection<Load> findLoads(double a, double b, final Integer sqRelationTimeInterval) { 514 public Collection<Load> findLoadsWithValue(double a, double b, final Integer sqRelationTimeInterval) {
523 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); 515 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
524 516
525 findStations(a, b, new Visitor() { 517 findStations(a, b, new Visitor() {
526 @Override 518 @Override
527 public void visit(Station station) { 519 public void visit(Station station) {
528 station.allLoads(loads, sqRelationTimeInterval); 520 station.allLoadsWithValue(loads, sqRelationTimeInterval);
529 } 521 }
530 }); 522 });
531 523
532 return loads; 524 return loads;
533 } 525 }
534 526
535 /** Get a list of loads with unique sq_time_intervals. 527 /** Get a list of loads with unique sq_time_intervals.
536 * 528 *
537 * This is mainly a convenience function for the SedimentLoadInfoService. 529 * This is mainly a convenience function for the SedimentLoadInfoService.
538 */ 530 */
539 public Collection<Load> findDistinctSQTimeIntervalNonEpochLoads(double a, double b) { 531 public Collection<Load> findDistinctSQTimeIntervalNonEpochLoadsWithValue(double a, double b) {
540 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP); 532 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP);
541 533
542 findStations(a, b, new Visitor() { 534 findStations(a, b, new Visitor() {
543 @Override 535 @Override
544 public void visit(Station station) { 536 public void visit(Station station) {
545 station.allNonEpochLoads(loads); 537 station.allNonEpochLoadsWithValue(loads);
546 } 538 }
547 }); 539 });
548 540
549 return loads; 541 return loads;
550 } 542 }
551 543
552 public Collection<Load> findLoads(double a, double b) { 544 public Collection<Load> findLoadsWithValue(double a, double b) {
553 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); 545 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
554 546
555 findStations(a, b, new Visitor() { 547 findStations(a, b, new Visitor() {
556 @Override 548 @Override
557 public void visit(Station station) { 549 public void visit(Station station) {
558 station.allLoads(loads); 550 station.allLoadsWithValue(loads);
559 } 551 }
560 }); 552 });
561 553
562 return loads; 554 return loads;
563 } 555 }

http://dive4elements.wald.intevation.org