Mercurial > dive4elements > river
changeset 8068:9ecd6267323b
Sediment load: transform units for official epochs, too.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 31 Jul 2014 18:14:22 +0200 |
parents | 6d24ba2ac964 |
children | 86c1ff462fb5 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java |
diffstat | 2 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Thu Jul 31 17:04:41 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Thu Jul 31 18:14:22 2014 +0200 @@ -249,8 +249,7 @@ SedimentDensity sd = getSedimentDensity(); for (int year: years) { - Value.Filter filter = new And() - .add(notEpochs) + Value.Filter filter = new And(notEpochs) .add(new TimeRangeIntersects(year)); for (GrainFraction gf: GRAIN_FRACTIONS) { @@ -303,8 +302,7 @@ int max = Math.max(epoch[0], epoch[1]); for (int year = min; year <= max; ++year) { - Value.Filter filter = new And() - .add(notEpochs) + Value.Filter filter = new And(notEpochs) .add(new TimeRangeIntersects(year)); Sum sum = new Sum(); @@ -346,14 +344,17 @@ SedimentLoadDataResult sldr = new SedimentLoadDataResult(); + SedimentDensity sd = getSedimentDensity(); + boolean isKmUp = isKmUp(); Set<Integer> missingFractions = new TreeSet<Integer>(); for (int [] epoch: epochs) { - Value.Filter filter = new And() - .add(IsOfficial.INSTANCE) + Value.Filter filter = new And(IsOfficial.INSTANCE) .add(new TimeRangeIntersects(epoch[0], epoch[1])); + int year = Math.min(epoch[0], epoch[1]); + Sum sum = new Sum(); for (GrainFraction gf: GRAIN_FRACTIONS) { @@ -367,7 +368,7 @@ gf.getDescription()); continue; } - // TODO: Optionally transform units. + transformT2M3(sd, year, result); SedimentLoadDataResult.Fraction sldrf = new SedimentLoadDataResult.Fraction(gf.getDescription(), result); sldr.addFraction(sldrf); @@ -378,7 +379,7 @@ } /** Figure out flow direction of river. */ - private boolean isKmUp() { + private final boolean isKmUp() { River r = RiverFactory.getRiver(river); if (r == null) { addProblem("minfo.missing.river");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Thu Jul 31 17:04:41 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Thu Jul 31 18:14:22 2014 +0200 @@ -41,6 +41,11 @@ filters = new ArrayList<Filter>(); } + public Composite(Filter filter) { + this(); + add(filter); + } + public Composite add(Filter filter) { filters.add(filter); return this; @@ -52,6 +57,10 @@ public And() { } + public And(Filter filter) { + super(filter); + } + @Override public boolean accept(Value value) { for (Filter filter: filters) { @@ -68,6 +77,10 @@ public Or() { } + public Or(Composite filter) { + super(filter); + } + @Override public boolean accept(Value value) { for (Filter filter: filters) {