annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java @ 5779:ebec12def170

Datacage: Add a pool of builders to make it multi threadable. XML DOM is not thread safe. Therefore the old implementation only allowed one thread to use the builder at a time. As the complexity of the configuration has increased over time this has become a bottleneck of the whole application because it took quiet some time to build a result. Furthermore the builder code path is visited very frequent. So many concurrent requests were piled up resulting in long waits for the users. To mitigate this problem a round robin pool of builders is used now. Each of the pooled builders has an independent copy of the XML template and can be run in parallel. The number of builders is determined by the system property 'flys.datacage.pool.size'. It defaults to 4.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 21 Apr 2013 12:48:09 +0200
parents 3b12c890b0b2
children
rev   line source
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.access;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
4850
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
5 import gnu.trove.TDoubleArrayList;
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallContext;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import de.intevation.flys.artifacts.FLYSArtifact;
4850
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
8 import de.intevation.flys.artifacts.WINFOArtifact;
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
9
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import de.intevation.flys.utils.FLYSUtils;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11
4850
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
12
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 /** For the moment, light-weight wrapper around FLYSUtils. */
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 // TODO employ 'Caching' like other Accesses, remove usage of FLYSUtils.
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 public class RangeAccess
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 extends RiverAccess
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 {
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 private static Logger logger = Logger.getLogger(RangeAccess.class);
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 private CallContext context;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21
4852
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
22 public static enum KM_MODE { RANGE, LOCATIONS, NONE };
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
23
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
24 double[] kmRange;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
25
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
26 Double from;
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
27
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
28 Double to;
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
29
4825
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
30 Double step;
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
31
4852
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
32 private KM_MODE mode;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
33
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 public RangeAccess(FLYSArtifact artifact, CallContext context) {
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 super(artifact);
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 this.context = context;
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 }
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
4852
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
41 /** Evaluate the ld_mode data of artifact. */
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
42 public KM_MODE getKmRangeMode() {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
43 if (mode != null) {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
44 return mode;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
45 }
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
46 String modeData = getString("ld_mode");
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
47
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
48 if (modeData == null || modeData.length() == 0) {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
49 mode = KM_MODE.NONE;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
50 }
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
51 else if (modeData.equals("distance")) {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
52 mode = KM_MODE.RANGE;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
53 }
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
54 else if (modeData.equals("locations")) {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
55 mode = KM_MODE.LOCATIONS;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
56 }
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
57 else {
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
58 mode = KM_MODE.NONE;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
59 }
5282
14db045d6368 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4853
diff changeset
60
4852
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
61 return mode;
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
62 }
9790a284246c RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4850
diff changeset
63
4850
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
64 /**
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
65 * Return sorted array of locations at which stuff was calculated
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
66 * (from ld_locations data), null if not parameterized this way.
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
67 */
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
68 public double[] getLocations() {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
69 String locationStr = getString("ld_locations");
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
70
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
71 if (locationStr == null || locationStr.length() == 0) {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
72 if (getArtifact() instanceof WINFOArtifact) {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
73 WINFOArtifact winfo = (WINFOArtifact) getArtifact();
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
74 if (winfo.getReferenceStartKm() != null && winfo.getReferenceEndKms() != null) {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
75 return new double[]
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
76 {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
77 winfo.getReferenceStartKm().doubleValue(),
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
78 winfo.getReferenceEndKms()[0]
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
79 };
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
80 }
5665
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
81 else if (winfo.getReferenceStartKm() != null) {
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
82 return new double[]
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
83 {
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
84 winfo.getReferenceStartKm().doubleValue(),
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
85 winfo.getReferenceStartKm().doubleValue()
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
86 };
3b12c890b0b2 Fix RangeAccess.getLocations for Reference Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5282
diff changeset
87 }
4850
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
88 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
89 return null;
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
90 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
91
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
92 String[] tmp = locationStr.split(" ");
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
93 TDoubleArrayList locations = new TDoubleArrayList();
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
94
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
95 for (String l: tmp) {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
96 try {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
97 locations.add(Double.parseDouble(l));
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
98 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
99 catch (NumberFormatException nfe) {
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
100 logger.debug(nfe.getLocalizedMessage(), nfe);
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
101 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
102 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
103
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
104 locations.sort();
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
105
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
106 return locations.toNativeArray();
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
107 }
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
108
c9a27912840d RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4827
diff changeset
109
4827
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
110 /** Return ld_from data (in km). */
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
111 public double getFrom() {
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
112 if (from == null) {
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
113 from = getDouble("ld_from");
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
114 }
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
115
4827
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
116 if (logger.isDebugEnabled()) {
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
117 logger.debug("from: '" + from + "'");
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
118 }
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
119
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
120 return from.doubleValue();
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
121 }
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
122
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
123
4827
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
124 /** Return ld_to data (in km). */
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
125 public double getTo() {
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
126 if (to == null) {
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
127 to = getDouble("ld_to");
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
128 }
4827
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
129
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
130 if (logger.isDebugEnabled()) {
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
131 logger.debug("to: '" + to + "'");
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
132 }
15e55fdbb402 RangeAccess: Doc and debug.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4825
diff changeset
133
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
134 return to.doubleValue();
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
135 }
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
136
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4699
diff changeset
137
4825
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
138 /** Step width for calculation. */
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
139 public Double getStep() {
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
140
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
141 if (step == null) {
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
142 step = getDouble("ld_step");
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
143 }
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
144
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
145 if (logger.isDebugEnabled()) {
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
146 logger.debug("step: '" + step + "'");
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
147 }
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
148
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
149 return step;
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
150 }
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
151
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4824
diff changeset
152
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153 /**
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
154 * Get min and max kilometer, independent of parametization
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 * (ld_from/to vs ld_locations).
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156 */
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 public double[] getKmRange() {
4853
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
158 // TODO store kmRange in field.
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
159 switch (getKmRangeMode()) {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
160 case RANGE: {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
161 return getKmFromTo();
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
162 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
163
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
164 case LOCATIONS: {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
165 double[] locs = getLocations();
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
166 // if no locations, nPE.
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
167 if (locs == null) {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
168 logger.warn("no locations to get km range from.");
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
169 return new double[] { Double.NaN, Double.NaN };
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
170 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
171 return new double[] { locs[0], locs[locs.length-1] };
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
172 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
173
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
174 case NONE: {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
175 double[] locs = getLocations();
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
176 if (locs != null) {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
177 return new double[] { locs[0], locs[locs.length-1] };
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
178 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
179 else {
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
180 return getKmFromTo();
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
181 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
182 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
183 }
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
184
a0949259181e RangeAccess.getKmRange: Extracted from FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
185 return new double[] { Double.NaN, Double.NaN };
4647
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 }
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
188
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
189 public double[] getKmFromTo() {
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
190 return FLYSUtils.getKmFromTo(this.getArtifact());
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
191 }
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
192 }
1fea4243721c Add stubs for GaugeAccess and RangeAccess, for they do not get lost.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
193 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org