comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java @ 6405:74b8362f6a4c

issue1235: Respect that suspSand values are also measured at "suspended" (Schwebstoff) measurement stations.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 24 Jun 2013 10:34:55 +0200
parents e6ceab9e3091
children a21f7a3e4be5
comparison
equal deleted inserted replaced
6404:e6ceab9e3091 6405:74b8362f6a4c
298 298
299 299
300 /** Returns true if all fraction values except SuspSediment are unset. */ 300 /** Returns true if all fraction values except SuspSediment are unset. */
301 private boolean hasOnlySuspValues(SedimentLoadFraction fraction) { 301 private boolean hasOnlySuspValues(SedimentLoadFraction fraction) {
302 return (fraction.getSuspSediment() != 0d && 302 return (fraction.getSuspSediment() != 0d &&
303 fraction.getSuspSand() != 0d &&
303 fraction.getCoarse() == 0d && 304 fraction.getCoarse() == 0d &&
304 fraction.getFineMiddle() == 0d && 305 fraction.getFineMiddle() == 0d &&
305 fraction.getSand() == 0d && 306 fraction.getSand() == 0d);
306 fraction.getSuspSand() == 0d);
307 } 307 }
308 308
309 309
310 /** Returns true if all fraction values except SuspSediment are set. */ 310 /** Returns true if all fraction values except SuspSediment are set. */
311 private boolean hasButSuspValues(SedimentLoadFraction fraction) { 311 private boolean hasButSuspValues(SedimentLoadFraction fraction) {
312 return (fraction.getSuspSediment() == 0d && 312 return (fraction.getSuspSediment() == 0d &&
313 fraction.getSuspSand() == 0d &&
313 fraction.getCoarse() != 0d && 314 fraction.getCoarse() != 0d &&
314 fraction.getFineMiddle() != 0d && 315 fraction.getFineMiddle() != 0d &&
315 fraction.getSand() != 0d && 316 fraction.getSand() != 0d);
316 fraction.getSuspSand() != 0d);
317 } 317 }
318 318
319 319
320 /** Returns true if all fraction needed for total calculation are set. */ 320 /** Returns true if all fraction needed for total calculation are set. */
321 private boolean complete(SedimentLoadFraction fraction) { 321 private boolean complete(SedimentLoadFraction fraction) {
367 < fraction.getSuspSedimentRange().getEnd()) { 367 < fraction.getSuspSedimentRange().getEnd()) {
368 // Schwebstoff is longer. 368 // Schwebstoff is longer.
369 // Adjust and remember schwebstoffs range and value. 369 // Adjust and remember schwebstoffs range and value.
370 lastSuspRange = (Range) fraction.getSuspSedimentRange().clone(); 370 lastSuspRange = (Range) fraction.getSuspSedimentRange().clone();
371 lastSuspRange.setStart(fraction.getCoarseRange().getEnd()); 371 lastSuspRange.setStart(fraction.getCoarseRange().getEnd());
372 lastSuspValue = fraction.getSuspSediment(); 372 lastSuspValue = fraction.getSuspSediment() + fraction.getSuspSand();
373 lastOtherRange = null; 373 lastOtherRange = null;
374 fairLoad.setTotal(km, total, fraction.getCoarseRange()); 374 fairLoad.setTotal(km, total, fraction.getCoarseRange());
375 } 375 }
376 else { 376 else {
377 // Geschiebe is longer. 377 // Geschiebe is longer.
399 double total = lastOtherValue + fraction.getSuspSediment(); 399 double total = lastOtherValue + fraction.getSuspSediment();
400 Range totalRange = new Range(maxStart, minEnd); 400 Range totalRange = new Range(maxStart, minEnd);
401 if (suspSedimentRange.getEnd() > lastOtherRange.getEnd()) { 401 if (suspSedimentRange.getEnd() > lastOtherRange.getEnd()) {
402 lastSuspRange = (Range) suspSedimentRange.clone(); 402 lastSuspRange = (Range) suspSedimentRange.clone();
403 lastSuspRange.setStart(lastOtherRange.getEnd()); 403 lastSuspRange.setStart(lastOtherRange.getEnd());
404 lastSuspValue = fraction.getSuspSediment(); 404 lastSuspValue = fraction.getSuspSediment() + fraction.getSuspSand();
405 lastOtherRange = null; 405 lastOtherRange = null;
406 } 406 }
407 else { 407 else {
408 // Other is "longer". 408 // Other is "longer".
409 lastOtherRange.setStart(suspSedimentRange.getEnd()); 409 lastOtherRange.setStart(suspSedimentRange.getEnd());
415 } 415 }
416 fairLoad.setTotal(km, total + fraction.getSuspSediment(), totalRange); 416 fairLoad.setTotal(km, total + fraction.getSuspSediment(), totalRange);
417 } 417 }
418 else { 418 else {
419 lastSuspRange = suspSedimentRange; 419 lastSuspRange = suspSedimentRange;
420 lastSuspValue = fraction.getSuspSediment(); 420 lastSuspValue = fraction.getSuspSediment() + fraction.getSuspSand();
421 lastOtherRange = null; 421 lastOtherRange = null;
422 } 422 }
423 } 423 }
424 else if (hasButSuspValues(fraction) && lastSuspRange != null) { 424 else if (hasButSuspValues(fraction) && lastSuspRange != null) {
425 // If intersects with last suspsed range, merge and add 425 // If intersects with last suspsed range, merge and add
426 double total = fraction.getCoarse() + 426 double total = fraction.getCoarse() +
427 fraction.getFineMiddle() + 427 fraction.getFineMiddle() +
428 fraction.getSand() + 428 fraction.getSand() +
429 fraction.getSuspSand() +
430 lastSuspValue; 429 lastSuspValue;
431 double maxStart = Math.max(fraction.getCoarseRange().getStart(), 430 double maxStart = Math.max(fraction.getCoarseRange().getStart(),
432 lastSuspRange.getStart()); 431 lastSuspRange.getStart());
433 if (lastSuspRange.contains(km)) { 432 if (lastSuspRange.contains(km)) {
434 double minEnd = Math.min(fraction.getCoarseRange().getEnd(), 433 double minEnd = Math.min(fraction.getCoarseRange().getEnd(),

http://dive4elements.wald.intevation.org