view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java @ 9145:e6b63b2b41b9

sinfo.flood_duration pdf, csv, ui
author gernotbelger
date Tue, 12 Jun 2018 10:23:23 +0200
parents
children 23945061daec
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.sinfo.flood_duration;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.commons.lang.math.DoubleRange;
import org.dive4elements.river.artifacts.common.GeneralResultType;
import org.dive4elements.river.artifacts.common.ResultRow;
import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider;
import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
import org.dive4elements.river.artifacts.sinfo.util.WstInfo;

/**
 * @author Gernot Belger
 */
final class FloodDurationCalculator {

    private final Collection<ResultRow> rows = new ArrayList<>();

    private final RiverInfoProvider riverInfoProvider;

    public FloodDurationCalculator(final RiverInfoProvider riverInfoProvider) {

        this.riverInfoProvider = riverInfoProvider;

    }

    public FloodDurationCalculationResult execute(final String label, final WstInfo wstInfo, final DoubleRange calcRange) {

        calculateResultRow(8888.888);
        calculateResultRow(99);
        calculateResultRow(77);
        return new FloodDurationCalculationResult(label, wstInfo, this.rows, 4);
    }

    private void calculateResultRow(final double station) {

        final ResultRow row = ResultRow.create();

        // REMARK: access the location once only during calculation
        final String location = this.riverInfoProvider.getLocation(station);
        row.putValue(GeneralResultType.station, station);
        row.putValue(SInfoResultType.riverside, "todo:getRiverside");
        row.putValue(SInfoResultType.inundationduration, 44);
        row.putValue(SInfoResultType.inundationdurationq, 444);
        row.putValue(SInfoResultType.infrastructureHeight, 55);
        row.putValue(SInfoResultType.infrastructuretype, "todo_get_infrastructureType");

        // custom type; each entry produces 4 Columns
        final List<DurationWaterlevel> rowWsps = new ArrayList<>();

        rowWsps.add(new DurationWaterlevel(222, 30, 666, "1. Test"));
        rowWsps.add(new DurationWaterlevel(111, 40, 555, "2. Test"));
        rowWsps.add(new DurationWaterlevel(123, 333, 33, "3. Test"));
        rowWsps.add(new DurationWaterlevel(444, 452, 55, "4. Test"));
        row.putValue(SInfoResultType.customMultiRowColWaterlevel, rowWsps);

        row.putValue(SInfoResultType.gaugeLabel, "todo:getReferencedGauge");
        row.putValue(SInfoResultType.location, "location");

        this.rows.add(row);
    }
}

http://dive4elements.wald.intevation.org