comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1847:8e5b4ea2851c

Minor cosmetics and let facets be inactive in duration curve diagrams. flys-artifacts/trunk@3191 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 09 Nov 2011 12:48:36 +0000
parents 4ee833095e75
children 7e7522c9e663
comparison
equal deleted inserted replaced
1846:6deed62a2468 1847:8e5b4ea2851c
120 */ 120 */
121 protected State spawnState() { 121 protected State spawnState() {
122 state = new StaticState(STATIC_STATE_NAME); 122 state = new StaticState(STATIC_STATE_NAME);
123 List<Facet> fs = (List<Facet>) facets.get(STATIC_STATE_NAME); 123 List<Facet> fs = (List<Facet>) facets.get(STATIC_STATE_NAME);
124 124
125 DefaultOutput mainValuesOutput2 = new DefaultOutput( 125 DefaultOutput mainValuesOutput = new DefaultOutput(
126 "computed_discharge_curve", 126 "computed_discharge_curve",
127 "output.computed_discharge_curve", "image/png", 127 "output.computed_discharge_curve", "image/png",
128 fs, 128 fs,
129 "chart"); 129 "chart");
130 130
131 state.getOutputs().add(mainValuesOutput2); 131 state.getOutputs().add(mainValuesOutput);
132 return state; 132 return state;
133 } 133 }
134 134
135 135
136 @Override 136 @Override
137 protected void initialize(Artifact artifact, Object context, CallMeta meta) { 137 protected void initialize(Artifact artifact, Object context, CallMeta meta) {
138 logger.debug("MainValuesArtifact.initialize"); 138 logger.debug("MainValuesArtifact.initialize");
139 WINFOArtifact winfo = (WINFOArtifact) artifact; 139 WINFOArtifact winfo = (WINFOArtifact) artifact;
140 double location = FLYSUtils.getLocations(winfo)[0]; 140 double [] locations = FLYSUtils.getLocations(winfo);
141 addData("location", new DefaultStateData("location", null, null, 141 if (locations != null) {
142 double location = locations[0];
143 addData("location", new DefaultStateData("location", null, null,
142 String.valueOf(location))); 144 String.valueOf(location)));
145 }
146 else {
147 logger.warn("No location for mainvalues given.");
148 }
149 // TODO use importData
143 addData("river", winfo.getData("river")); 150 addData("river", winfo.getData("river"));
144 } 151 }
145 152
146 153
147 /** 154 /**
198 * invalid parameterization. 205 * invalid parameterization.
199 */ 206 */
200 protected Gauge getGauge() { 207 protected Gauge getGauge() {
201 River river = FLYSUtils.getRiver(this); 208 River river = FLYSUtils.getRiver(this);
202 209
203 if (river == null) { 210 // TODO use helper to get location as double
211 String locationStr = getDataAsString("location");
212
213 if (river == null || locationStr == null) {
204 return null; 214 return null;
205 } 215 }
206 216
207 double location = Double.parseDouble( 217 double location = Double.parseDouble(locationStr);
208 getDataAsString("location"));
209 218
210 return river.determineGaugeByPosition(location); 219 return river.determineGaugeByPosition(location);
211 } 220 }
212 221
213 222
214 /** 223 /**
215 * Get current location. 224 * Get current location.
216 * @return the location. 225 * @return the location.
217 */ 226 */
218 public double getLocation() { 227 public double getLocation() {
219 double location = Double.parseDouble( 228 double location = Double.parseDouble(getDataAsString("location"));
220 (String)getData("location").getValue());
221 return location; 229 return location;
222 } 230 }
223 231
224 232
225 /** 233 /**
259 public List<NamedDouble> getMainValuesW() { 267 public List<NamedDouble> getMainValuesW() {
260 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); 268 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
261 Gauge gauge = getGauge(); 269 Gauge gauge = getGauge();
262 WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this)); 270 WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this));
263 Calculation c = new Calculation(); 271 Calculation c = new Calculation();
272
264 double gaugeStation = gauge.getStation().doubleValue(); 273 double gaugeStation = gauge.getStation().doubleValue();
265 double w_out[] = {0.0f}; 274 double w_out[] = {0.0f};
266 double q_out[] = {0.0f}; 275 double q_out[] = {0.0f};
267 double kms[] = {getLocation()}; 276 double kms[] = {getLocation()};
268 if (gauge != null) { 277 if (gauge != null) {
302 logger.debug("MainValuesArtifact.active?: " 311 logger.debug("MainValuesArtifact.active?: "
303 + outputName 312 + outputName
304 + "/" 313 + "/"
305 + facetName); 314 + facetName);
306 315
307 if (outputName.equals("computed_discharge_curve")) { 316 if (outputName.equals("computed_discharge_curve")
317 || outputName.equals("duration_curve")) {
308 return 0; 318 return 0;
309 } 319 }
310 else { 320 else {
311 return 1; 321 return 1;
312 } 322 }

http://dive4elements.wald.intevation.org