Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8145:52504fc2cd58
Calculate all single years in given interval but only once.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 27 Aug 2014 15:01:54 +0200 |
parents | fae48b3c09d1 |
children | 363b82ecf29f |
comparison
equal
deleted
inserted
replaced
8144:8eeb4b717dca | 8145:52504fc2cd58 |
---|---|
251 | 251 |
252 Sum sum = new Sum(); | 252 Sum sum = new Sum(); |
253 | 253 |
254 SedimentDensity sd = getSedimentDensity(); | 254 SedimentDensity sd = getSedimentDensity(); |
255 | 255 |
256 for (int year: years) { | 256 int min = Math.min(years[0], years[1]); |
257 int max = Math.max(years[0], years[1]); | |
258 | |
259 for (int year = min; year <= max; ++year) { | |
257 Value.Filter filter = new And(notEpochs) | 260 Value.Filter filter = new And(notEpochs) |
258 .add(new TimeRangeIntersects(year)); | 261 .add(new TimeRangeIntersects(year)); |
259 String period = Integer.toString(year); | 262 String period = Integer.toString(year); |
260 | 263 |
261 for (GrainFraction gf: GRAIN_FRACTIONS) { | 264 for (GrainFraction gf: GRAIN_FRACTIONS) { |
275 SedimentLoadDataResult.Fraction sldrf = | 278 SedimentLoadDataResult.Fraction sldrf = |
276 new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period); | 279 new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period); |
277 | 280 |
278 sldr.addFraction(sldrf); | 281 sldr.addFraction(sldrf); |
279 } | 282 } |
283 | |
284 // Do not give single year twice | |
285 if (min == max) break; | |
280 } | 286 } |
281 // TODO: Generate messages for missing fractions. | 287 // TODO: Generate messages for missing fractions. |
282 return new CalculationResult(sldr, this); | 288 return new CalculationResult(sldr, this); |
283 } | 289 } |
284 | 290 |