comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 1838:853cd2120d69

Cosmetics, doc. flys-artifacts/trunk@3174 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 07 Nov 2011 10:48:13 +0000
parents eb35570df0e8
children ddd425858169
comparison
equal deleted inserted replaced
1837:0585bf8af41b 1838:853cd2120d69
18 18
19 import org.apache.commons.math.ArgumentOutsideDomainException; 19 import org.apache.commons.math.ArgumentOutsideDomainException;
20 20
21 import org.apache.commons.math.exception.MathIllegalArgumentException; 21 import org.apache.commons.math.exception.MathIllegalArgumentException;
22 22
23 /**
24 * W, Q and km data from database 'wsts' spiced with interpolation algorithms.
25 */
23 public class WstValueTable 26 public class WstValueTable
24 implements Serializable 27 implements Serializable
25 { 28 {
26 private static Logger log = Logger.getLogger(WstValueTable.class); 29 private static Logger log = Logger.getLogger(WstValueTable.class);
27 30
84 } 87 }
85 88
86 } // class Position 89 } // class Position
87 90
88 /** 91 /**
89 * A row, typically a position where measurements whrere taken. 92 * A row, typically a position where measurements were taken.
90 */ 93 */
91 public static final class Row 94 public static final class Row
92 implements Serializable, Comparable<Row> 95 implements Serializable, Comparable<Row>
93 { 96 {
94 double km; 97 double km;
104 public Row(double km, double [] ws) { 107 public Row(double km, double [] ws) {
105 this(km); 108 this(km);
106 this.ws = ws; 109 this.ws = ws;
107 } 110 }
108 111
112 /**
113 * Compare according to place of measurement (km).
114 */
109 public int compareTo(Row other) { 115 public int compareTo(Row other) {
110 double d = km - other.km; 116 double d = km - other.km;
111 if (d < -0.0001) return -1; 117 if (d < -0.0001) return -1;
112 if (d > 0.0001) return +1; 118 if (d > 0.0001) return +1;
113 return 0; 119 return 0;
349 355
350 return Linear.weight(kmWeight, tw, ow); 356 return Linear.weight(kmWeight, tw, ow);
351 } 357 }
352 } // class Row 358 } // class Row
353 359
360 /** Rows in table. */
354 protected List<Row> rows; 361 protected List<Row> rows;
355 362
363 /** Columns in table. */
356 protected Column [] columns; 364 protected Column [] columns;
357 365
358 public WstValueTable() { 366 public WstValueTable() {
359 rows = new ArrayList<Row>(); 367 rows = new ArrayList<Row>();
360 } 368 }
367 public WstValueTable(Column [] columns, List<Row> rows) { 375 public WstValueTable(Column [] columns, List<Row> rows) {
368 this.columns = columns; 376 this.columns = columns;
369 this.rows = rows; 377 this.rows = rows;
370 } 378 }
371 379
380 /** Sort rows (by km). */
372 public void sortRows() { 381 public void sortRows() {
373 Collections.sort(rows); 382 Collections.sort(rows);
374 } 383 }
375 384
376 public double [] interpolateW(double km, double [] qs, double [] ws) { 385 public double [] interpolateW(double km, double [] qs, double [] ws) {
431 } 440 }
432 441
433 return ws; 442 return ws;
434 } 443 }
435 444
445 /**
446 * Interpolate W and Q values at a given km.
447 */
436 public double [][] interpolateWQ(double km) { 448 public double [][] interpolateWQ(double km) {
437 return interpolateWQ(km, null); 449 return interpolateWQ(km, null);
438 } 450 }
439 451
452 /**
453 * Interpolate W and Q values at a given km.
454 */
440 public double [][] interpolateWQ(double km, Calculation errors) { 455 public double [][] interpolateWQ(double km, Calculation errors) {
441 return interpolateWQ(km, DEFAULT_Q_STEPS, errors); 456 return interpolateWQ(km, DEFAULT_Q_STEPS, errors);
442 } 457 }
443 458
444 public double [][] interpolateWQ(double km, int steps, Calculation errors) { 459 public double [][] interpolateWQ(double km, int steps, Calculation errors) {

http://dive4elements.wald.intevation.org