Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8242:f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
This also includes a bit cleanup to move the sqRelationTimeInterval check
to the creation of the load list in SedimentLoadData allLoads.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 09 Sep 2014 11:13:37 +0200 |
parents | 61fd22f65bd4 |
children | 5ffbf97766f7 |
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; |
8240
61fd22f65bd4
(issue1448) Actually filter out not matching sq_time_interval_ids
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8239
diff
changeset
|
19 import java.util.Iterator; |
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
|
20 |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
21 import org.apache.log4j.Logger; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
22 |
8201
4b8c5a08de04
Make it compile again.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8199
diff
changeset
|
23 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
|
24 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 public 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
|
26 { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8201
diff
changeset
|
27 private static Logger log = Logger.getLogger(SedimentLoadData.class); |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
28 |
8177
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_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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 |
8208
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
41 public static final String [] GF_NAMES = { |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
42 "coarse", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
43 "fine_middle", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
44 "sand", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
45 "susp_sand", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
46 "susp_sand_bed", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
47 "suspended_sediment", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
48 "total", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
49 "bed_load", |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
50 "bed_load_susp_sand" |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
51 }; |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
52 |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
53 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
|
54 /* 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
|
55 /* 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
|
56 /* 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
|
57 /* 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
|
58 /* 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
|
59 /* 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
|
60 /* 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
|
61 /* 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
|
62 /* 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
|
63 }; |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
64 |
8209
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
65 public static final int measurementStationType(int grainFraction) { |
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
66 return grainFraction < 0 || grainFraction >= MEASUREMENT_STATION_GF.length |
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
67 ? Station.UNKNOWN |
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
68 : MEASUREMENT_STATION_GF[grainFraction]; |
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
69 } |
5114b643a6d6
Fixed broken build.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8208
diff
changeset
|
70 |
8208
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
71 public static final int grainFractionIndex(String name) { |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
72 for (int i = 0; i < GF_NAMES.length; ++i) { |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
73 if (GF_NAMES[i].equals(name)) { |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
74 return i; |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
75 } |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
76 } |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
77 return GF_UNKNOWN; |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
78 } |
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
79 |
8208
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
80 public static final String grainFractionName(int index) { |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
81 return index >= 0 && index < GF_NAMES.length |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
82 ? GF_NAMES[index] |
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
83 : "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
|
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 |
8208
2badb2ca5f89
Sediment load: converted grain fraction name to an array lookup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8202
diff
changeset
|
86 |
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
|
87 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
|
88 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
|
89 } |
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
|
90 |
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
|
91 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
|
92 |
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
|
93 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
|
94 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
|
95 } |
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
|
96 |
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
|
97 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
|
98 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
|
99 } |
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
|
100 |
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
|
101 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
|
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 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
|
104 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 public 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
|
106 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
107 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
108 public 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
|
109 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
|
110 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
|
111 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
114 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
|
115 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 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
|
118 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
|
119 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 } // 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
|
121 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
124 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
126 private int kind; |
8239
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
127 private Integer sqTiId; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 private 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
|
130 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 private 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
|
132 private Date stopTime; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
133 private Date sqStartTime; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
134 private Date sqStopTime; |
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
|
135 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 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
|
137 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 |
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
|
139 public Load( |
8237
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
140 int id, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
141 int kind, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
142 String description, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
143 Date startTime, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
144 Date stopTime, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
145 Integer sqTiId, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
146 Date sqStartTime, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
147 Date sqStopTime |
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
|
148 ) { |
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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 this.stopTime = stopTime; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
154 this.sqStartTime = sqStartTime; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
155 this.sqStopTime = sqStopTime; |
8239
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
156 this.sqTiId = sqTiId; |
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
|
157 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
158 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
159 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
|
160 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
|
161 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 |
8239
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
163 public Integer getSQRelationTimeIntervalId() { |
8237
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8228
diff
changeset
|
164 return sqTiId; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
165 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
166 |
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
|
167 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
|
168 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
|
169 } |
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
|
170 |
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
|
171 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
|
172 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
|
173 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
174 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
175 public 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
|
176 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
|
177 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache 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 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
|
180 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
|
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 |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
183 public Date getSQStartTime() { |
8228
2f63c6c84540
(issue1448) Fix return values of SQ time interval accessors
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8216
diff
changeset
|
184 return sqStartTime; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
185 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
186 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
187 public Date getSQStopTime() { |
8228
2f63c6c84540
(issue1448) Fix return values of SQ time interval accessors
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8216
diff
changeset
|
188 return sqStopTime; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
189 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
190 |
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
|
191 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
|
192 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
|
193 } |
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
|
194 } // 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
|
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 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
|
197 |
8048
cde6d2a9ec32
Sediment Load: Added table to figure out where grain fractions are measured.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
202 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
|
203 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
204 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
|
205 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
206 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
|
207 |
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
|
208 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
|
209 |
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
|
210 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
|
211 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
|
212 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
213 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 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
|
218 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
219 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
|
220 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
|
221 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
222 |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
223 public void allLoads(Collection<Load> loads) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
224 for (List<Value> values: grainFractions) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
225 if (values != null) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
226 for (Value value: values) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
227 loads.add(value.getLoad()); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
228 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
229 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
230 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
231 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
232 |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
233 public void allOfficialLoads(Collection<Load> loads) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
234 for (List<Value> values: grainFractions) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
235 if (values != null) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
236 for (Value value: values) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
237 Load load = value.getLoad(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
238 if (load.getKind() == 1) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
239 loads.add(value.getLoad()); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
240 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
241 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
242 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
243 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
244 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
245 |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
246 public void allLoads(Collection<Load> loads, Integer sqRelationTimeInterval) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
247 |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
248 for (List<Value> values: grainFractions) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
249 if (values == null) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
250 continue; |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
251 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
252 for (Value value: values) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
253 Load load = value.getLoad(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
254 Integer sqId = load.getSQRelationTimeIntervalId(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
255 if ((sqRelationTimeInterval == null) |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
256 || sqId != null && sqId.equals(sqRelationTimeInterval)) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
257 loads.add(load); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
258 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
259 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
260 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
261 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
262 |
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
|
263 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
|
264 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
|
265 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
266 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
267 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
|
268 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
|
269 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
270 |
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
|
271 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
|
272 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
|
273 } |
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
|
274 |
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
|
275 public void setPrev(Station prev) { |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
276 this.prev = prev; |
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
|
277 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
278 |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
279 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
|
280 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
|
281 } |
b6e7cfcabf2c
Wire the neighbors to the measurement stations together. This eases the lookup for same types (suspended or bed load).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8033
diff
changeset
|
282 |
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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 } |
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
|
289 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
290 |
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
|
291 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
|
292 @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
|
293 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
|
294 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
|
295 } |
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
|
296 }; |
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
|
297 |
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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 // 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
|
303 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
|
304 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
|
305 } |
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
|
306 |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
307 public Station prevByType(int type) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
308 for (Station curr = this; curr != null; curr = curr.getPrev()) { |
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
|
309 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
|
310 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
|
311 } |
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
|
312 } |
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
|
313 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
|
314 } |
aa622bddfdac
Directly chain stations with the same km position together. This ease some summations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8036
diff
changeset
|
315 |
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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 } |
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
|
322 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
|
323 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
324 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
325 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
|
326 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
|
327 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
328 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
333 |
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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 ) { |
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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 } |
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
|
345 } |
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
|
346 } |
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
|
347 } |
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
|
348 |
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
|
349 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
|
350 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
|
351 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
|
352 @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
|
353 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
|
354 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
|
355 } |
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
|
356 }); |
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
|
357 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
|
358 } |
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
|
359 |
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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 } |
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 } |
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
|
367 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
|
368 } |
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
|
369 |
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
|
370 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
|
371 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
|
372 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
|
373 ) { |
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
|
374 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
|
375 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
|
376 } |
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
|
377 // 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 int xid = v.getLoad().getId(); |
8100
786bb4f87e8d
Fix binarysearch logic in SedimentLoadData
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8092
diff
changeset
|
383 if (xid > id) hi = mid-1; |
786bb4f87e8d
Fix binarysearch logic in SedimentLoadData
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8092
diff
changeset
|
384 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
|
385 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
|
386 } |
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
|
387 |
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
|
388 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
|
389 } |
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
|
390 } // 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
|
391 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
392 |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
393 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
|
394 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
395 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
|
396 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
397 |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
398 public SedimentLoadData(Collection<Station> stations, boolean kmUp) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
399 setStations(stations, kmUp); |
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
|
400 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
401 |
8092
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
402 public Station[] getStations() { |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
403 return stations; |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
404 } |
7d4be7a6a2b1
Expose sedimentLoad stations
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8058
diff
changeset
|
405 |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
406 public void setStations(Collection<Station> stations, boolean kmUp) { |
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
|
407 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
|
408 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
|
409 |
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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 } 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
|
416 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
|
417 } |
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
|
418 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
419 this.stations = new Station[same.size()]; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
420 int i = 0; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
421 for (Station station: same.values()) { |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
422 this.stations[i++] = station; |
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
423 } |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
424 wireNeighbors(kmUp); |
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
|
425 } |
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
|
426 |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
427 private void wireNeighbors(boolean kmUp) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
428 if (kmUp) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
429 for (int i = stations.length - 1; i > 0; --i) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
430 stations[i-1].setPrev(stations[i]); |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
431 } |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
432 } |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
433 else { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
434 for (int i = 1; i < stations.length; ++i) { |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
435 stations[i].setPrev(stations[i-1]); |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8186
diff
changeset
|
436 } |
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
|
437 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
438 } |
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 |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
440 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
|
441 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
|
442 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
|
443 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
|
444 ) { |
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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 } 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
|
452 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
|
453 } 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
|
454 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
|
455 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
|
456 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
|
457 } |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
458 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
459 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
460 |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
461 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
|
462 @Override |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
463 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
|
464 return a.getId() - b.getId(); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
465 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
466 }; |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
467 |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
468 public static final Comparator<Load> LOAD_TI_CMP = new Comparator<Load>() { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
469 @Override |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
470 public int compare(Load a, Load b) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
471 Date a_start = a.getStartTime(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
472 Date a_stop = a.getStopTime(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
473 Date b_start = b.getStartTime(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
474 Date b_stop = b.getStopTime(); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
475 if (a_start == null && b_start == null) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
476 return 0; |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
477 } else if (a_start != null) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
478 return a_start.compareTo(b_start); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
479 } else if (a_stop != null) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
480 return a_stop.compareTo(b_stop); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
481 } else { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
482 return 1; |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
483 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
484 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
485 }; |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
486 |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
487 public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
488 @Override |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
489 public int compare(Load a, Load b) { |
8239
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
490 Integer a_id = a.getSQRelationTimeIntervalId(); |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
491 Integer b_id = b.getSQRelationTimeIntervalId(); |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
492 if (a_id == null && b_id == null) { |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
493 return 0; |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
494 } |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
495 if (a_id == null) { |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
496 return -1; |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
497 } |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
498 if (b_id == null) { |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
499 return 1; |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
500 } |
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
501 return a_id - b_id; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
502 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
503 }; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
504 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
505 /** Find all loads in the range a/b with the according sq_time_interval */ |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
506 public Collection<Load> findLoads(double a, double b, final Integer sqRelationTimeInterval) { |
8239
b207eeb66edd
(issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8237
diff
changeset
|
507 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
508 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
509 findStations(a, b, new Visitor() { |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
510 @Override |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
511 public void visit(Station station) { |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
512 station.allLoads(loads, sqRelationTimeInterval); |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
513 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
514 }); |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
515 |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
516 return loads; |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
517 } |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
518 |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
519 /** Find all official loads with a distinct time interval id */ |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
520 public Collection<Load> findUniqueTiOfficialLoads(double a, double b) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
521 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_TI_CMP); |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
522 |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
523 findStations(a, b, new Visitor() { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
524 @Override |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
525 public void visit(Station station) { |
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
526 station.allOfficialLoads(loads); |
8240
61fd22f65bd4
(issue1448) Actually filter out not matching sq_time_interval_ids
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8239
diff
changeset
|
527 } |
8242
f8ea1a7ecde6
(issue1448) Fix info service for epoch / periods and off epoch
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8240
diff
changeset
|
528 }); |
8240
61fd22f65bd4
(issue1448) Actually filter out not matching sq_time_interval_ids
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8239
diff
changeset
|
529 |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
530 return loads; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
531 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
532 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
533 /** Get a list of loads with unique sq_time_intervals. |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
534 * |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
535 * This is mainly a convenience function for the SedimentLoadInfoService. |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
536 */ |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
537 public Collection<Load> findUniqueTimeIntervalLoads(double a, double b) { |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
538 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP); |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
539 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
540 findStations(a, b, new Visitor() { |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
541 @Override |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
542 public void visit(Station station) { |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
543 station.allLoads(loads); |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
544 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
545 }); |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
546 |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
547 return loads; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
548 } |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
549 |
8123
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
550 public Collection<Load> findLoads(double a, double b) { |
8140
369fbb28f5d0
Added missing generics parameter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8139
diff
changeset
|
551 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
|
552 |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
553 findStations(a, b, new Visitor() { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
554 @Override |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
555 public void visit(Station station) { |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
556 station.allLoads(loads); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
557 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
558 }); |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
559 |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
560 return loads; |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
561 } |
4a2ef6895557
Sediment load: Fixed findStations() and add findLoads().
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8100
diff
changeset
|
562 |
8035
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 } |
8040
f1500a524b76
Replace station list with a plain array.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8039
diff
changeset
|
567 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
|
568 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
569 |
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
|
570 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
|
571 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
|
572 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
|
573 @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
|
574 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
|
575 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
|
576 } |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
577 }); |
f2dc7992b8a3
Sediment loads from cache are sorted in station order so range filters
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
578 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
|
579 } |
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
|
580 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
581 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |