annotate artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedDifferencesAccess.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 76113b975829
children 0a5239a1e46e
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4528
diff changeset
9 package org.dive4elements.river.artifacts.access;
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
3898
95d699c769fb Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3887
diff changeset
11 import java.util.Arrays;
95d699c769fb Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3887
diff changeset
12
95d699c769fb Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3887
diff changeset
13 import org.apache.log4j.Logger;
95d699c769fb Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3887
diff changeset
14
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4528
diff changeset
15 import org.dive4elements.artifacts.CallContext;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
16 import org.dive4elements.river.artifacts.D4EArtifact;
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
17 import org.dive4elements.river.utils.RiverUtils;
8186
a1ceacf15d3a Removed NASTY package clash. We had too org.dive4elements.river.util packages.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6241
diff changeset
18 import org.dive4elements.river.backend.utils.StringUtil;
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 public class BedDifferencesAccess
8544
76113b975829 (Issue1754) Make BedDifference calculation range dependent.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
22 extends RangeAccess
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
24 private static Logger log = Logger.getLogger(BedDifferencesAccess.class);
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
26 private String yearEpoch;
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
27 private String [] diffs;
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
29 private String [][] differenceArtifactIds;
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
30
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
31 public BedDifferencesAccess(D4EArtifact artifact) {
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 super(artifact);
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 }
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 public String getYearEpoch() {
3898
95d699c769fb Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3887
diff changeset
36 yearEpoch = getString("ye_select");
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 return yearEpoch;
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 }
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
40 public String [] getDiffs() {
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
41 if (diffs == null) {
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
42 diffs = getString("diffids").split("#");
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
43 if (log.isDebugEnabled()) {
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
44 log.debug("diffs: " + Arrays.toString(diffs));
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
45 }
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 }
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
47 return diffs;
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
48 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
49
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
50 public String[][] getDifferenceArtifactIds() {
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
51
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
52 if (differenceArtifactIds == null) {
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
53 String [] diffs = getDiffs();
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
54 differenceArtifactIds = new String[diffs.length/2][2];
6210
165086b1e66d I1035: Fixed calculation of multiple bed height differences.
Raimund Renkert <rrenkert@intevation.de>
parents: 6148
diff changeset
55 for (int i = 0; i < diffs.length/2; i++) {
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
56 String diff1 = StringUtil.unbracket(diffs[0 + 2*i]);
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
57 String diff2 = StringUtil.unbracket(diffs[1 + 2*i]);
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
58 String[] diff1parts = diff1.split(";");
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
59 String[] diff2parts = diff2.split(";");
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
60 if (log.isDebugEnabled()) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
61 log.debug("creating 2 artifacts."
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
62 + diff1parts[0] + "; " + diff2parts[0]);
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
63 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
64 differenceArtifactIds[i][0] = diff1parts[0];
6210
165086b1e66d I1035: Fixed calculation of multiple bed height differences.
Raimund Renkert <rrenkert@intevation.de>
parents: 6148
diff changeset
65 differenceArtifactIds[i][1] = diff2parts[0];
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
66 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
67 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
68
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
69 return differenceArtifactIds;
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
70 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
71
6241
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
72 public String[] getDifferenceArtifactNamePairs() {
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
73
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
74 String [] diffs = getDiffs();
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
75 String [] result = new String[diffs.length/2];
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
76 for (int i = 0; i < diffs.length/2; i++) {
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
77 String diff1 = StringUtil.unbracket(diffs[0 + 2*i]);
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
78 String diff2 = StringUtil.unbracket(diffs[1 + 2*i]);
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
79 String[] diff1parts = diff1.split(";");
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
80 String[] diff2parts = diff2.split(";");
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
81 result[i] = diff1parts[3] + " - " + diff2parts[3];
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
82 }
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
83
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
84 return result;
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
85 }
db97448f21b7 Add method to get name pairs of differences
Andre Heinecke <aheinecke@intevation.de>
parents: 6210
diff changeset
86
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
87 public int [][] extractHeightIds(CallContext context) {
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
88 String [][] artifactsIds = getDifferenceArtifactIds();
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
89 int [][] ids = new int[artifactsIds.length][2];
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
90 for (int i = 0; i < artifactsIds.length; ++i) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
91 D4EArtifact a1 = RiverUtils.getArtifact(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
92 artifactsIds[i][0], context);
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
93 D4EArtifact a2 = RiverUtils.getArtifact(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8544
diff changeset
94 artifactsIds[i][1], context);
6148
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
95 ids[i][0] = getHeightId(a1);
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
96 ids[i][1] = getHeightId(a2);
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
97 }
b12ec9f240bc Bed height differences: DO NOT STORE ARTIFACTS IN CALCULATION RESULTS!!! This would lead to caching them which is _really_ wrong.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
98 return ids;
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 }
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
101 public static int getHeightId(D4EArtifact artifact) {
3887
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 Access a = new Access(artifact);
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 return a.getInteger("height_id");
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 }
a1c79d84e3cd New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 }
4528
cbd0fafcb26b Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3898
diff changeset
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org