Mercurial > dive4elements > river
view 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 |
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.bundu.bezugswst; import java.util.Date; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.access.BedQualityAccess; import org.dive4elements.river.artifacts.bundu.BUNDUArtifact; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.Calculation.Problem; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation; import org.dive4elements.river.artifacts.model.minfo.BedQualityResult; import org.dive4elements.river.artifacts.model.minfo.BedQualityResultValue; import org.dive4elements.river.model.River; /** * Calculator for bed quality parameters in a km range and time period, wrapping the minfo BedQualityCalculation * * @author Matthias Schäfer * */ public class BedQualityCalculator { private final CallContext context; private final BUNDUArtifact bundu; public BedQualityCalculator(final CallContext context, final BUNDUArtifact bundu) { this.context = context; this.bundu = bundu; } /** * Calculates the river bed sublayer densities for an array of kms and a time period of measurements */ public double[][] execute(final Calculation problems, final River river, final double[] kms, final Date startDay, final Date endDay) { final BedQualityCalculation bqCalc = new BedQualityCalculation(); final BedQualityAccess access = createBqAccess(kms[0], kms[kms.length - 1], startDay, endDay); final CalculationResult bqCalcResult = bqCalc.calculate(access); if (bqCalcResult.getReport().getProblems() != null) { for (final Problem problem : bqCalcResult.getReport().getProblems()) problems.addProblem(problem); } final BedQualityResult[] results = (BedQualityResult[]) bqCalcResult.getData(); final BedQualityResult result = results[0]; final BedQualityResultValue bqResValue = result.getValue("density", "sublayer"); return bqResValue.getDataInterpolated(kms); } /** * Creates an access object for the bed quality calculation */ private BedQualityAccess createBqAccess(final double fromKm, final double toKm, final Date startDay, final Date endDay) { final BunduMinfoArtifactWrapper minfo = new BunduMinfoArtifactWrapper(this.bundu, startDay, endDay); return new BedQualityAccess(minfo, this.context); } }