Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9537:bf6b63208f34
Work on uinfo inundation duration calculation.
Using proxy-wms to induce additional style information (work in progress).
author | gernotbelger |
---|---|
date | Wed, 17 Oct 2018 11:23:17 +0200 |
parents | 787fc085459b |
children | ba0561906f81 |
comparison
equal
deleted
inserted
replaced
9536:aa23225fd85f | 9537:bf6b63208f34 |
---|---|
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; | |
14 | 16 |
15 import org.dive4elements.artifacts.CallMeta; | 17 import org.dive4elements.artifacts.CallContext; |
16 import org.dive4elements.river.artifacts.access.RangeAccess; | 18 import org.dive4elements.river.artifacts.access.RangeAccess; |
17 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; | 19 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; |
18 import org.dive4elements.river.artifacts.resources.Resources; | 20 import org.dive4elements.river.artifacts.resources.Resources; |
19 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; | 21 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; |
20 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | 22 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
35 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | 37 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR |
36 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | 38 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; |
37 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | 39 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; |
38 | 40 |
39 private final EpochYearAccessHelper helper; | 41 private final EpochYearAccessHelper helper; |
42 | |
43 public static enum WmsClassification { | |
44 asIs { | |
45 @Override | |
46 public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { | |
47 return url; | |
48 } | |
49 }, | |
50 vegetationZone { | |
51 @Override | |
52 public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { | |
53 | |
54 try { | |
55 final String urlEncoded = URLEncoder.encode(url, "UTF-8"); | |
56 final String vegZoneIdEncoded = URLEncoder.encode(vegetationZoneId, "UTF-8"); | |
57 | |
58 return String.format("%s/%s/%s/%s", serverAddress, VegetationWmsResource.BASE_PATH, vegZoneIdEncoded, urlEncoded); | |
59 } | |
60 catch (final UnsupportedEncodingException e) { | |
61 /* should never happen */ | |
62 e.printStackTrace(); | |
63 return null; | |
64 } | |
65 } | |
66 }; | |
67 | |
68 public abstract String configureAddress(String serverAddress, String url, String vegetationZoneId); | |
69 } | |
40 | 70 |
41 // Fields from state: | 71 // Fields from state: |
42 // | 72 // |
43 // calculation_mode (String) | 73 // calculation_mode (String) |
44 // ld_from, ld_to | 74 // ld_from, ld_to |
62 if (this.helper.getYearEpoch().equals("state.uinfo.year")) | 92 if (this.helper.getYearEpoch().equals("state.uinfo.year")) |
63 return true; | 93 return true; |
64 return false; | 94 return false; |
65 } | 95 } |
66 | 96 |
67 public WmsLayer createWMSLayer(final CallMeta meta, final String i10nKey) { | 97 public WmsLayer createWMSLayer(final CallContext context, final String i10nKey, final WmsClassification classification, final String vegZoneId) |
98 throws IOException, TsvReaderException { | |
68 | 99 |
69 final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; | 100 final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; |
70 final String selectedElement = getSelectedLabel(); | 101 final String selectedElement = getSelectedLabel(); |
71 | 102 |
72 final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); | 103 final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); |
73 | 104 |
74 try { | 105 return createWMSLayer(context, layerLabel, type, selectedElement, classification, vegZoneId); |
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); | |
80 } | |
81 catch (final IOException | TsvReaderException e) { | |
82 e.printStackTrace(); | |
83 } | |
84 return null; | |
85 | |
86 } | 106 } |
87 | 107 |
88 public WmsLayer createScenarioWMSLayer(final CallMeta meta, final String i10nKey) { | 108 public WmsLayer createScenarioWMSLayer(final CallContext context, final String i10nKey, final WmsClassification classification, final String vegZoneId) |
109 throws IOException, TsvReaderException { | |
89 | 110 |
90 // FIXME: use scenario-cm as label, and scenario-type | 111 // FIXME: use scenario-cm as label, and scenario-type |
91 final YearType type = YearType.jahre; | 112 final YearType type = YearType.jahre; |
113 | |
92 final String selectedElement = Integer.toString(getDwspl()); | 114 final String selectedElement = Integer.toString(getDwspl()); |
115 final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); | |
93 | 116 |
94 final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); | 117 return createWMSLayer(context, layerLabel, type, selectedElement, classification, vegZoneId); |
118 } | |
95 | 119 |
96 try { | 120 private WmsLayer createWMSLayer(final CallContext context, final String layerLabel, final YearType type, final String selectedElement, |
97 final UedauernConfiguration helper = UedauernConfiguration.getInstance(getRiverName(), type); | 121 final WmsClassification classification, final String vegZoneId) |
98 final String url = helper.getUrl(selectedElement); | 122 throws IOException, TsvReaderException { |
99 final String layer = helper.getLayer(selectedElement); | |
100 | 123 |
101 return new WmsLayer(layerLabel, url, layer, false); | 124 final String serverAddress = context.getDatabase().getServerAddress(); |
102 } | |
103 catch (final IOException | TsvReaderException e) { | |
104 e.printStackTrace(); | |
105 } | |
106 return null; | |
107 | 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); | |
108 } | 133 } |
109 | 134 |
110 private String getSelectedLabel() { | 135 private String getSelectedLabel() { |
111 return this.getString("year_epoch_select"); | 136 return this.getString("year_epoch_select"); |
112 } | 137 } |