Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedDifferencesAccess.java @ 4187:21f4e4b79121
Refactor GaugeDischargeCurveFacet to be able to set a facet name
For adding another output of the GaugeDischargeCurveArtifact it is necessary to
provide to facet instances with different names. Therefore the
GaugeDischargeCurveFacet is extended to set the facet name in the constructor.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 19 Oct 2012 13:25:49 +0200 |
parents | 95d699c769fb |
children | cbd0fafcb26b |
rev | line source |
---|---|
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.access; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
3 import java.util.Arrays; |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
4 |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
5 import org.apache.log4j.Logger; |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
6 |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.artifacts.FLYSArtifact; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.utils.FLYSUtils; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.utils.StringUtil; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 public class BedDifferencesAccess |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 extends RiverAccess |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 { |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
16 private static Logger logger = Logger.getLogger(BedDifferencesAccess.class); |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 private String yearEpoch; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 private String[] diffs; |
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 private CallContext context; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 public BedDifferencesAccess(FLYSArtifact artifact, CallContext context) { |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 super(artifact); |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 this.context = context; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 } |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 public String getYearEpoch() { |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
28 yearEpoch = getString("ye_select"); |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 return yearEpoch; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 } |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public FLYSArtifact[][] getDifferenceArtifacts() { |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
33 diffs = getString("diffids").split("#"); |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
34 logger.debug("diffs: " + Arrays.toString(diffs)); |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
35 FLYSArtifact[][] artifacts = new FLYSArtifact[diffs.length/2][2]; |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
36 for (int i = 0; i < diffs.length; i += 2) { |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
37 String diff1 = StringUtil.unbracket(diffs[0 + 2*i]); |
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
38 String diff2 = StringUtil.unbracket(diffs[1 + 2*i]); |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 String[] diff1parts = diff1.split(";"); |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 String[] diff2parts = diff2.split(";"); |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
41 logger.debug("creating 2 artifacts." + diff1parts[0] + "; " + diff2parts[0]); |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 artifacts[i][0] = FLYSUtils.getArtifact(diff1parts[0], context); |
3898
95d699c769fb
Bedheight difference calculation has chart outpus now.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3887
diff
changeset
|
43 artifacts[i][1] = FLYSUtils.getArtifact(diff2parts[0], context); |
3887
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 } |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 return artifacts; |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 } |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 public static int getHeightId(FLYSArtifact artifact) { |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 Access a = new Access(artifact); |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 return a.getInteger("height_id"); |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 } |
a1c79d84e3cd
New calcultion in MINFO: Bed height difference calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 } |