[PATCH] Sediment load: take arguments from sediment access

Wald Commits scm-commit at wald.intevation.org
Fri Jul 18 11:16:54 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1405675010 -7200
# Node ID 1dae69eff79dd23ab0af8bfd9ec76573855edcea
# Parent  9dce39cffab3d64c11e7d00653a9b79fbee88577
Sediment load: take arguments from sediment access.

diff -r 9dce39cffab3 -r 1dae69eff79d 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	Fri Jul 18 11:05:34 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Fri Jul 18 11:16:50 2014 +0200
@@ -82,7 +82,7 @@
 
     public static final class Sum implements Value.Visitor {
 
-        private int n;
+        private int    n;
         private double sum;
         private double scale;
 
@@ -118,17 +118,70 @@
     } // class Aggregate
 
 
+    private String   river;
+    private String   yearEpoch;
+    private String   unit;
+    private int [][] epoch;
+    private int []   period;
+    private double   from;
+    private double   to;
+
+
     public SedimentLoadDataCalculation() {
     }
 
     public CalculationResult calculate(SedimentLoadAccess access) {
         log.info("SedimentLoadDataCalculation.calculate");
+
+        String river     = access.getRiverName();
+        String yearEpoch = access.getYearEpoch();
+        String unit      = access.getUnit();
+
+        int [] period  = null;
+        int [][] epoch = null;
+
+        double from = access.getUpperKM();
+        double to   = access.getLowerKM();
+
+        if (yearEpoch.equals("year")) {
+            period = access.getPeriod();
+        }
+        else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) {
+            epoch = access.getEpochs();
+        }
+        else {
+            addProblem("minfo.missing.year_epoch");
+        }
+
+        if (river == null) {
+            // TODO: i18n
+            addProblem("minfo.missing.river");
+        }
+
+        if (period == null && epoch == null) {
+            addProblem("minfo.missing.time");
+        }
+
+        if (!hasProblems()) {
+            this.river     = river;
+            this.yearEpoch = yearEpoch;
+            this.unit      = unit;
+            this.period    = period;
+            this.epoch     = epoch;
+            this.from      = from;
+            this.to        = to;
+            return internalCalculate();
+        }
+
+        return new CalculationResult();
+    }
+
+    private CalculationResult internalCalculate() {
         // TODO: Implement me!
-
         return null;
     }
 
-    private static double sum(double [] values) {
+    private static final double sum(double [] values) {
         double sum = 0.0;
         for (double value: values) {
             sum += value;
@@ -138,8 +191,6 @@
 
     public double[][] sum(
         SedimentLoadData sld,
-        double           from,
-        double           to,
         int []           grainFractions,
         Value.Filter     filter,
         Sum              sum,


More information about the Dive4Elements-commits mailing list