Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9068:a5cf8d7bff3c | 9069:1ffd38826175 |
---|---|
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.uinfo.vegetationzones; | |
12 | |
13 import java.util.ArrayList; | |
14 | |
15 import org.apache.commons.lang.math.DoubleRange; | |
16 import org.dive4elements.river.artifacts.access.RangeAccess; | |
17 import org.dive4elements.river.artifacts.common.AccessHelper; | |
18 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
19 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; | |
20 | |
21 /** | |
22 * Access to the flow depth calculation type specific SInfo artifact data. | |
23 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent | |
24 * reference to the artifact instance. | |
25 * Hence we do NOT cache any data. | |
26 * | |
27 * @author Gernot Belger | |
28 */ | |
29 final class VegetationzonesAccess extends RangeAccess { | |
30 | |
31 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | |
32 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | |
33 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | |
34 private final AccessHelper helper; | |
35 | |
36 // Fields from state: | |
37 // calculation_mode (String) | |
38 // ld_from, ld_to,ld_step | |
39 // vegzones (String) | |
40 | |
41 public VegetationzonesAccess(final UINFOArtifact uinfo) { | |
42 super(uinfo); | |
43 | |
44 /* assert calculation mode */ | |
45 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); | |
46 this.helper = new AccessHelper(uinfo); | |
47 assert (calculationMode == UinfoCalcMode.uinfo_vegetation_zones); | |
48 } | |
49 | |
50 public DoubleRange getRange() { | |
51 final double from = getFrom(); | |
52 final double to = getTo(); | |
53 return new DoubleRange(from, to); | |
54 } | |
55 | |
56 public ArrayList<String[]> getVegZones() { | |
57 final ArrayList<String[]> results = new ArrayList<>(); | |
58 final String zonesRaw = super.getString("vegzones"); | |
59 if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) { | |
60 final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR); | |
61 for (final String row : rows) { | |
62 if (row.contains(TABLE_CELL_SEPARATOR)) { | |
63 final String[] result = row.split(TABLE_CELL_SEPARATOR); | |
64 results.add(result); | |
65 } | |
66 } | |
67 } | |
68 return results; | |
69 } | |
70 | |
71 } |