Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
8913:924cd9943337 | 8914:e3519c3e7a0a |
---|---|
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.access; | |
11 | |
12 import org.dive4elements.artifactdatabase.data.StateData; | |
13 import org.dive4elements.river.artifacts.D4EArtifact; | |
14 import org.dive4elements.river.artifacts.states.ComputationRangeState; | |
15 import org.dive4elements.river.utils.DoubleUtil; | |
16 | |
17 /** | |
18 * Access to data handled by {@link ComputationRangeState}. | |
19 * | |
20 * @author Gernot Belger | |
21 */ | |
22 public class ComputationRangeAccess extends RangeAccess { | |
23 | |
24 public ComputationRangeAccess(final D4EArtifact artifact) { | |
25 super(artifact); | |
26 } | |
27 | |
28 public double[] getFromToStep() { | |
29 | |
30 if (!isRange()) | |
31 return null; | |
32 | |
33 final double[] fromTo = getKmRange(); | |
34 | |
35 if (fromTo == null) | |
36 return null; | |
37 | |
38 final StateData dStep = getArtifact().getData("ld_step"); | |
39 if (dStep == null) | |
40 return null; | |
41 | |
42 final double[] result = new double[3]; | |
43 result[0] = fromTo[0]; | |
44 result[1] = fromTo[1]; | |
45 | |
46 try { | |
47 final String dStepValue = (String) dStep.getValue(); | |
48 result[2] = DoubleUtil.round(Double.parseDouble(dStepValue) / 1000d); | |
49 return result; | |
50 } | |
51 catch (final NumberFormatException nfe) { | |
52 nfe.printStackTrace(); | |
53 return null; | |
54 } | |
55 } | |
56 | |
57 public double[] getKms() { | |
58 | |
59 if (isRange()) | |
60 return getKmSteps(); | |
61 | |
62 return getLocations(); | |
63 } | |
64 } |