Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9481:787fc085459b
TSV introduced; uinfo.inundationWMS-Config
author | gernotbelger |
---|---|
date | Wed, 12 Sep 2018 10:55:09 +0200 |
parents | 0633f963c5be |
children | bf6b63208f34 |
rev | line source |
---|---|
9069 | 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.inundationduration; | |
12 | |
9481 | 13 import java.io.IOException; |
14 | |
15 import org.dive4elements.artifacts.CallMeta; | |
9069 | 16 import org.dive4elements.river.artifacts.access.RangeAccess; |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
17 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; |
9481 | 18 import org.dive4elements.river.artifacts.resources.Resources; |
19 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; | |
9069 | 20 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
21 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; | |
9481 | 22 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer; |
23 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.YearType; | |
9069 | 24 |
25 /** | |
26 * Access to the flow depth calculation type specific SInfo artifact data. | |
27 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent | |
28 * reference to the artifact instance. | |
29 * Hence we do NOT cache any data. | |
30 * | |
31 * @author Gernot Belger | |
32 */ | |
33 final class InundationDurationAccess extends RangeAccess { | |
34 | |
35 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | |
36 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | |
37 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
38 |
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
39 private final EpochYearAccessHelper helper; |
9069 | 40 |
41 // Fields from state: | |
42 // | |
43 // calculation_mode (String) | |
44 // ld_from, ld_to | |
45 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) | |
9481 | 46 // year_epoch_select |
9069 | 47 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) |
48 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) | |
49 // sedimentheight String | |
50 // | |
51 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen | |
52 | |
53 public InundationDurationAccess(final UINFOArtifact uinfo) { | |
54 super(uinfo); | |
55 /* assert calculation mode */ | |
56 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
57 this.helper = new EpochYearAccessHelper(uinfo); |
9069 | 58 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); |
59 } | |
60 | |
9481 | 61 public boolean isUseYear() { |
62 if (this.helper.getYearEpoch().equals("state.uinfo.year")) | |
63 return true; | |
64 return false; | |
9069 | 65 } |
66 | |
9481 | 67 public WmsLayer createWMSLayer(final CallMeta meta, final String i10nKey) { |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9155
diff
changeset
|
68 |
9481 | 69 final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; |
70 final String selectedElement = getSelectedLabel(); | |
71 | |
72 final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); | |
73 | |
74 try { | |
75 final UedauernConfiguration helper = UedauernConfiguration.getInstance(getRiverName(), type); | |
76 final String url = helper.getUrl(selectedElement); | |
77 final String layer = helper.getLayer(selectedElement); | |
78 | |
79 return new WmsLayer(layerLabel, url, layer, true); | |
9069 | 80 } |
9481 | 81 catch (final IOException | TsvReaderException e) { |
82 e.printStackTrace(); | |
83 } | |
84 return null; | |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9155
diff
changeset
|
85 |
9069 | 86 } |
87 | |
9481 | 88 public WmsLayer createScenarioWMSLayer(final CallMeta meta, final String i10nKey) { |
89 | |
90 // FIXME: use scenario-cm as label, and scenario-type | |
91 final YearType type = YearType.jahre; | |
92 final String selectedElement = Integer.toString(getDwspl()); | |
93 | |
94 final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); | |
95 | |
96 try { | |
97 final UedauernConfiguration helper = UedauernConfiguration.getInstance(getRiverName(), type); | |
98 final String url = helper.getUrl(selectedElement); | |
99 final String layer = helper.getLayer(selectedElement); | |
100 | |
101 return new WmsLayer(layerLabel, url, layer, false); | |
9184 | 102 } |
9481 | 103 catch (final IOException | TsvReaderException e) { |
104 e.printStackTrace(); | |
105 } | |
106 return null; | |
107 | |
9184 | 108 } |
109 | |
9481 | 110 private String getSelectedLabel() { |
111 return this.getString("year_epoch_select"); | |
112 } | |
113 | |
114 private Integer getDwspl() { | |
115 if (getIsUseScenario()) | |
9184 | 116 return super.getInteger("sedimentheight"); |
9481 | 117 |
9184 | 118 return null; |
119 } | |
120 | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
121 public String getVegZones() { |
9184 | 122 // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...) |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
123 return super.getString("vegzones"); |
9069 | 124 } |
125 | |
9190 | 126 public boolean getIsUseScenario() { |
127 return super.getBoolean("use_scenario"); | |
128 } | |
9069 | 129 } |