changeset 8145:52504fc2cd58

Calculate all single years in given interval but only once.
author Tom Gottfried <tom@intevation.de>
date Wed, 27 Aug 2014 15:01:54 +0200
parents 8eeb4b717dca
children ce35bdf3d750
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Tue Aug 26 17:21:42 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Wed Aug 27 15:01:54 2014 +0200
@@ -253,7 +253,10 @@
 
         SedimentDensity sd = getSedimentDensity();
 
-        for (int year: years) {
+        int min = Math.min(years[0], years[1]);
+        int max = Math.max(years[0], years[1]);
+
+        for (int year = min; year <= max; ++year) {
             Value.Filter filter = new And(notEpochs)
                 .add(new TimeRangeIntersects(year));
             String period = Integer.toString(year);
@@ -277,6 +280,9 @@
 
                 sldr.addFraction(sldrf);
             }
+
+            // Do not give single year twice
+            if (min == max) break;
         }
         // TODO: Generate messages for missing fractions.
         return new CalculationResult(sldr, this);

http://dive4elements.wald.intevation.org