diff 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
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java	Tue Mar 13 09:55:53 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java	Tue Mar 13 18:49:33 2018 +0100
@@ -10,7 +10,6 @@
 
 package org.dive4elements.river.artifacts.sinfo.flowdepth;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 
@@ -18,7 +17,6 @@
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
-import org.dive4elements.river.backend.utils.StringUtil;
 
 /**
  * Access to the flow depth calculation type specific SInfo artifact data.
@@ -29,23 +27,8 @@
  * @author Gernot Belger
  */
 final class FlowDepthAccess extends RangeAccess {
-    public static class DifferencesPair {
-        private final String wstId;
-        private final String soundingId;
 
-        public DifferencesPair(final String wstId, final String soundingId) {
-            this.wstId = wstId;
-            this.soundingId = soundingId;
-        }
-
-        public String getWstId() {
-            return this.wstId;
-        }
-
-        public String getSoundingId() {
-            return this.soundingId;
-        }
-    }
+    private static final String FIELD_DIFFIDS = "diffids";
 
     private static final String FIELD_USE_TKH = "use_transport_bodies"; //$NON-NLS-1$
 
@@ -68,25 +51,15 @@
         return useTkh == null ? false : useTkh;
     }
 
-    public Collection<DifferencesPair> getDifferencePairs() {
+    public Collection<WstSoundingIdPair> getDifferencePairs() {
 
-        final Collection<DifferencesPair> diffPairs = new ArrayList<>();
-
-        final String diffids = super.getString("diffids");
+        final String diffids = getString(FIELD_DIFFIDS);
         if (diffids == null) {
             // Should never happen as this is handled by the ui
             return Collections.emptyList();
         }
 
-        // FIXME: this way of parsing the datacage-ids is repeated all over flys!
-        final String datas[] = diffids.split("#");
-        for (int i = 0; i < datas.length; i += 2) {
-            final String leftId = StringUtil.unbracket(datas[i]);
-            final String rightId = StringUtil.unbracket(datas[i + 1]);
-
-            diffPairs.add(new DifferencesPair(leftId, rightId));
-        }
-
-        return Collections.unmodifiableCollection(diffPairs);
+        final Collection<WstSoundingIdPair> pairs = WstSoundingIdPair.parsePairs(diffids);
+        return pairs;
     }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org