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

http://dive4elements.wald.intevation.org