Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8047:c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 17 Jul 2014 11:19:59 +0200 |
parents | 86fa217c24d5 |
children | cde6d2a9ec32 |
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; |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
13 import java.util.Collections; |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
14 import java.util.Comparator; |
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
|
15 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
|
16 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
|
17 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
|
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 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
|
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 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
|
22 { |
8041
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
23 public static final int GF_UNKNOWN = -1; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
24 public static final int GF_COARSE = 0; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
25 public static final int GF_FINE_MIDDLE = 1; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
26 public static final int GF_SAND = 2; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
27 public static final int GF_SUSP_SAND = 3; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
28 public static final int GF_SUSP_SAND_BED = 4; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
29 public static final int GF_SUSP_SEDIMENT = 5; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
30 public static final int GF_TOTAL = 6; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
31 public static final int GF_BED_LOAD = 7; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
32 public static final int GF_SUSPENDED_LOAD = 8; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
33 public static final int GF_MAX = 8; |
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
|
34 |
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 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 if ("suspended_sediment".equals(name)) return GF_SUSP_SEDIMENT; |
8041
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
42 if ("total".equals(name)) return GF_TOTAL; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
43 if ("bed_load".equals(name)) return GF_BED_LOAD; |
01ad09af0975
Sediment load: Recognize grain fractions 'total', 'bed_load' and 'suspended_load' from pre-calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8040
diff
changeset
|
44 if ("suspended_load".equals(name)) return GF_SUSPENDED_LOAD; |
8039
3a769d5fb733
Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8038
diff
changeset
|
45 return GF_UNKNOWN; |
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
|
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 |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
48 public interface Visitor { |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
49 void visit(Station station); |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
50 } |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
51 |
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
|
52 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
|
53 |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
54 public interface Filter { |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
55 boolean accept(Value value); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
56 } |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
57 |
8047
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
58 public interface Visitor { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
59 void visit(Value value); |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
60 } |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
61 |
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
|
62 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
|
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 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
|
65 |
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 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
|
67 } |
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 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
|
70 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
|
71 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
|
72 } |
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 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
|
75 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
|
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 |
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 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
|
79 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
|
80 } |
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 } // 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
|
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 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
|
85 |
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 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
|
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 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
|
89 |
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 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
|
91 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
|
92 |
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 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
|
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 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 } |
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 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
|
104 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
|
105 } |
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 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
|
108 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
|
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 |
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 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
|
112 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
|
113 } |
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 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
|
116 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
|
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 |
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 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
|
120 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
|
121 } |
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
|
122 } // 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
|
123 |
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
|
124 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
|
125 |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
126 public static final int BED_LOAD = 1; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
127 public static final int SUSPENDED = 2; |
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
|
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 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
|
130 |
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 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
|
132 |
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 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
|
134 |
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
|
135 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
|
136 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
|
137 |
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
|
138 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
|
139 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
|
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 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
|
143 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
|
144 for (int i = 0; i < GF_MAX+1; ++i) { |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
145 grainFractions.add(null); |
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
|
146 } |
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
|
147 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
|
148 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
|
149 } |
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
|
150 |
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
|
151 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
|
152 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
|
153 } |
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
|
154 |
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
|
155 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
|
156 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
|
157 } |
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
|
158 |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
159 public boolean isType(int type) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
160 return (this.type & type) == type; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
161 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
162 |
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
|
163 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
|
164 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
|
165 } |
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
|
166 |
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
|
167 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
|
168 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
|
169 } |
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
|
170 |
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
|
171 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
|
172 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
|
173 } |
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
|
174 |
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
|
175 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
|
176 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
|
177 } |
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
|
178 |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
179 public Station getNext(boolean isKMUp) { |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
180 return isKMUp ? getNext() : getPrev(); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
181 } |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
182 |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
183 public Station getPrev(boolean isKMUp) { |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
184 return isKMUp ? getPrev() : getNext(); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
185 } |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
186 |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
187 public void merge(Station other) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
188 this.type |= other.type; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
189 for (int i = 0, N = grainFractions.size(); i < N; ++i) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
190 grainFractions.set(i, |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
191 mergeValues(grainFractions.get(i), other.grainFractions.get(i))); |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
192 } |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
193 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
194 |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
195 private static final Comparator<Value> ID_CMP = new Comparator<Value>() { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
196 @Override |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
197 public int compare(Value a, Value b) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
198 return a.getLoad().getId() - b.getLoad().getId(); |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
199 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
200 }; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
201 |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
202 private static List<Value> mergeValues(List<Value> a, List<Value> b) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
203 if (a == null) return b; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
204 if (b == null) return a; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
205 a.addAll(b); |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
206 // re-establish id order. |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
207 Collections.sort(a, ID_CMP); |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
208 return a; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
209 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
210 |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
211 public Station nextByType(int type, boolean isKMUp) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
212 for (Station curr = this; curr != null; curr = curr.getNext(isKMUp)) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
213 if (curr.isType(type)) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
214 return curr; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
215 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
216 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
217 return null; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
218 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
219 |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
220 public Station prevByType(int type, boolean isKMUp) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
221 for (Station curr = this; curr != null; curr = curr.getPrev(isKMUp)) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
222 if (curr.isType(type)) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
223 return curr; |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
224 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
225 } |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
226 return null; |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
227 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
228 |
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
|
229 public void addValue(int grainFraction, Value value) { |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
230 List<Value> values = grainFractions.get(grainFraction); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
231 if (values == null) { |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
232 values = new ArrayList<Value>(); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
233 grainFractions.set(grainFraction, values); |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
234 } |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
235 values.add(value); |
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
|
236 } |
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
|
237 |
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
|
238 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
|
239 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
|
240 } |
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
|
241 |
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
|
242 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
|
243 List<Value> values = grainFractions.get(grainFraction); |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
244 return values != null && !values.isEmpty(); |
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
|
245 } |
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
|
246 |
8047
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
247 public void filterGrainFraction( |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
248 int grainFraction, |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
249 Value.Filter filter, |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
250 Value.Visitor visitor |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
251 ) { |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
252 List<Value> values = grainFractions.get(grainFraction); |
8047
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
253 if (values != null && !values.isEmpty()) { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
254 for (Value value: values) { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
255 if (filter.accept(value)) { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
256 visitor.visit(value); |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
257 } |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
258 } |
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
|
259 } |
8047
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
260 } |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
261 |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
262 public List<Value> filterGrainFraction(int grainFraction, Value.Filter filter) { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
263 final List<Value> result = new ArrayList<Value>(); |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
264 filterGrainFraction(grainFraction, filter, new Value.Visitor() { |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
265 @Override |
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
266 public void visit(Value value) { |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
267 result.add(value); |
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
|
268 } |
8047
c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8044
diff
changeset
|
269 }); |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
270 return result; |
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
|
271 } |
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
|
272 |
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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 } |
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
|
279 } |
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
|
280 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
|
281 } |
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
|
282 |
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
|
283 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
|
284 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
|
285 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
|
286 ) { |
8036
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
287 if (values == null) { |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
288 return Double.NaN; |
17542d100e75
Throw out old visitor model and use grain fraction filters instead. Fixed neighborhood wirinng of measument stations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8035
diff
changeset
|
289 } |
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
|
290 // 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 } |
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
|
300 |
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
|
301 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
|
302 } |
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
|
303 } // 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
|
304 |
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
|
305 |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
306 private 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
|
307 |
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
|
308 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
|
309 } |
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
|
310 |
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
|
311 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
|
312 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
|
313 } |
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
|
314 |
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
|
315 public void setStations(Collection<Station> stations) { |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
316 TreeMap<Double, Station> same = |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
317 new TreeMap<Double, Station>(EpsilonComparator.CMP); |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
318 |
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
|
319 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
|
320 Double key = station.getStation(); |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
321 Station st = same.get(key); |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
322 if (st == null) { |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
323 same.put(key, station); |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
324 } else { |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
325 st.merge(station); |
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
|
326 } |
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
|
327 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
328 this.stations = new Station[same.size()]; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
329 int i = 0; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
330 for (Station station: same.values()) { |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
331 this.stations[i++] = station; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
332 } |
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
|
333 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
|
334 } |
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
|
335 |
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
|
336 private void wireNeighbors() { |
8044
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
337 for (int i = 1; i < stations.length; ++i) { |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
338 stations[i-1].setNext(stations[i]); |
86fa217c24d5
Sediment load: Merge measurement stations if they have the same km. The chaining was too complicated to build algorithms on top of it.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8041
diff
changeset
|
339 stations[i].setPrev(stations[i-1]); |
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
|
340 } |
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
|
341 } |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
342 |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
343 private void recursiveFindStations( |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
344 double a, double b, |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
345 int lo, int hi, |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
346 Visitor visitor |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
347 ) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
348 while (lo >= hi) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
349 int mid = (lo+hi)/2; |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
350 Station st = stations[mid]; |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
351 double station = st.getStation(); |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
352 if (station < a) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
353 hi = mid-1; |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
354 } else if (station > b) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
355 lo = mid+1; |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
356 } else { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
357 recursiveFindStations(a, b, lo, mid-1, visitor); |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
358 visitor.visit(st); |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
359 lo = mid+1; |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
360 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
361 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
362 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
363 |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
364 public void findStations(double a, double b, Visitor visitor) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
365 if (a > b) { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
366 double t = a; a = b; b = t; |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
367 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
368 recursiveFindStations(a, b, 0, stations.length-1, visitor); |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
369 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
370 |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
371 public List<Station> findStations(double a, double b) { |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
372 final List<Station> result = new ArrayList<Station>(); |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
373 findStations(a, b, new Visitor() { |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
374 @Override |
8038
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
375 public void visit(Station station) { |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
376 result.add(station); |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
377 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
378 }); |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
379 return result; |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
380 } |
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
|
381 } |
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
|
382 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |