comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxAccess.java @ 8993:0adc6d04de95

SInfo - FlowDepthMinMax: choosing bed heights, not bed height min and max separately
author gernotbelger
date Wed, 11 Apr 2018 14:09:13 +0200
parents 5d5d482da3e9
children 611a523fc42f
comparison
equal deleted inserted replaced
8981:2e27061d9a93 8993:0adc6d04de95
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.flowdepthminmax; 11 package org.dive4elements.river.artifacts.sinfo.flowdepthminmax;
12 12
13 import java.util.ArrayList;
14 import java.util.Collection; 13 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.List;
17 14
18 import org.apache.commons.lang.math.DoubleRange; 15 import org.apache.commons.lang.math.DoubleRange;
19 import org.dive4elements.river.artifacts.access.RangeAccess; 16 import org.dive4elements.river.artifacts.access.RangeAccess;
20 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; 17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
21 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; 18 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
29 * 26 *
30 * @author Gernot Belger 27 * @author Gernot Belger
31 */ 28 */
32 final class FlowDepthMinMaxAccess extends RangeAccess { 29 final class FlowDepthMinMaxAccess extends RangeAccess {
33 30
34 public static class MinMaxIdPair {
35
36 private final String wstId;
37
38 private final String minSoundingId;
39
40 private final String maxSoundingId;
41
42 public MinMaxIdPair(final String wstId, final String minSoundingId, final String maxSoundingId) {
43 this.wstId = wstId;
44 this.minSoundingId = minSoundingId;
45 this.maxSoundingId = maxSoundingId;
46 }
47
48 public String getWstId() {
49 return this.wstId;
50 }
51
52 public String getMinSoundingId() {
53 return this.minSoundingId;
54 }
55
56 public String getMaxSoundingId() {
57 return this.maxSoundingId;
58 }
59 }
60
61 private static final String FIELD_DIFFIDS = "diffids"; 31 private static final String FIELD_DIFFIDS = "diffids";
62 32
63 public FlowDepthMinMaxAccess(final SINFOArtifact artifact) { 33 public FlowDepthMinMaxAccess(final SINFOArtifact artifact) {
64 super(artifact); 34 super(artifact);
65 35
72 final double from = getFrom(); 42 final double from = getFrom();
73 final double to = getTo(); 43 final double to = getTo();
74 return new DoubleRange(from, to); 44 return new DoubleRange(from, to);
75 } 45 }
76 46
77 public Collection<MinMaxIdPair> getMinMaxPairs() { 47 public Collection<WstSoundingIdPair> getMinMaxPairs() {
78
79 final String diffids = getString(FIELD_DIFFIDS); 48 final String diffids = getString(FIELD_DIFFIDS);
80 49 return WstSoundingIdPair.parsePairs(diffids);
81 /* fetch the raw configured pairs */
82 final List<WstSoundingIdPair> diffPairs = WstSoundingIdPair.parsePairs(diffids);
83
84 /* now sort eleemnts into pairs of TL/KL */
85 // FIXME: use sounding-ids to determine how pairs fit together
86 // or, let the ui already enforce it somehow
87
88 final List<MinMaxIdPair> minMaxPairs = new ArrayList<>(diffPairs.size());
89 // FIXME: at the moment, we simply pair by order
90 for (int i = 0; i < diffPairs.size(); i++) {
91
92 final WstSoundingIdPair minPair = diffPairs.get(i);
93
94 if (i < diffPairs.size() - 1) {
95 final WstSoundingIdPair maxPair = diffPairs.get(i + 1);
96 minMaxPairs.add(new MinMaxIdPair(minPair.getWstId(), minPair.getSoundingId(), maxPair.getSoundingId()));
97 i++;
98 } else {
99 minMaxPairs.add(new MinMaxIdPair(minPair.getWstId(), minPair.getSoundingId(), null));
100 }
101 }
102
103 return Collections.unmodifiableCollection(minMaxPairs);
104 } 50 }
105 } 51 }

http://dive4elements.wald.intevation.org