view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java @ 9331:127638669052

bundu bezugswst result 2
author gernotbelger
date Fri, 27 Jul 2018 18:49:55 +0200
parents 0a0937f33bb5
children c64de8cc4e97
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.ArrayList;
import java.util.List;

import org.dive4elements.artifacts.CallContext;
import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.bundu.BUNDUArtifact;
import org.dive4elements.river.artifacts.bundu.BunduResultType;
import org.dive4elements.river.artifacts.common.GeneralResultType;
import org.dive4elements.river.artifacts.common.ResultRow;
import org.dive4elements.river.artifacts.model.CalculationResult;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo;
import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
import org.dive4elements.river.model.River;

class BezugswstCalculation {

    // private static Logger log = Logger.getLogger(FloodDurationCalculation.class);

    private final CallContext context;

    public BezugswstCalculation(final CallContext context) {
        this.context = context;
    }

    public CalculationResult calculate(final BUNDUArtifact bunduartifact) {

        final String user = CalculationUtils.findArtifactUser(this.context, bunduartifact);
        final CallMeta m = this.context.getMeta();
        /* access input data */
        final BunduAccess access = new BunduAccess(bunduartifact);

        final River river = access.getRiver();
        final RiverInfo riverInfo = new RiverInfo(river);
        final String calcModeLabel = Resources.getMsg(m, "bundu_bezugswst");
        final BezugswstCalculationResults results = new BezugswstCalculationResults(calcModeLabel, user, riverInfo, access.getRange());

        // TODO: get wst, sounding for river
        final WstInfo wstInfo = null;
        final BedHeightInfo sounding = null;
        // final int wspYear = waterlevel.getYear();
        // final WstInfo wstInfo = new WstInfo(wspLabel, wspYear, riverInfo.getReferenceGauge());
        final String function = access.getFunction();
        final boolean preprocessing = access.getPreprocessing();// nullpointer dürfen nicht entstehen; Fehler läge woanders
        final int startYear = access.getStartYear();
        final int endYear = access.getBezugsJahr();
        final Integer ud = access.getUd();
        final double[] qs = access.getQs();
        final Double missingVolFrom = access.getMissingVolFrom();
        final Double missingVolTo = access.getMissingVolTo();

        final List<ResultRow> list = new ArrayList<>();
        final ResultRow row = ResultRow.create();
        row.putValue(GeneralResultType.station, 666.666);
        row.putValue(BunduResultType.bezugswst, 22.15);
        row.putValue(GeneralResultType.dischargeQwithUnit, 77.666);
        row.putValue(GeneralResultType.waterlevelLabel, "GLQ");
        row.putValue(GeneralResultType.gaugeLabel, "Bonn");
        row.putValue(GeneralResultType.location, "keine Lage");
        list.add(row);

        final BezugswstMainCalculationResult result = new BezugswstMainCalculationResult("label? was fürn label?", list, sounding, wstInfo, function,
                preprocessing, startYear, endYear, ud, qs, missingVolFrom, missingVolTo);
        results.addResult(result, null);

        // missing volume calculation
        if (access.getMissingVolFrom() != null) {
            /// FIRST RESULT
            final List<ResultRow> listResult1 = new ArrayList<>();
            final ResultRow rowResult1 = ResultRow.create();
            rowResult1.putValue(BunduResultType.bezugswst, 45.15);
            rowResult1.putValue(GeneralResultType.dischargeQwithUnit, 890);
            rowResult1.putValue(GeneralResultType.waterlevelLabel, "GLQ");
            rowResult1.putValue(GeneralResultType.gaugeLabel, "Bonn");

            rowResult1.putValue(BunduResultType.sounding, "NIEDERRHEIN_QP-2002");
            rowResult1.putValue(BunduResultType.channelLowerEdge, 42.65);
            rowResult1.putValue(BunduResultType.channelMinDepth, 2.5);
            rowResult1.putValue(BunduResultType.hasMissingDepth, Resources.getMsg(m, "true"));
            rowResult1.putValue(BunduResultType.missVolume, 2250);
            rowResult1.putValue(BunduResultType.missMass, 3897);
            rowResult1.putValue(BunduResultType.excavationVolume, 2475);
            rowResult1.putValue(BunduResultType.excavationCosts, 999.99);
            rowResult1.putValue(BunduResultType.channelWidth, 150);
            rowResult1.putValue(BunduResultType.density, 1732);

            rowResult1.putValue(GeneralResultType.location, "Spitzenlage");
            listResult1.add(rowResult1);

            final BezugswstMissVolCalculationResult1 r1 = new BezugswstMissVolCalculationResult1(
                    Resources.getMsg(m, "bundu.export.csv.title.bezugswst.result1"), listResult1);
            results.addResult(r1, null);

            // SECOND RESULT
            final List<ResultRow> listResult2 = new ArrayList<>();
            final ResultRow rowResult2 = ResultRow.create();

            rowResult2.putValue(GeneralResultType.station, 890);
            final List<String> fieldValues = new ArrayList<>();
            fieldValues.add("444 [m³] / 765 [t]");
            fieldValues.add("4.444 [m³] / 1.765 [t]");
            fieldValues.add("444 [m³] / 765 [t]");
            fieldValues.add("");
            fieldValues.add("");
            fieldValues.add("");
            fieldValues.add("");
            fieldValues.add("");
            fieldValues.add("");
            fieldValues.add("444 [m³] / 765 [t]");
            rowResult2.putValue(BunduResultType.fields, fieldValues);
            rowResult2.putValue(BunduResultType.meanBedheight, "9.444 [m³] / 8.765 [t]");

            listResult2.add(rowResult2);

            final BezugswstMissVolCalculationResult2 r2 = new BezugswstMissVolCalculationResult2(
                    Resources.getMsg(m, "bundu.export.csv.title.bezugswst.result2"), listResult2);
            results.addResult(r2, null);

        }

        return new CalculationResult(results, null);// problems);
    }

    /**
     * Calculates one W-MSH differences pair.
     *
     * @param infoProvider
     */

}

http://dive4elements.wald.intevation.org