comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 70469e3d34b9
children
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
1 package de.intevation.flys.artifacts.model;
2
3 import de.intevation.flys.artifacts.math.Linear;
4
5 import java.util.Arrays;
6
7 import java.io.Serializable;
8
9 public class FixingsColumn
10 implements Serializable
11 {
12 protected double [] kms;
13 protected double [] ws;
14
15 protected QRangeTree qs;
16
17 public FixingsColumn() {
18 }
19
20 public FixingsColumn(
21 double [] kms,
22 double [] ws,
23 QRangeTree qs
24 ) {
25 this.kms = kms;
26 this.ws = ws;
27 this.qs = qs;
28 }
29
30 public boolean getW(double km, double [] w) {
31 return getW(km, w, 0);
32 }
33
34 public boolean getW(double km, double [] w, int index) {
35
36 if (kms.length == 0 || km < kms[0] || km > kms[kms.length-1]) {
37 w[index] = Double.NaN;
38 return true;
39 }
40
41 int idx = Arrays.binarySearch(kms, km);
42
43 if (idx >= 0) {
44 w[index] = ws[idx];
45 return true;
46 }
47
48 idx = -idx - 1;
49
50 w[index] = Linear.linear(km, kms[idx-1], kms[idx], ws[idx-1], ws[idx]);
51 return false;
52 }
53
54 public double getQ(double km) {
55 return qs.findQ(km);
56 }
57
58 public QRangeTree getQRanges() {
59 return qs;
60 }
61 }
62 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org