annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 2616:27cc95e65f18

Defined a style for WSPLGEN layers which are now modifiable. flys-artifacts/trunk@4200 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 05 Apr 2012 07:21:58 +0000
parents b0597a63fe70
children 6ed24efc80de
rev   line source
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import de.intevation.flys.artifacts.math.Linear;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.util.Arrays;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import java.io.Serializable;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 public class FixingsColumn
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 implements Serializable
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 {
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 protected int columnId;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 protected double [] kms;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 protected double [] ws;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 protected QRangeTree qs;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 public FixingsColumn() {
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 public FixingsColumn(
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 int columnId,
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 double [] kms,
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 double [] ws
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 ) {
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 this.columnId = columnId;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 this.kms = kms;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 this.ws = ws;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public int getColumnId() {
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 return columnId;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
36 public boolean getW(double km, double [] w) {
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 if (km < kms[0] || km > kms[kms.length-1]) {
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
39 w[0] = Double.NaN;
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
40 return true;
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 int idx = Arrays.binarySearch(kms, km);
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
45 if (idx >= 0) {
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
46 w[0] = ws[idx];
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
47 return true;
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
48 }
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 idx = -idx - 1;
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
52 w[0] = Linear.linear(km, kms[idx], kms[idx+1], ws[idx], ws[idx+1]);
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
53 return false;
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 public double getQ(double km) {
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 return qs.findQ(km);
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 }
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org