annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java @ 9069:1ffd38826175

access uinfo.vegetationzones+inundation_duration
author gernotbelger
date Tue, 15 May 2018 12:00:26 +0200
parents
children 611a523fc42f
rev   line source
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
2 * Software engineering by
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
5 *
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
9 */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
10
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
11 package org.dive4elements.river.artifacts.uinfo.vegetationzones;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
12
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
13 import java.util.ArrayList;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
14
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
15 import org.apache.commons.lang.math.DoubleRange;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
16 import org.dive4elements.river.artifacts.access.RangeAccess;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
17 import org.dive4elements.river.artifacts.common.AccessHelper;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
18 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
19 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
20
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
21 /**
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
22 * Access to the flow depth calculation type specific SInfo artifact data.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
23 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
24 * reference to the artifact instance.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
25 * Hence we do NOT cache any data.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
26 *
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
27 * @author Gernot Belger
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
28 */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
29 final class VegetationzonesAccess extends RangeAccess {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
30
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
31 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
32 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
33 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
34 private final AccessHelper helper;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
35
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
36 // Fields from state:
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
37 // calculation_mode (String)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
38 // ld_from, ld_to,ld_step
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
39 // vegzones (String)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
40
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
41 public VegetationzonesAccess(final UINFOArtifact uinfo) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
42 super(uinfo);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
43
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
44 /* assert calculation mode */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
45 final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
46 this.helper = new AccessHelper(uinfo);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
47 assert (calculationMode == UinfoCalcMode.uinfo_vegetation_zones);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
48 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
49
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
50 public DoubleRange getRange() {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
51 final double from = getFrom();
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
52 final double to = getTo();
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
53 return new DoubleRange(from, to);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
54 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
55
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
56 public ArrayList<String[]> getVegZones() {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
57 final ArrayList<String[]> results = new ArrayList<>();
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
58 final String zonesRaw = super.getString("vegzones");
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
59 if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
60 final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
61 for (final String row : rows) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
62 if (row.contains(TABLE_CELL_SEPARATOR)) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
63 final String[] result = row.split(TABLE_CELL_SEPARATOR);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
64 results.add(result);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
65 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
66 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
67 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
68 return results;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
69 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
70
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
71 }

http://dive4elements.wald.intevation.org