Mercurial > dive4elements > river
changeset 8131:fae48b3c09d1
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.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 25 Aug 2014 19:59:14 +0200 |
parents | bbad52b073a4 |
children | 58e3fed51e9e |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java |
diffstat | 2 files changed, 20 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }
--- 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