view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/WaterlevelValuesFinder.java @ 8964:45f1ad66560e

Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
author gernotbelger
date Thu, 29 Mar 2018 15:48:17 +0200
parents 5d5d482da3e9
children
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.tkhcalculation;

import org.dive4elements.river.artifacts.model.Calculation;
import org.dive4elements.river.artifacts.model.WKms;
import org.dive4elements.river.artifacts.sinfo.util.LinearInterpolator;

/**
 * Abstraction for access to waterlevels by station.
 *
 * @author Gernot Belger
 */
public class WaterlevelValuesFinder {

    private static final double MAX_DSTANCE_KM = 1.0;

    public static WaterlevelValuesFinder fromKms(final Calculation problems, final WKms wkms) {
        return new WaterlevelValuesFinder(problems, wkms);
    }

    private final LinearInterpolator wstInterpolator;

    private WaterlevelValuesFinder(final Calculation problems, final WKms wkms) {
        this.wstInterpolator = LinearInterpolator.create(problems, wkms.allKms(), wkms.allWs(), MAX_DSTANCE_KM);
    }

    public double getWaterlevel(final double km) {
        return this.wstInterpolator.value(km);
    }
}

http://dive4elements.wald.intevation.org