Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8186:a1ceacf15d3a
Removed NASTY package clash. We had too org.dive4elements.river.util packages.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 04 Sep 2014 13:00:55 +0200 |
parents | 76e1e9d81ce2 |
children | 8d447516b7dd |
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; |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
18 import java.util.TreeSet; |
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
|
19 |
8186
a1ceacf15d3a
Removed NASTY package clash. We had too org.dive4elements.river.util packages.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8185
diff
changeset
|
20 import org.dive4elements.river.backend.utils.EpsilonComparator; |
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
|
21 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
23 { |
8177
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
24 public static final int GF_UNKNOWN = -1; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
25 public static final int GF_COARSE = 0; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
26 public static final int GF_FINE_MIDDLE = 1; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
27 public static final int GF_SAND = 2; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
28 public static final int GF_SUSP_SAND = 3; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
29 public static final int GF_SUSP_SAND_BED = 4; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
30 public static final int GF_SUSP_SEDIMENT = 5; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
31 public static final int GF_TOTAL = 6; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
32 public static final int GF_BED_LOAD = 7; |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
33 public static final int GF_BED_LOAD_SUSP_SAND = 8; |
8185
76e1e9d81ce2
Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents:
8178
diff
changeset
|
34 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
|
35 |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
36 public static final int [] MEASUREMENT_STATION_GF = { |
8177
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
37 /* GF_COARSE */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
38 /* GF_FINE_MIDDLE */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
39 /* GF_SAND */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
40 /* GF_SUSP_SAND */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
41 /* GF_SUSP_SAND_BED */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
42 /* GF_SUSP_SEDIMENT */ Station.SUSPENDED, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
43 /* GF_TOTAL */ Station.BED_LOAD|Station.SUSPENDED, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
44 /* GF_BED_LOAD */ Station.BED_LOAD, |
aa80f9ba56a9
We have to calculate bed load plus suspended sand instead of suspended load.
Tom Gottfried <tom@intevation.de>
parents:
8140
diff
changeset
|
45 /* GF_BED_LOAD_SUSP_SAND */ Station.BED_LOAD |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
46 }; |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
47 |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
48 public static final int measurementStationType(int grainFraction) { |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
49 return grainFraction < 0 || grainFraction >= MEASUREMENT_STATION_GF.length |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
50 ? Station.UNKNOWN |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
51 : MEASUREMENT_STATION_GF[grainFraction]; |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
52 } |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
53 |
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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 if ("bed_load".equals(name)) return GF_BED_LOAD; |
8178
5bab2e57e965
Rev aa80f9ba56a9 was incomplete. Shame on me.
Tom Gottfried <tom@intevation.de>
parents:
8177
diff
changeset
|
63 if ("bed_load_susp_sand".equals(name)) return GF_BED_LOAD_SUSP_SAND; |
8039
3a769d5fb733
Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8038
diff
changeset
|
64 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
|
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 |
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
|
67 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
|
68 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
|
69 } |
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
|
70 |
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
|
71 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
|
72 |
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
|
73 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
|
74 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
|
75 } |
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
|
76 |
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
|
77 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
|
78 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
|
79 } |
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
|
80 |
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
|
81 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
|
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 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
|
84 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
86 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 public 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
|
89 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
|
90 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
|
91 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
92 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
94 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
|
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 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
98 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
|
99 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 } // 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
|
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 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
|
104 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 private int id; |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
106 private int kind; |
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
|
107 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
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 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
|
111 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
|
112 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
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 |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
116 public Load( |
8185
76e1e9d81ce2
Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents:
8178
diff
changeset
|
117 int id, |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
118 int kind, |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
119 String description, |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
120 Date startTime, |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
121 Date stopTime |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
122 ) { |
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
|
123 this.id = id; |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
124 this.kind = kind; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 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
|
126 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
|
127 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
|
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 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
131 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
|
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 |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
134 public int getKind() { |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
135 return kind; |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
diff
changeset
|
136 } |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8050
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 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
|
139 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
|
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 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
|
143 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
|
144 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
147 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
|
148 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
151 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
|
152 } |
8185
76e1e9d81ce2
Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents:
8178
diff
changeset
|
153 } // class Load |
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
|
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 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
|
156 |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
157 public static final int UNKNOWN = 0; |
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
|
158 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
|
159 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
|
160 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
161 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
|
162 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 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
|
164 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
165 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
|
166 |
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
|
167 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
|
168 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
|
169 |
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
|
170 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
|
171 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
|
172 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
173 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
179 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
|
180 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
|
181 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
182 |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
183 public void allLoads(Collection<Load> loads) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
184 for (List<Value> values: grainFractions) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
185 if (values != null) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
186 for (Value value: values) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
187 loads.add(value.getLoad()); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
188 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
189 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
190 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
191 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
192 |
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
|
193 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
|
194 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
|
195 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
196 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
197 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
|
198 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
|
199 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
200 |
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
|
201 public boolean isType(int type) { |
8050
9e79e384aa8b
Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8048
diff
changeset
|
202 return (this.type & type) != 0; |
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
|
203 } |
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 |
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
|
205 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
|
206 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
|
207 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
208 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
209 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
|
210 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
|
211 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
212 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
213 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
|
214 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
|
215 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
216 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
217 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
|
218 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
|
219 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
220 |
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
|
221 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
|
222 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
|
223 } |
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
|
224 |
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
|
225 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
|
226 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
|
227 } |
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
|
228 |
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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 } |
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
|
235 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
236 |
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
|
237 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
|
238 @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
|
239 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
|
240 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
|
241 } |
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
|
242 }; |
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
|
243 |
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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 // 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
|
249 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
|
250 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
|
251 } |
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
|
252 |
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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 } |
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
|
258 } |
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
|
259 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
|
260 } |
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
|
261 |
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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 } |
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
|
267 } |
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
|
268 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
|
269 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
270 |
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 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
|
272 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
|
273 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
|
274 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
|
275 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
|
276 } |
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
|
277 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
|
278 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
279 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
280 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
|
281 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
|
282 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
283 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
284 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
|
285 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
|
286 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
|
287 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
288 |
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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 ) { |
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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 } |
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
|
300 } |
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
|
301 } |
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
|
302 } |
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
|
303 |
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
|
304 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
|
305 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
|
306 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
|
307 @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
|
308 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
|
309 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
|
310 } |
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
|
311 }); |
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
|
312 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
|
313 } |
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
|
314 |
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 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 } |
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
|
321 } |
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
|
322 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
|
323 } |
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
|
324 |
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
|
325 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
|
326 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
|
327 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
|
328 ) { |
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
|
329 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
|
330 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
|
331 } |
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
|
332 // 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 int xid = v.getLoad().getId(); |
8100
786bb4f87e8d
Fix binarysearch logic in SedimentLoadData
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8092
diff
changeset
|
338 if (xid > id) hi = mid-1; |
786bb4f87e8d
Fix binarysearch logic in SedimentLoadData
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8092
diff
changeset
|
339 else if (xid < id) lo = mid+1; |
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
|
340 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
|
341 } |
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
|
342 |
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
|
343 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
|
344 } |
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
|
345 } // 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
|
346 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
347 |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
348 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
|
349 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
350 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
|
351 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
352 |
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
|
353 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
|
354 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
|
355 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
356 |
8092
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
357 public Station[] getStations() { |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
358 return stations; |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
359 } |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
360 |
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
|
361 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
|
362 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
|
363 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
|
364 |
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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 } 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
|
371 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
|
372 } |
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
|
373 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
374 this.stations = new Station[same.size()]; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
375 int i = 0; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
376 for (Station station: same.values()) { |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
377 this.stations[i++] = station; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
378 } |
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
|
379 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
|
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 |
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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
387 } |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
388 |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
389 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
|
390 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
|
391 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
|
392 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
|
393 ) { |
8139
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
394 while (lo <= hi) { |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
395 int mid = (lo+hi)/2; |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
396 Station st = stations[mid]; |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
397 double station = st.getStation(); |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
398 if (station < a) { |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
399 lo = mid+1; |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
400 } else if (station > b) { |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
401 hi = mid-1; |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
402 } else { |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
403 recursiveFindStations(a, b, lo, mid-1, visitor); |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
404 visitor.visit(st); |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
405 lo = mid+1; |
1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8130
diff
changeset
|
406 } |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
407 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
408 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
409 |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
410 public static final Comparator<Load> LOAD_ID_CMP = new Comparator<Load>() { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
411 @Override |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
412 public int compare(Load a, Load b) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
413 return a.getId() - b.getId(); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
414 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
415 }; |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
416 |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
417 public Collection<Load> findLoads(double a, double b) { |
8140
369fbb28f5d0
Added missing generics parameter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8139
diff
changeset
|
418 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
419 |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
420 findStations(a, b, new Visitor() { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
421 @Override |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
422 public void visit(Station station) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
423 station.allLoads(loads); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
424 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
425 }); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
426 |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
427 return loads; |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
428 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
429 |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
434 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
|
435 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
436 |
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
|
437 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
|
438 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
|
439 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
|
440 @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
|
441 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
|
442 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
|
443 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
444 }); |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
445 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
|
446 } |
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
|
447 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
448 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |