Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/access/ComputationRangeAccess.java @ 8914:e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
author | gernotbelger |
---|---|
date | Tue, 27 Feb 2018 18:06:52 +0100 |
parents | |
children | 8cc192731c7d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/ComputationRangeAccess.java Tue Feb 27 18:06:52 2018 +0100 @@ -0,0 +1,64 @@ +/** 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.access; + +import org.dive4elements.artifactdatabase.data.StateData; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.states.ComputationRangeState; +import org.dive4elements.river.utils.DoubleUtil; + +/** + * Access to data handled by {@link ComputationRangeState}. + * + * @author Gernot Belger + */ +public class ComputationRangeAccess extends RangeAccess { + + public ComputationRangeAccess(final D4EArtifact artifact) { + super(artifact); + } + + public double[] getFromToStep() { + + if (!isRange()) + return null; + + final double[] fromTo = getKmRange(); + + if (fromTo == null) + return null; + + final StateData dStep = getArtifact().getData("ld_step"); + if (dStep == null) + return null; + + final double[] result = new double[3]; + result[0] = fromTo[0]; + result[1] = fromTo[1]; + + try { + final String dStepValue = (String) dStep.getValue(); + result[2] = DoubleUtil.round(Double.parseDouble(dStepValue) / 1000d); + return result; + } + catch (final NumberFormatException nfe) { + nfe.printStackTrace(); + return null; + } + } + + public double[] getKms() { + + if (isRange()) + return getKmSteps(); + + return getLocations(); + } +} \ No newline at end of file