Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 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 | 640fffb0ad60 |
comparison
equal
deleted
inserted
replaced
8067:6d24ba2ac964 | 8068:9ecd6267323b |
---|---|
247 Sum sum = new Sum(); | 247 Sum sum = new Sum(); |
248 | 248 |
249 SedimentDensity sd = getSedimentDensity(); | 249 SedimentDensity sd = getSedimentDensity(); |
250 | 250 |
251 for (int year: years) { | 251 for (int year: years) { |
252 Value.Filter filter = new And() | 252 Value.Filter filter = new And(notEpochs) |
253 .add(notEpochs) | |
254 .add(new TimeRangeIntersects(year)); | 253 .add(new TimeRangeIntersects(year)); |
255 | 254 |
256 for (GrainFraction gf: GRAIN_FRACTIONS) { | 255 for (GrainFraction gf: GRAIN_FRACTIONS) { |
257 double [][] result = sum( | 256 double [][] result = sum( |
258 sld, gf.getGrainFractions(), filter, sum, isKmUp, | 257 sld, gf.getGrainFractions(), filter, sum, isKmUp, |
301 | 300 |
302 int min = Math.min(epoch[0], epoch[1]); | 301 int min = Math.min(epoch[0], epoch[1]); |
303 int max = Math.max(epoch[0], epoch[1]); | 302 int max = Math.max(epoch[0], epoch[1]); |
304 | 303 |
305 for (int year = min; year <= max; ++year) { | 304 for (int year = min; year <= max; ++year) { |
306 Value.Filter filter = new And() | 305 Value.Filter filter = new And(notEpochs) |
307 .add(notEpochs) | |
308 .add(new TimeRangeIntersects(year)); | 306 .add(new TimeRangeIntersects(year)); |
309 | 307 |
310 Sum sum = new Sum(); | 308 Sum sum = new Sum(); |
311 | 309 |
312 for (GrainFraction gf: GRAIN_FRACTIONS) { | 310 for (GrainFraction gf: GRAIN_FRACTIONS) { |
344 return error("minfo.sediment.load.no.data"); | 342 return error("minfo.sediment.load.no.data"); |
345 } | 343 } |
346 | 344 |
347 SedimentLoadDataResult sldr = new SedimentLoadDataResult(); | 345 SedimentLoadDataResult sldr = new SedimentLoadDataResult(); |
348 | 346 |
347 SedimentDensity sd = getSedimentDensity(); | |
348 | |
349 boolean isKmUp = isKmUp(); | 349 boolean isKmUp = isKmUp(); |
350 Set<Integer> missingFractions = new TreeSet<Integer>(); | 350 Set<Integer> missingFractions = new TreeSet<Integer>(); |
351 | 351 |
352 for (int [] epoch: epochs) { | 352 for (int [] epoch: epochs) { |
353 Value.Filter filter = new And() | 353 Value.Filter filter = new And(IsOfficial.INSTANCE) |
354 .add(IsOfficial.INSTANCE) | |
355 .add(new TimeRangeIntersects(epoch[0], epoch[1])); | 354 .add(new TimeRangeIntersects(epoch[0], epoch[1])); |
355 | |
356 int year = Math.min(epoch[0], epoch[1]); | |
356 | 357 |
357 Sum sum = new Sum(); | 358 Sum sum = new Sum(); |
358 | 359 |
359 for (GrainFraction gf: GRAIN_FRACTIONS) { | 360 for (GrainFraction gf: GRAIN_FRACTIONS) { |
360 double [][] result = sum( | 361 double [][] result = sum( |
365 // TODO: resolve i18n | 366 // TODO: resolve i18n |
366 addProblem("minfo.sediment.load.no.fractions", | 367 addProblem("minfo.sediment.load.no.fractions", |
367 gf.getDescription()); | 368 gf.getDescription()); |
368 continue; | 369 continue; |
369 } | 370 } |
370 // TODO: Optionally transform units. | 371 transformT2M3(sd, year, result); |
371 SedimentLoadDataResult.Fraction sldrf = | 372 SedimentLoadDataResult.Fraction sldrf = |
372 new SedimentLoadDataResult.Fraction(gf.getDescription(), result); | 373 new SedimentLoadDataResult.Fraction(gf.getDescription(), result); |
373 sldr.addFraction(sldrf); | 374 sldr.addFraction(sldrf); |
374 } | 375 } |
375 } | 376 } |
376 // TODO: Generate messages for missing fractions. | 377 // TODO: Generate messages for missing fractions. |
377 return new CalculationResult(sldr, this); | 378 return new CalculationResult(sldr, this); |
378 } | 379 } |
379 | 380 |
380 /** Figure out flow direction of river. */ | 381 /** Figure out flow direction of river. */ |
381 private boolean isKmUp() { | 382 private final boolean isKmUp() { |
382 River r = RiverFactory.getRiver(river); | 383 River r = RiverFactory.getRiver(river); |
383 if (r == null) { | 384 if (r == null) { |
384 addProblem("minfo.missing.river"); | 385 addProblem("minfo.missing.river"); |
385 return true; | 386 return true; |
386 } | 387 } |