Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9558:709a73badd48 | 9559:ba0561906f81 |
---|---|
9 */ | 9 */ |
10 | 10 |
11 package org.dive4elements.river.artifacts.uinfo.inundationduration; | 11 package org.dive4elements.river.artifacts.uinfo.inundationduration; |
12 | 12 |
13 import java.io.IOException; | 13 import java.io.IOException; |
14 import java.io.UnsupportedEncodingException; | |
15 import java.net.URLEncoder; | |
16 | 14 |
17 import org.dive4elements.artifacts.CallContext; | 15 import org.dive4elements.artifacts.CallContext; |
18 import org.dive4elements.river.artifacts.access.RangeAccess; | 16 import org.dive4elements.river.artifacts.access.RangeAccess; |
19 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; | 17 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; |
20 import org.dive4elements.river.artifacts.resources.Resources; | 18 import org.dive4elements.river.artifacts.resources.Resources; |
21 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; | 19 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; |
22 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | 20 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
23 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; | 21 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; |
24 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer; | 22 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer; |
25 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.YearType; | 23 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.WmsConfig; |
26 | 24 |
27 /** | 25 /** |
28 * Access to the flow depth calculation type specific SInfo artifact data. | 26 * Access to the flow depth calculation type specific SInfo artifact data. |
29 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent | 27 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent |
30 * reference to the artifact instance. | 28 * reference to the artifact instance. |
32 * | 30 * |
33 * @author Gernot Belger | 31 * @author Gernot Belger |
34 */ | 32 */ |
35 final class InundationDurationAccess extends RangeAccess { | 33 final class InundationDurationAccess extends RangeAccess { |
36 | 34 |
37 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | |
38 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | |
39 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | |
40 | |
41 private final EpochYearAccessHelper helper; | 35 private final EpochYearAccessHelper helper; |
42 | 36 |
43 public static enum WmsClassification { | 37 // public static enum WmsClassification { |
44 asIs { | 38 // asIs { |
45 @Override | 39 // @Override |
46 public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { | 40 // public String configureAddress(final WmsConfig config) { |
47 return url; | 41 // return config.getUrl(); |
48 } | 42 // } |
49 }, | 43 // } |
50 vegetationZone { | 44 // // , |
51 @Override | 45 // // vegetationZone { |
52 public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { | 46 // // @Override |
53 | 47 // // public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { |
54 try { | 48 // // |
55 final String urlEncoded = URLEncoder.encode(url, "UTF-8"); | 49 // // try { |
56 final String vegZoneIdEncoded = URLEncoder.encode(vegetationZoneId, "UTF-8"); | 50 // // final String urlEncoded = URLEncoder.encode(url, "UTF-8"); |
57 | 51 // // final String vegZoneIdEncoded = URLEncoder.encode(vegetationZoneId, "UTF-8"); |
58 return String.format("%s/%s/%s/%s", serverAddress, VegetationWmsResource.BASE_PATH, vegZoneIdEncoded, urlEncoded); | 52 // // |
59 } | 53 // // return String.format("%s/%s/%s/%s", serverAddress, VegetationWmsResource.BASE_PATH, vegZoneIdEncoded, urlEncoded); |
60 catch (final UnsupportedEncodingException e) { | 54 // // } |
61 /* should never happen */ | 55 // // catch (final UnsupportedEncodingException e) { |
62 e.printStackTrace(); | 56 // // /* should never happen */ |
63 return null; | 57 // // e.printStackTrace(); |
64 } | 58 // // return null; |
65 } | 59 // // } |
66 }; | 60 // // } |
67 | 61 // // } |
68 public abstract String configureAddress(String serverAddress, String url, String vegetationZoneId); | 62 // ; |
69 } | 63 // |
64 // public abstract String configureAddress(final WmsConfig config); | |
65 // } | |
70 | 66 |
71 // Fields from state: | 67 // Fields from state: |
72 // | 68 // |
73 // calculation_mode (String) | 69 // calculation_mode (String) |
74 // ld_from, ld_to | 70 // ld_from, ld_to |
92 if (this.helper.getYearEpoch().equals("state.uinfo.year")) | 88 if (this.helper.getYearEpoch().equals("state.uinfo.year")) |
93 return true; | 89 return true; |
94 return false; | 90 return false; |
95 } | 91 } |
96 | 92 |
97 public WmsLayer createWMSLayer(final CallContext context, final String i10nKey, final WmsClassification classification, final String vegZoneId) | 93 // public WmsLayer createWMSLayer(final CallContext context, final String i10nKey, final WmsConfig classification) |
98 throws IOException, TsvReaderException { | 94 // throws IOException, TsvReaderException { |
95 // | |
96 // final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; | |
97 // final String selectedElement = getSelectedLabel(); | |
98 // | |
99 // final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); | |
100 // | |
101 // return createWMSLayer(context, layerLabel, type, selectedElement, classification); | |
102 // } | |
99 | 103 |
100 final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; | 104 // public WmsLayer createScenarioWMSLayer(final CallContext context, final String i10nKey, final WmsConfig |
101 final String selectedElement = getSelectedLabel(); | 105 // classification, final String vegZoneId) |
106 // throws IOException, TsvReaderException { | |
107 // | |
108 // // FIXME: use scenario-cm as label, and scenario-type | |
109 // final YearType type = YearType.jahre; | |
110 // | |
111 // final String selectedElement = Integer.toString(getDwspl()); | |
112 // final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); | |
113 // | |
114 // return createWMSLayer(context, layerLabel, type, selectedElement, classification); | |
115 // } | |
102 | 116 |
103 final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); | 117 public WmsLayer createWMSLayer(final CallContext context, final String layerLabel, final String selectedItem, final WmsConfig config, |
118 final boolean showLayerLink) throws IOException, TsvReaderException { | |
104 | 119 |
105 return createWMSLayer(context, layerLabel, type, selectedElement, classification, vegZoneId); | 120 // final String serverAddress = context.getDatabase().getServerAddress(); |
121 // final UedauernConfiguration config = UedauernConfiguration.getInstance(getRiverName(), type); | |
122 | |
123 final String layerLabelFinal = Resources.getMsg(context.getMeta(), layerLabel, new Object[] { selectedItem }); | |
124 final String url = config.getUrl(); | |
125 final String layer = config.getLayer(); | |
126 | |
127 if (url != null && layer != null) { | |
128 // final String realUrl = classification.configureAddress(serverAddress, url, vegZoneId); | |
129 | |
130 return new WmsLayer(layerLabelFinal, url, layer, showLayerLink); | |
131 } | |
132 return null; | |
106 } | 133 } |
107 | 134 |
108 public WmsLayer createScenarioWMSLayer(final CallContext context, final String i10nKey, final WmsClassification classification, final String vegZoneId) | 135 public String getSelectedLabel() { |
109 throws IOException, TsvReaderException { | |
110 | |
111 // FIXME: use scenario-cm as label, and scenario-type | |
112 final YearType type = YearType.jahre; | |
113 | |
114 final String selectedElement = Integer.toString(getDwspl()); | |
115 final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); | |
116 | |
117 return createWMSLayer(context, layerLabel, type, selectedElement, classification, vegZoneId); | |
118 } | |
119 | |
120 private WmsLayer createWMSLayer(final CallContext context, final String layerLabel, final YearType type, final String selectedElement, | |
121 final WmsClassification classification, final String vegZoneId) | |
122 throws IOException, TsvReaderException { | |
123 | |
124 final String serverAddress = context.getDatabase().getServerAddress(); | |
125 | |
126 final UedauernConfiguration config = UedauernConfiguration.getInstance(getRiverName(), type); | |
127 final String url = config.getUrl(selectedElement); | |
128 final String layer = config.getLayer(selectedElement); | |
129 | |
130 final String realUrl = classification.configureAddress(serverAddress, url, vegZoneId); | |
131 | |
132 return new WmsLayer(layerLabel, realUrl, layer, classification == WmsClassification.asIs); | |
133 } | |
134 | |
135 private String getSelectedLabel() { | |
136 return this.getString("year_epoch_select"); | 136 return this.getString("year_epoch_select"); |
137 } | 137 } |
138 | 138 |
139 private Integer getDwspl() { | 139 public String getSelectedSzenario() { |
140 if (getIsUseScenario()) | 140 if (getIsUseScenario()) |
141 return super.getInteger("sedimentheight"); | 141 return super.getString("inundation_scenario"); |
142 | 142 |
143 return null; | 143 return null; |
144 } | |
145 | |
146 public String getVegZones() { | |
147 // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...) | |
148 return super.getString("vegzones"); | |
149 } | 144 } |
150 | 145 |
151 public boolean getIsUseScenario() { | 146 public boolean getIsUseScenario() { |
152 return super.getBoolean("use_scenario"); | 147 return super.getBoolean("use_scenario"); |
153 } | 148 } |