Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 2610:3c907758f0ab
Added cacheable model for fixing column.
flys-artifacts/trunk@4192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Apr 2012 16:51:03 +0000 |
parents | |
children | b0597a63fe70 |
comparison
equal
deleted
inserted
replaced
2609:ed550e325248 | 2610:3c907758f0ab |
---|---|
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 int columnId; | |
13 | |
14 protected double [] kms; | |
15 protected double [] ws; | |
16 | |
17 protected QRangeTree qs; | |
18 | |
19 public FixingsColumn() { | |
20 } | |
21 | |
22 public FixingsColumn( | |
23 int columnId, | |
24 double [] kms, | |
25 double [] ws | |
26 ) { | |
27 this.columnId = columnId; | |
28 this.kms = kms; | |
29 this.ws = ws; | |
30 } | |
31 | |
32 public int getColumnId() { | |
33 return columnId; | |
34 } | |
35 | |
36 public double getW(double km) { | |
37 | |
38 if (km < kms[0] || km > kms[kms.length-1]) { | |
39 return Double.NaN; | |
40 } | |
41 | |
42 int idx = Arrays.binarySearch(kms, km); | |
43 | |
44 if (idx >= 0) return ws[idx]; | |
45 | |
46 idx = -idx - 1; | |
47 | |
48 return Linear.linear(km, kms[idx], kms[idx+1], ws[idx], ws[idx+1]); | |
49 } | |
50 | |
51 public double getQ(double km) { | |
52 return qs.findQ(km); | |
53 } | |
54 } | |
55 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |