view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java @ 8980:b194fa64506a

SINFO - show results themes according to spec, either raw data or floating mean values. Some improvements to error handling and handling of empty results.
author gernotbelger
date Thu, 05 Apr 2018 18:30:34 +0200
parents 322b0e6298ea
children 8ae7137b67d7
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.flowdepth;

import org.dive4elements.river.artifacts.model.Calculation;

/**
 * @author Gernot Belger
 */
public final class FlowDepthUtils {

    private FlowDepthUtils() {
        throw new UnsupportedOperationException();
    }

    /**
     * Checks the year difference between waterlevels and sounding, and issues a warning if too big.
     *
     * Zeitraum Zeitliche Differenz [a]
     * X ≥ 1998 ± 3
     * 1958 ≤ X < 1998 ± 6
     * 1918 ≤ X < 1958 ± 12
     * X < 1918 ± 25
     */
    public static void checkYearDifference(final String label, final int wstYear, final int soundingYear, final Calculation problems) {

        if (wstYear < 0)
            return;

        final int maxDifference = getMaxDifferenceYears(soundingYear);

        final int difference = Math.abs(soundingYear - wstYear);
        if (difference > maxDifference)
            problems.addProblem("sinfo_calc_flow_depth.warning.year_difference", label, Integer.toString(wstYear), Integer.toString(soundingYear));
    }

    public static int getMaxDifferenceYears(final int year) {

        if (year < 1918)
            return 25;

        if (1918 <= year && year < 1958)
            return 12;

        if (1958 <= year && year < 1998)
            return 6;

        /* >= 1998 */
        return 3;
    }
}

http://dive4elements.wald.intevation.org