comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 4835:8e72777c961c

Introduced a fake ConstantWQKms class to have type information to only generate w facets for curves which really carry w data.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 23 Jan 2013 05:53:44 +0100
parents bcf25d8c183e
children 61ebb6fb2ac4
comparison
equal deleted inserted replaced
4834:601f9d69cc10 4835:8e72777c961c
12 import de.intevation.flys.artifacts.model.WstValueTable.QPosition; 12 import de.intevation.flys.artifacts.model.WstValueTable.QPosition;
13 13
14 import de.intevation.flys.model.River; 14 import de.intevation.flys.model.River;
15 15
16 import de.intevation.flys.utils.DoubleUtil; 16 import de.intevation.flys.utils.DoubleUtil;
17
18 import gnu.trove.TDoubleArrayList;
19 17
20 import java.util.ArrayList; 18 import java.util.ArrayList;
21 import java.util.Arrays; 19 import java.util.Arrays;
22 import java.util.List; 20 import java.util.List;
23 21
274 for (int i = 0; i < results.length; ++i) { 272 for (int i = 0; i < results.length; ++i) {
275 results[i].setName(createName(i)); 273 results[i].setName(createName(i));
276 } 274 }
277 275
278 // Generate the "Umhuellende". 276 // Generate the "Umhuellende".
279 QKms [] qkms = generateInfolding(table, results, from, to, step); 277 ConstantWQKms [] infoldings =
278 generateInfolding(table, results, from, to, step);
280 279
281 // TODO: Use qkms in a new result type. 280 // TODO: Use qkms in a new result type.
282 281 WQKms [] newResults = new WQKms[results.length + infoldings.length];
283 return new CalculationResult(results, this); 282 System.arraycopy(
284 } 283 results, 0, newResults, 0, results.length);
285 284 System.arraycopy(
286 protected QKms [] generateInfolding( 285 infoldings, 0, newResults, results.length, infoldings.length);
286
287 return new CalculationResult(newResults, this);
288 }
289
290 protected ConstantWQKms [] generateInfolding(
287 WstValueTable wst, 291 WstValueTable wst,
288 WQKms [] results, 292 WQKms [] results,
289 double from, 293 double from,
290 double to, 294 double to,
291 double step 295 double step
293 WstValueTable.Column [] columns = wst.getColumns(); 297 WstValueTable.Column [] columns = wst.getColumns();
294 298
295 InfoldingColumns ic = new InfoldingColumns(columns); 299 InfoldingColumns ic = new InfoldingColumns(columns);
296 ic.markInfoldingColumns(results); 300 ic.markInfoldingColumns(results);
297 301
298 List<QKms> infoldings = new ArrayList<QKms>(); 302 List<ConstantWQKms> infoldings = new ArrayList<ConstantWQKms>();
299 303
300 boolean [] infoldingColumns = ic.getInfoldingColumns(); 304 boolean [] infoldingColumns = ic.getInfoldingColumns();
301 305
302 double [] kms = null; 306 double [] kms = null;
307 double [] ws = null;
303 308
304 for (int i = 0; i < infoldingColumns.length; ++i) { 309 for (int i = 0; i < infoldingColumns.length; ++i) {
305 if (!infoldingColumns[i]) { 310 if (!infoldingColumns[i]) {
306 continue; 311 continue;
307 } 312 }
308 313
309 kms = kms == null 314 if (kms == null) {
310 ? DoubleUtil.explode(from, to, step) 315 kms = DoubleUtil.explode(from, to, step);
311 : (double [])kms.clone(); 316 ws = new double[kms.length];
317 }
312 318
313 QRangeTree.QuickQFinder qf = 319 QRangeTree.QuickQFinder qf =
314 columns[i].getQRangeTree().new QuickQFinder(); 320 columns[i].getQRangeTree().new QuickQFinder();
315 321
316 int numProblemsBefore = numProblems(); 322 int numProblemsBefore = numProblems();
317 double [] qs = qf.findQs(kms, this); 323 double [] qs = qf.findQs(kms, this);
318 324
319 // TODO: i18n 325 // TODO: i18n
320 String name = "Umh\u00fcllende " + columns[i].getName(); 326 String name = "Umh\u00fcllende " + columns[i].getName();
321 327
322 QKmsImpl qkms = new QKmsImpl( 328 ConstantWQKms infolding = new ConstantWQKms(kms, qs, ws, name);
323 new TDoubleArrayList(kms),
324 new TDoubleArrayList(qs),
325 name);
326 329
327 if (numProblems() > numProblemsBefore) { 330 if (numProblems() > numProblemsBefore) {
328 qkms.removeNaNs(); 331 infolding.removeNaNs();
329 } 332 }
330 333
331 infoldings.add(qkms); 334 infoldings.add(infolding);
332 } 335 }
333 336
334 return infoldings.toArray(new QKms[infoldings.size()]); 337 return infoldings.toArray(new ConstantWQKms[infoldings.size()]);
335 } 338 }
336 339
337 protected String createName(int index) { 340 protected String createName(int index) {
338 // TODO: i18n 341 // TODO: i18n
339 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W"); 342 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W");

http://dive4elements.wald.intevation.org