# HG changeset patch # User Felix Wolfsteller # Date 1372061734 -7200 # Node ID e6ceab9e309129416de65530e216e2ba4779a7eb # Parent 2d538e01da7c02ef6df9dbc91a30f0fb6ccf6983 prep issue1235: Rename functions and variable to indicate use of other susp values. diff -r 2d538e01da7c -r e6ceab9e3091 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Fri Jun 21 18:22:55 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Mon Jun 24 10:15:34 2013 +0200 @@ -298,7 +298,7 @@ /** Returns true if all fraction values except SuspSediment are unset. */ - private boolean hasOnlySuspSediment(SedimentLoadFraction fraction) { + private boolean hasOnlySuspValues(SedimentLoadFraction fraction) { return (fraction.getSuspSediment() != 0d && fraction.getCoarse() == 0d && fraction.getFineMiddle() == 0d && @@ -308,7 +308,7 @@ /** Returns true if all fraction values except SuspSediment are set. */ - private boolean hasButSuspSediment(SedimentLoadFraction fraction) { + private boolean hasButSuspValues(SedimentLoadFraction fraction) { return (fraction.getSuspSediment() == 0d && fraction.getCoarse() != 0d && fraction.getFineMiddle() != 0d && @@ -342,8 +342,8 @@ Range lastOtherRange = null; double lastOtherValue = 0d; - Range lastSuspSedimentRange = null; - double lastSuspSedimentValue = 0d; + Range lastSuspRange = null; + double lastSuspValue = 0d; for (double km: load.getKms()) { logger.debug ("Trying to add at km " + km); @@ -358,7 +358,7 @@ if (fraction.getCoarseRange().equals( fraction.getSuspSedimentRange())) { lastOtherRange = null; - lastSuspSedimentRange = null; + lastSuspRange = null; fairLoad.setTotal(km, total, fraction.getCoarseRange()); } else { @@ -367,9 +367,9 @@ < fraction.getSuspSedimentRange().getEnd()) { // Schwebstoff is longer. // Adjust and remember schwebstoffs range and value. - lastSuspSedimentRange = (Range) fraction.getSuspSedimentRange().clone(); - lastSuspSedimentRange.setStart(fraction.getCoarseRange().getEnd()); - lastSuspSedimentValue = fraction.getSuspSediment(); + lastSuspRange = (Range) fraction.getSuspSedimentRange().clone(); + lastSuspRange.setStart(fraction.getCoarseRange().getEnd()); + lastSuspValue = fraction.getSuspSediment(); lastOtherRange = null; fairLoad.setTotal(km, total, fraction.getCoarseRange()); } @@ -379,12 +379,12 @@ lastOtherRange = (Range) fraction.getSuspSedimentRange().clone(); lastOtherRange.setStart(fraction.getSuspSedimentRange().getEnd()); lastOtherValue = (total - fraction.getSuspSediment()); - lastSuspSedimentRange = null; + lastSuspRange = null; fairLoad.setTotal(km, total, fraction.getSuspSedimentRange()); } } } - else if (hasOnlySuspSediment(fraction) && lastOtherRange != null) { + else if (hasOnlySuspValues(fraction) && lastOtherRange != null) { // Split stuff. Range suspSedimentRange = fraction.getSuspSedimentRange(); // if intersects with last other range, cool! merge and add! @@ -399,56 +399,56 @@ double total = lastOtherValue + fraction.getSuspSediment(); Range totalRange = new Range(maxStart, minEnd); if (suspSedimentRange.getEnd() > lastOtherRange.getEnd()) { - lastSuspSedimentRange = (Range) suspSedimentRange.clone(); - lastSuspSedimentRange.setStart(lastOtherRange.getEnd()); - lastSuspSedimentValue = fraction.getSuspSediment(); + lastSuspRange = (Range) suspSedimentRange.clone(); + lastSuspRange.setStart(lastOtherRange.getEnd()); + lastSuspValue = fraction.getSuspSediment(); lastOtherRange = null; } else { // Other is "longer". lastOtherRange.setStart(suspSedimentRange.getEnd()); - lastSuspSedimentRange = null; + lastSuspRange = null; } if (Math.abs(suspSedimentRange.getEnd() - lastOtherRange.getEnd()) < 0.1d) { lastOtherRange = null; - lastSuspSedimentRange = null; + lastSuspRange = null; } fairLoad.setTotal(km, total + fraction.getSuspSediment(), totalRange); } else { - lastSuspSedimentRange = suspSedimentRange; - lastSuspSedimentValue = fraction.getSuspSediment(); + lastSuspRange = suspSedimentRange; + lastSuspValue = fraction.getSuspSediment(); lastOtherRange = null; } } - else if (hasButSuspSediment(fraction) && lastSuspSedimentRange != null) { + else if (hasButSuspValues(fraction) && lastSuspRange != null) { // If intersects with last suspsed range, merge and add double total = fraction.getCoarse() + fraction.getFineMiddle() + fraction.getSand() + fraction.getSuspSand() + - lastSuspSedimentValue; + lastSuspValue; double maxStart = Math.max(fraction.getCoarseRange().getStart(), - lastSuspSedimentRange.getStart()); - if (lastSuspSedimentRange.contains(km)) { + lastSuspRange.getStart()); + if (lastSuspRange.contains(km)) { double minEnd = Math.min(fraction.getCoarseRange().getEnd(), - lastSuspSedimentRange.getEnd()); + lastSuspRange.getEnd()); Range totalRange = new Range(maxStart, minEnd); - if (lastSuspSedimentRange.getEnd() > fraction.getCoarseRange().getEnd()) { + if (lastSuspRange.getEnd() > fraction.getCoarseRange().getEnd()) { // SuspSed longer. - lastSuspSedimentRange.setStart(fraction.getCoarseRange().getEnd()); + lastSuspRange.setStart(fraction.getCoarseRange().getEnd()); lastOtherRange = null; } else { // Other longer lastOtherRange = (Range) fraction.getCoarseRange().clone(); - lastOtherRange.setStart(lastSuspSedimentRange.getEnd()); - lastSuspSedimentRange = null; - lastOtherValue = total - lastSuspSedimentValue; + lastOtherRange.setStart(lastSuspRange.getEnd()); + lastSuspRange = null; + lastOtherValue = total - lastSuspValue; } - if (Math.abs(lastSuspSedimentRange.getEnd() - lastOtherRange.getEnd()) < 0.1d) { + if (Math.abs(lastSuspRange.getEnd() - lastOtherRange.getEnd()) < 0.1d) { lastOtherRange = null; - lastSuspSedimentRange = null; + lastSuspRange = null; } fairLoad.setTotal(km, total, totalRange); } @@ -456,7 +456,7 @@ // Ranges are disjoint. lastOtherRange = fraction.getCoarseRange(); lastOtherValue = total - fraction.getSuspSediment(); - lastSuspSedimentRange = null; + lastSuspRange = null; } } else {