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