Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9559:ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
author | gernotbelger |
---|---|
date | Wed, 24 Oct 2018 18:40:38 +0200 |
parents | bf6b63208f34 |
children | 63bbd5e45839 |
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 | |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
15 import org.dive4elements.artifacts.CallContext; |
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; |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
23 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.WmsConfig; |
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 | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
35 private final EpochYearAccessHelper helper; |
9069 | 36 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
37 // public static enum WmsClassification { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
38 // asIs { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
39 // @Override |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
40 // public String configureAddress(final WmsConfig config) { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
41 // return config.getUrl(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
42 // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
43 // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
44 // // , |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
45 // // vegetationZone { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
46 // // @Override |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
47 // // public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
48 // // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
49 // // try { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
50 // // final String urlEncoded = URLEncoder.encode(url, "UTF-8"); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
51 // // final String vegZoneIdEncoded = URLEncoder.encode(vegetationZoneId, "UTF-8"); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
52 // // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
53 // // return String.format("%s/%s/%s/%s", serverAddress, VegetationWmsResource.BASE_PATH, vegZoneIdEncoded, urlEncoded); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
54 // // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
55 // // catch (final UnsupportedEncodingException e) { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
56 // // /* should never happen */ |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
57 // // e.printStackTrace(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
58 // // return null; |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
59 // // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
60 // // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
61 // // } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
62 // ; |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
63 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
64 // public abstract String configureAddress(final WmsConfig config); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
65 // } |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
66 |
9069 | 67 // Fields from state: |
68 // | |
69 // calculation_mode (String) | |
70 // ld_from, ld_to | |
71 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) | |
9481 | 72 // year_epoch_select |
9069 | 73 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) |
74 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) | |
75 // sedimentheight String | |
76 // | |
77 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen | |
78 | |
79 public InundationDurationAccess(final UINFOArtifact uinfo) { | |
80 super(uinfo); | |
81 /* assert calculation mode */ | |
82 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
83 this.helper = new EpochYearAccessHelper(uinfo); |
9069 | 84 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); |
85 } | |
86 | |
9481 | 87 public boolean isUseYear() { |
88 if (this.helper.getYearEpoch().equals("state.uinfo.year")) | |
89 return true; | |
90 return false; | |
9069 | 91 } |
92 | |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
93 // public WmsLayer createWMSLayer(final CallContext context, final String i10nKey, final WmsConfig classification) |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
94 // throws IOException, TsvReaderException { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
95 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
96 // final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
97 // final String selectedElement = getSelectedLabel(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
98 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
99 // final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
100 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
101 // return createWMSLayer(context, layerLabel, type, selectedElement, classification); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
102 // } |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9155
diff
changeset
|
103 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
104 // public WmsLayer createScenarioWMSLayer(final CallContext context, final String i10nKey, final WmsConfig |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
105 // classification, final String vegZoneId) |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
106 // throws IOException, TsvReaderException { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
107 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
108 // // FIXME: use scenario-cm as label, and scenario-type |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
109 // final YearType type = YearType.jahre; |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
110 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
111 // final String selectedElement = Integer.toString(getDwspl()); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
112 // final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
113 // |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
114 // return createWMSLayer(context, layerLabel, type, selectedElement, classification); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
115 // } |
9481 | 116 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
117 public WmsLayer createWMSLayer(final CallContext context, final String layerLabel, final String selectedItem, final WmsConfig config, |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
118 final boolean showLayerLink) throws IOException, TsvReaderException { |
9481 | 119 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
120 // final String serverAddress = context.getDatabase().getServerAddress(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
121 // final UedauernConfiguration config = UedauernConfiguration.getInstance(getRiverName(), type); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
122 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
123 final String layerLabelFinal = Resources.getMsg(context.getMeta(), layerLabel, new Object[] { selectedItem }); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
124 final String url = config.getUrl(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
125 final String layer = config.getLayer(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
126 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
127 if (url != null && layer != null) { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
128 // final String realUrl = classification.configureAddress(serverAddress, url, vegZoneId); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
129 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
130 return new WmsLayer(layerLabelFinal, url, layer, showLayerLink); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
131 } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
132 return null; |
9069 | 133 } |
134 | |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
135 public String getSelectedLabel() { |
9481 | 136 return this.getString("year_epoch_select"); |
137 } | |
138 | |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
139 public String getSelectedSzenario() { |
9481 | 140 if (getIsUseScenario()) |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9537
diff
changeset
|
141 return super.getString("inundation_scenario"); |
9481 | 142 |
9184 | 143 return null; |
144 } | |
145 | |
9190 | 146 public boolean getIsUseScenario() { |
147 return super.getBoolean("use_scenario"); | |
148 } | |
9069 | 149 } |