comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java @ 8946:5d5d482da3e9

Implementing SINFO - FlowDepthMinMax calculation
author gernotbelger
date Tue, 13 Mar 2018 18:49:33 +0100
parents d9dbf0b74bc2
children 2ed3824a3d53
comparison
equal deleted inserted replaced
8945:4a6b6a3c279c 8946:5d5d482da3e9
8 * documentation coming with Dive4Elements River for details. 8 * documentation coming with Dive4Elements River for details.
9 */ 9 */
10 10
11 package org.dive4elements.river.artifacts.sinfo.flowdepth; 11 package org.dive4elements.river.artifacts.sinfo.flowdepth;
12 12
13 import java.util.ArrayList;
14 import java.util.Collection; 13 import java.util.Collection;
15 import java.util.Collections; 14 import java.util.Collections;
16 15
17 import org.apache.commons.lang.math.DoubleRange; 16 import org.apache.commons.lang.math.DoubleRange;
18 import org.dive4elements.river.artifacts.access.RangeAccess; 17 import org.dive4elements.river.artifacts.access.RangeAccess;
19 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; 18 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
20 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; 19 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
21 import org.dive4elements.river.backend.utils.StringUtil;
22 20
23 /** 21 /**
24 * Access to the flow depth calculation type specific SInfo artifact data. 22 * Access to the flow depth calculation type specific SInfo artifact data.
25 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent 23 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
26 * reference to the artifact instance. 24 * reference to the artifact instance.
27 * Hence we do NOT cache any data. 25 * Hence we do NOT cache any data.
28 * 26 *
29 * @author Gernot Belger 27 * @author Gernot Belger
30 */ 28 */
31 final class FlowDepthAccess extends RangeAccess { 29 final class FlowDepthAccess extends RangeAccess {
32 public static class DifferencesPair {
33 private final String wstId;
34 private final String soundingId;
35 30
36 public DifferencesPair(final String wstId, final String soundingId) { 31 private static final String FIELD_DIFFIDS = "diffids";
37 this.wstId = wstId;
38 this.soundingId = soundingId;
39 }
40
41 public String getWstId() {
42 return this.wstId;
43 }
44
45 public String getSoundingId() {
46 return this.soundingId;
47 }
48 }
49 32
50 private static final String FIELD_USE_TKH = "use_transport_bodies"; //$NON-NLS-1$ 33 private static final String FIELD_USE_TKH = "use_transport_bodies"; //$NON-NLS-1$
51 34
52 public FlowDepthAccess(final SINFOArtifact artifact) { 35 public FlowDepthAccess(final SINFOArtifact artifact) {
53 super(artifact); 36 super(artifact);
66 public boolean isUseTransportBodies() { 49 public boolean isUseTransportBodies() {
67 final Boolean useTkh = this.artifact.getDataAsBoolean(FIELD_USE_TKH); 50 final Boolean useTkh = this.artifact.getDataAsBoolean(FIELD_USE_TKH);
68 return useTkh == null ? false : useTkh; 51 return useTkh == null ? false : useTkh;
69 } 52 }
70 53
71 public Collection<DifferencesPair> getDifferencePairs() { 54 public Collection<WstSoundingIdPair> getDifferencePairs() {
72 55
73 final Collection<DifferencesPair> diffPairs = new ArrayList<>(); 56 final String diffids = getString(FIELD_DIFFIDS);
74
75 final String diffids = super.getString("diffids");
76 if (diffids == null) { 57 if (diffids == null) {
77 // Should never happen as this is handled by the ui 58 // Should never happen as this is handled by the ui
78 return Collections.emptyList(); 59 return Collections.emptyList();
79 } 60 }
80 61
81 // FIXME: this way of parsing the datacage-ids is repeated all over flys! 62 final Collection<WstSoundingIdPair> pairs = WstSoundingIdPair.parsePairs(diffids);
82 final String datas[] = diffids.split("#"); 63 return pairs;
83 for (int i = 0; i < datas.length; i += 2) {
84 final String leftId = StringUtil.unbracket(datas[i]);
85 final String rightId = StringUtil.unbracket(datas[i + 1]);
86
87 diffPairs.add(new DifferencesPair(leftId, rightId));
88 }
89
90 return Collections.unmodifiableCollection(diffPairs);
91 } 64 }
92 } 65 }

http://dive4elements.wald.intevation.org