comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BedQualityCalculator.java @ 9450:7e1fb8d0cb0d

Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
author mschaefer
date Wed, 22 Aug 2018 19:12:51 +0200
parents
children fd6621f47a72
comparison
equal deleted inserted replaced
9449:ba3ad54edbae 9450:7e1fb8d0cb0d
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.artifacts.bundu.bezugswst;
12
13 import java.util.Date;
14
15 import org.dive4elements.artifacts.CallContext;
16 import org.dive4elements.river.artifacts.access.BedQualityAccess;
17 import org.dive4elements.river.artifacts.bundu.BUNDUArtifact;
18 import org.dive4elements.river.artifacts.model.Calculation;
19 import org.dive4elements.river.artifacts.model.Calculation.Problem;
20 import org.dive4elements.river.artifacts.model.CalculationResult;
21 import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation;
22 import org.dive4elements.river.artifacts.model.minfo.BedQualityResult;
23 import org.dive4elements.river.artifacts.model.minfo.BedQualityResultValue;
24 import org.dive4elements.river.model.River;
25
26 /**
27 * Calculator for bed quality parameters in a km range and time period, wrapping the minfo BedQualityCalculation
28 *
29 * @author Matthias Schäfer
30 *
31 */
32 public class BedQualityCalculator {
33
34 private final CallContext context;
35
36 private final BUNDUArtifact bundu;
37
38
39 public BedQualityCalculator(final CallContext context, final BUNDUArtifact bundu) {
40 this.context = context;
41 this.bundu = bundu;
42 }
43
44 /**
45 * Calculates the river bed sublayer densities for an array of kms and a time period of measurements
46 */
47 public double[][] execute(final Calculation problems, final River river, final double[] kms, final Date startDay, final Date endDay) {
48 final BedQualityCalculation bqCalc = new BedQualityCalculation();
49 final BedQualityAccess access = createBqAccess(kms[0], kms[kms.length - 1], startDay, endDay);
50 final CalculationResult bqCalcResult = bqCalc.calculate(access);
51 if (bqCalcResult.getReport().getProblems() != null) {
52 for (final Problem problem : bqCalcResult.getReport().getProblems())
53 problems.addProblem(problem);
54 }
55 final BedQualityResult[] results = (BedQualityResult[]) bqCalcResult.getData();
56 final BedQualityResult result = results[0];
57 final BedQualityResultValue bqResValue = result.getValue("density", "sublayer");
58 return bqResValue.getDataInterpolated(kms);
59 }
60
61 /**
62 * Creates an access object for the bed quality calculation
63 */
64 private BedQualityAccess createBqAccess(final double fromKm, final double toKm, final Date startDay, final Date endDay) {
65 final BunduMinfoArtifactWrapper minfo = new BunduMinfoArtifactWrapper(this.bundu, startDay, endDay);
66 return new BedQualityAccess(minfo, this.context);
67 }
68 }

http://dive4elements.wald.intevation.org