view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/WaterlevelValuesFinder.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 45f1ad66560e
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