Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8034:b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 18:52:22 +0200 |
parents | 5e3f4b4fcb28 |
children | f2dc7992b8a3 |
rev | line source |
---|---|
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 package org.dive4elements.river.artifacts.model.minfo; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 import java.io.Serializable; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
12 import java.util.Collection; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.util.Date; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.util.List; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.util.TreeMap; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.dive4elements.river.utils.EpsilonComparator; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 public class SedimentLoadData implements Serializable |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 public static final double STATION_EPS = 0.0001; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 public static final int GF_COARSE = 0; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 public static final int GF_FINE_MIDDLE = 1; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 public static final int GF_SAND = 2; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 public static final int GF_SUSP_SAND = 3; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 public static final int GF_SUSP_SAND_BED = 4; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 public static final int GF_SUSP_SEDIMENT = 5; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final int GF_MAX = 5; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 public static final int grainFractionIndex(String name) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 if ("coarse".equals(name)) return GF_COARSE; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 if ("fine_middle".equals(name)) return GF_FINE_MIDDLE; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 if ("sand".equals(name)) return GF_SAND; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 if ("susp_sand".equals(name)) return GF_SUSP_SAND; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 if ("susp_sand_bed".equals(name)) return GF_SUSP_SAND_BED; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 if ("suspended_sediment".equals(name)) return GF_SUSP_SEDIMENT; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 return -1; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
41 public static class Value implements Serializable { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 private double value; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 private Load load; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 public Value() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 public Value(Load load, double value) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 this.load = load; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 this.value = value; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 public double getValue() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 return value; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
59 public Load getLoad() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
60 return load; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
62 } // class Value |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 public static class Load implements Serializable { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 private int id; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 private String description; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
70 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 private Date startTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 private Date stopTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 public Load() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
77 public Load(int id, String description, Date startTime, Date stopTime) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
78 this.id = id; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 this.description = description; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 this.startTime = startTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 this.stopTime = stopTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
84 public int getId() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 return id; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 public String getDescription() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 return description; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
92 public Date getStartTime() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
93 return startTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
96 public Date getStopTime() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
97 return stopTime; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
98 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
99 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 public boolean isEpoch() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
101 return startTime != null && stopTime != null; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
103 } // class SedimentLoad |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
104 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 public static class Station implements Serializable { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
106 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
107 public static final int BED_LOAD = 0; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
108 public static final int SUSPENDED = 1; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
109 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
110 public interface Visitor { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
111 boolean accept(Station station); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
112 boolean accept(int grainFraction); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 boolean visit(Value value, int grainFraction); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 private double station; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
118 private int type; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
119 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 private List<List<Value>> grainFractions; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
122 private Station next; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
123 private Station prev; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
124 |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 public Station() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 this(BED_LOAD, 0.0); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 public Station(int type, double station) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 grainFractions = new ArrayList<List<Value>>(GF_MAX+1); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 for (int i = 0; i < GF_MAX+1; ++i) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 grainFractions.add(new ArrayList<Value>()); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 this.type = type; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 this.station = station; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 public double getStation() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
139 return station; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 public int getType() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 return type; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
146 public void setNext(Station next) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
147 this.next = next; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
148 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
149 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
150 public Station getNext() { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
151 return next; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
152 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
153 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
154 public void setPrev(Station prev) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
155 this.prev = next; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
156 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
157 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
158 public Station getPrev() { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
159 return prev; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
160 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
161 |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
162 public void addValue(int grainFraction, Value value) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 grainFractions.get(grainFraction).add(value); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
164 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
165 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
166 public boolean hasGrainFraction(String grainFraction) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
167 return hasGrainFraction(grainFractionIndex(grainFraction)); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
168 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
169 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
170 public boolean hasGrainFraction(int grainFraction) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
171 List<Value> values = grainFractions.get(grainFraction); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
172 return !values.isEmpty(); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
173 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
174 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
175 public void visit(Visitor visitor) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
176 if (!visitor.accept(this)) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
177 return; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
178 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
179 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
180 for (int i = 0; i < GF_MAX+1; ++i) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
181 List<Value> values = grainFractions.get(i); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
182 if (values.isEmpty() || !visitor.accept(i)) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
183 continue; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
184 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
185 for (Value value: values) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
186 if (!visitor.visit(value, i)) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
187 break; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
188 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
189 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
190 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
192 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
193 public boolean inside(double a, double b) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
194 return station >= a && station <= b; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
195 } |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
196 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
197 public double findValueByLoadId(int id) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
198 for (List<Value> values: grainFractions) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
199 double value = findValueByLoadId(values, id); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
200 if (!Double.isNaN(value)) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
201 return value; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
202 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
203 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
204 return Double.NaN; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
205 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
206 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
207 private static final double findValueByLoadId( |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
208 List<Value> values, |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
209 int id |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
210 ) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
211 // List is ordered by station id -> binary search. |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
212 int lo = 0, hi = values.size()-1; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
213 while (lo <= hi) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
214 int mid = (lo + hi)/2; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
215 Value v = values.get(mid); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
216 int xid = v.getLoad().getId(); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
217 if (xid < id) hi = mid-1; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
218 else if (xid > id) lo = mid+1; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
219 else return v.getValue(); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
220 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
221 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
222 return Double.NaN; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
223 } |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
224 } // class Station |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
225 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
226 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
227 private List<List<Station>> stations; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
228 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
229 public SedimentLoadData() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
230 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
231 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
232 public SedimentLoadData(Collection<Station> stations) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
233 setStations(stations); |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
234 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
235 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
236 public void setStations(Collection<Station> stations) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
237 TreeMap<Double, List<Station>> same = |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
238 new TreeMap<Double, List<Station>>(EpsilonComparator.CMP); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
239 for (Station station: stations) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
240 Double key = station.getStation(); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
241 List<Station> sts = same.get(key); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
242 if (sts == null) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
243 sts = new ArrayList<Station>(2); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
244 same.put(key, sts); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
245 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
246 sts.add(station); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
247 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
248 this.stations = new ArrayList<List<Station>>(same.values()); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
249 wireNeighbors(); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
250 } |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
251 |
8034
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
252 private void wireNeighbors() { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
253 for (int i = 0, N = stations.size()-1; i < N; ++i) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
254 for (Station current: stations.get(i)) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
255 int type = current.getType(); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
256 NEXT: for (int j = i+1; j < N; ++j) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
257 for (Station next: stations.get(j)) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
258 if (next.getType() == type) { |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
259 current.setNext(next); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
260 next.setPrev(current); |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
261 break NEXT; |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
262 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
263 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
264 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
265 } |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
266 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
267 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
268 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
269 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |