comparison 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
comparison
equal deleted inserted replaced
9480:7228bd10a8cc 9481:787fc085459b
8 * documentation coming with Dive4Elements River for details. 8 * documentation coming with Dive4Elements River for details.
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;
14
15 import org.dive4elements.artifacts.CallMeta;
13 import org.dive4elements.river.artifacts.access.RangeAccess; 16 import org.dive4elements.river.artifacts.access.RangeAccess;
14 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; 17 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
18 import org.dive4elements.river.artifacts.resources.Resources;
19 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException;
15 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; 20 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
16 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; 21 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;
22 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer;
23 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.YearType;
17 24
18 /** 25 /**
19 * Access to the flow depth calculation type specific SInfo artifact data. 26 * Access to the flow depth calculation type specific SInfo artifact data.
20 * 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
21 * reference to the artifact instance. 28 * reference to the artifact instance.
34 // Fields from state: 41 // Fields from state:
35 // 42 //
36 // calculation_mode (String) 43 // calculation_mode (String)
37 // ld_from, ld_to 44 // ld_from, ld_to
38 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) 45 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year)
39 // singleyear (String) 46 // year_epoch_select
40 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) 47 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier))
41 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) 48 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe)
42 // sedimentheight String 49 // sedimentheight String
43 // 50 //
44 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen 51 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen
49 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); 56 final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
50 this.helper = new EpochYearAccessHelper(uinfo); 57 this.helper = new EpochYearAccessHelper(uinfo);
51 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); 58 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration);
52 } 59 }
53 60
54 public Integer getYear() { 61 public boolean isUseYear() {
55 final int[] years = this.helper.getYears("state.uinfo.year", "singleyear"); 62 if (this.helper.getYearEpoch().equals("state.uinfo.year"))
56 if (years != null) { 63 return true;
57 return years[0]; 64 return false;
65 }
66
67 public WmsLayer createWMSLayer(final CallMeta meta, final String i10nKey) {
68
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);
80 }
81 catch (final IOException | TsvReaderException e) {
82 e.printStackTrace();
58 } 83 }
59 return null; 84 return null;
60 }
61
62 public String getWMSUrl() {
63
64 final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
65 if (this.getYear() != null) {
66 return helper.urlFromYear(this.getYear());
67 } else {
68 return helper.getMittelUrl(); // nur 2 cases...
69 }
70 85
71 } 86 }
72 87
73 public String getWMSScenarioUrl() { 88 public WmsLayer createScenarioWMSLayer(final CallMeta meta, final String i10nKey) {
74 if (getIsUseScenario()) { 89
75 final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName()); 90 // FIXME: use scenario-cm as label, and scenario-type
76 if (this.getYear() != null) { 91 final YearType type = YearType.jahre;
77 return helper.getScenarioUrlFromYear(this.getYear(), this.getDwspl()); 92 final String selectedElement = Integer.toString(getDwspl());
78 } else { 93
79 return helper.getMittelScenarioUrl(this.getDwspl()); // nur 2 cases... 94 final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement });
80 } 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);
81 } 102 }
82 return ""; 103 catch (final IOException | TsvReaderException e) {
104 e.printStackTrace();
105 }
106 return null;
107
83 } 108 }
84 109
85 public Integer getDwspl() { 110 private String getSelectedLabel() {
86 if (getIsUseScenario()) { 111 return this.getString("year_epoch_select");
112 }
113
114 private Integer getDwspl() {
115 if (getIsUseScenario())
87 return super.getInteger("sedimentheight"); 116 return super.getInteger("sedimentheight");
88 } 117
89 return null; 118 return null;
90 } 119 }
91 120
92 public String getVegZones() { 121 public String getVegZones() {
93 // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...) 122 // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...)
95 } 124 }
96 125
97 public boolean getIsUseScenario() { 126 public boolean getIsUseScenario() {
98 return super.getBoolean("use_scenario"); 127 return super.getBoolean("use_scenario");
99 } 128 }
100
101 public Integer[] mittelStartEndYears() {
102 if (getIsUseScenario()) {
103 final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
104 return helper.getMittelStartEnd();
105 }
106 return null;
107 }
108 } 129 }

http://dive4elements.wald.intevation.org