comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8052:1dae69eff79d

Sediment load: take arguments from sediment access.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 18 Jul 2014 11:16:50 +0200
parents 9e79e384aa8b
children 72760ca2fc2b
comparison
equal deleted inserted replaced
8051:9dce39cffab3 8052:1dae69eff79d
80 SedimentLoadData.GF_SUSP_SEDIMENT 80 SedimentLoadData.GF_SUSP_SEDIMENT
81 }; 81 };
82 82
83 public static final class Sum implements Value.Visitor { 83 public static final class Sum implements Value.Visitor {
84 84
85 private int n; 85 private int n;
86 private double sum; 86 private double sum;
87 private double scale; 87 private double scale;
88 88
89 public Sum() { 89 public Sum() {
90 } 90 }
116 ++n; 116 ++n;
117 } 117 }
118 } // class Aggregate 118 } // class Aggregate
119 119
120 120
121 private String river;
122 private String yearEpoch;
123 private String unit;
124 private int [][] epoch;
125 private int [] period;
126 private double from;
127 private double to;
128
129
121 public SedimentLoadDataCalculation() { 130 public SedimentLoadDataCalculation() {
122 } 131 }
123 132
124 public CalculationResult calculate(SedimentLoadAccess access) { 133 public CalculationResult calculate(SedimentLoadAccess access) {
125 log.info("SedimentLoadDataCalculation.calculate"); 134 log.info("SedimentLoadDataCalculation.calculate");
135
136 String river = access.getRiverName();
137 String yearEpoch = access.getYearEpoch();
138 String unit = access.getUnit();
139
140 int [] period = null;
141 int [][] epoch = null;
142
143 double from = access.getUpperKM();
144 double to = access.getLowerKM();
145
146 if (yearEpoch.equals("year")) {
147 period = access.getPeriod();
148 }
149 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) {
150 epoch = access.getEpochs();
151 }
152 else {
153 addProblem("minfo.missing.year_epoch");
154 }
155
156 if (river == null) {
157 // TODO: i18n
158 addProblem("minfo.missing.river");
159 }
160
161 if (period == null && epoch == null) {
162 addProblem("minfo.missing.time");
163 }
164
165 if (!hasProblems()) {
166 this.river = river;
167 this.yearEpoch = yearEpoch;
168 this.unit = unit;
169 this.period = period;
170 this.epoch = epoch;
171 this.from = from;
172 this.to = to;
173 return internalCalculate();
174 }
175
176 return new CalculationResult();
177 }
178
179 private CalculationResult internalCalculate() {
126 // TODO: Implement me! 180 // TODO: Implement me!
127
128 return null; 181 return null;
129 } 182 }
130 183
131 private static double sum(double [] values) { 184 private static final double sum(double [] values) {
132 double sum = 0.0; 185 double sum = 0.0;
133 for (double value: values) { 186 for (double value: values) {
134 sum += value; 187 sum += value;
135 } 188 }
136 return sum; 189 return sum;
137 } 190 }
138 191
139 public double[][] sum( 192 public double[][] sum(
140 SedimentLoadData sld, 193 SedimentLoadData sld,
141 double from,
142 double to,
143 int [] grainFractions, 194 int [] grainFractions,
144 Value.Filter filter, 195 Value.Filter filter,
145 Sum sum, 196 Sum sum,
146 boolean isKMUp, 197 boolean isKMUp,
147 Set<Integer> missingFractions 198 Set<Integer> missingFractions

http://dive4elements.wald.intevation.org