Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/WaterlevelValuesFinder.java @ 8946:5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
author | gernotbelger |
---|---|
date | Tue, 13 Mar 2018 18:49:33 +0100 |
parents | |
children | 45f1ad66560e |
comparison
equal
deleted
inserted
replaced
8945:4a6b6a3c279c | 8946:5d5d482da3e9 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.tkhcalculation; | |
11 | |
12 import org.apache.commons.math.ArgumentOutsideDomainException; | |
13 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; | |
14 import org.dive4elements.river.artifacts.model.WKms; | |
15 import org.dive4elements.river.utils.DoubleUtil; | |
16 | |
17 /** | |
18 * Abstraction for access to waterlevels by station. | |
19 * | |
20 * @author Gernot Belger | |
21 */ | |
22 public class WaterlevelValuesFinder { | |
23 | |
24 public static WaterlevelValuesFinder fromKms(final WKms wkms) { | |
25 return new WaterlevelValuesFinder(wkms); | |
26 } | |
27 | |
28 private final PolynomialSplineFunction wstInterpolator; | |
29 | |
30 private WaterlevelValuesFinder(final WKms wkms) { | |
31 this.wstInterpolator = DoubleUtil.getLinearInterpolator(wkms.allKms(), wkms.allWs()); | |
32 } | |
33 | |
34 public double getWaterlevel(final double km) { | |
35 try { | |
36 return this.wstInterpolator.value(km); | |
37 } | |
38 catch (final ArgumentOutsideDomainException e) { | |
39 e.printStackTrace(); | |
40 return Double.NaN; | |
41 } | |
42 } | |
43 } |