[PATCH 2 of 6] Add period to sedimentloaddataresult fraction

Wald Commits scm-commit at wald.intevation.org
Mon Aug 25 20:03:41 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1408989554 -7200
# Node ID fae48b3c09d196e6178dd7cc729a0a247aaabb2c
# Parent  bbad52b073a44018c5214552b8cc28a5987e34ba
Add period to sedimentloaddataresult fraction

    Period is the validity of the result. It is either a single
    year or a range of years (epoch). As this is only used for
    presentation purposes the type is a string so that years
    and epochs need not be handled differently.

diff -r bbad52b073a4 -r fae48b3c09d1 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Mon Aug 25 19:58:00 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Mon Aug 25 19:59:14 2014 +0200
@@ -256,6 +256,7 @@
         for (int year: years) {
             Value.Filter filter = new And(notEpochs)
                 .add(new TimeRangeIntersects(year));
+            String period = Integer.toString(year);
 
             for (GrainFraction gf: GRAIN_FRACTIONS) {
                 double [][] result = sum(
@@ -272,7 +273,7 @@
                 transformT2M3(sd, year, result);
 
                 SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result);
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period);
 
                 sldr.addFraction(sldrf);
             }
@@ -306,6 +307,8 @@
             int min = Math.min(epoch[0], epoch[1]);
             int max = Math.max(epoch[0], epoch[1]);
 
+            String period = Integer.toString(epoch[0]) + " - " +
+                Integer.toString(epoch[1]);
             for (int year = min; year <= max; ++year) {
                 Value.Filter filter = new And(notEpochs)
                     .add(new TimeRangeIntersects(year));
@@ -332,7 +335,7 @@
             double [][] result = average(results);
             // TODO: Optionally transform units.
             SedimentLoadDataResult.Fraction sldrf =
-                new SedimentLoadDataResult.Fraction("TODO: nice description", result);
+                new SedimentLoadDataResult.Fraction("TODO: nice description", result, period);
             sldr.addFraction(sldrf);
         }
         // TODO: Generate messages for missing fractions.
@@ -360,6 +363,9 @@
 
             int year = Math.min(epoch[0], epoch[1]);
 
+            String period = Integer.toString(epoch[0]) + " - " +
+                Integer.toString(epoch[1]);
+
             Sum sum = new Sum();
 
             for (GrainFraction gf: GRAIN_FRACTIONS) {
@@ -375,7 +381,7 @@
                 }
                 transformT2M3(sd, year, result);
                 SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result);
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period);
                 sldr.addFraction(sldrf);
             }
         }
diff -r bbad52b073a4 -r fae48b3c09d1 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Mon Aug 25 19:58:00 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Mon Aug 25 19:59:14 2014 +0200
@@ -17,16 +17,20 @@
 
     public static class Fraction implements Serializable {
         private String      name;
-        private String      unit;
+        /* Period is the validity of the result. It is either a single
+         * year or a range of years (epoch). As this is only used for
+         * presentation purposes the type is a string so that years
+         * and epochs need not be handled differently.*/
+        private String      period;
         private double [][] data;
 
         public Fraction() {
         }
 
-        public Fraction(String name, double [][] data) {
+        public Fraction(String name, double [][] data, String period) {
             this.name = name;
             this.data = data;
-            this.unit = "ta"; // TODO take from calculation
+            this.period = period;
         }
 
         public String getName() {
@@ -45,12 +49,12 @@
             this.data = data;
         }
 
-        public String getUnit() {
-            return unit;
+        public void setPeriod(String period) {
+            this.period = period;
         }
 
-        public void setUnit(String unit) {
-            this.unit = unit;
+        public String getPeriod() {
+            return period;
         }
 
     } // class Fraction


More information about the Dive4Elements-commits mailing list