Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/access/ExtremeAccess.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/access/ExtremeAccess.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.access; | |
2 | |
3 import org.dive4elements.artifacts.CallContext; | |
4 | |
5 import org.dive4elements.river.artifacts.FLYSArtifact; | |
6 | |
7 import org.dive4elements.river.artifacts.model.RangeWithValues; | |
8 | |
9 import org.dive4elements.river.utils.DoubleUtil; | |
10 | |
11 import java.util.ArrayList; | |
12 import java.util.List; | |
13 | |
14 import org.apache.log4j.Logger; | |
15 | |
16 /** Access data used for extreme value analysis. */ | |
17 public class ExtremeAccess | |
18 extends RangeAccess | |
19 { | |
20 /** Our private logger. */ | |
21 private static Logger logger = Logger.getLogger(ExtremeAccess.class); | |
22 | |
23 protected Long start; | |
24 protected Long end; | |
25 | |
26 protected Double percent; | |
27 | |
28 protected String function; | |
29 | |
30 protected List<RangeWithValues> ranges; | |
31 | |
32 | |
33 public ExtremeAccess(FLYSArtifact artifact, CallContext context) { | |
34 super(artifact, context); | |
35 } | |
36 | |
37 | |
38 /** Returns the percent given. */ | |
39 public Double getPercent() { | |
40 | |
41 if (percent == null) { | |
42 percent = getDouble("percent"); | |
43 } | |
44 | |
45 if (logger.isDebugEnabled()) { | |
46 logger.debug("percent: '" + percent + "'"); | |
47 } | |
48 | |
49 return percent; | |
50 } | |
51 | |
52 public String getFunction() { | |
53 if (function == null) { | |
54 function = getString("function"); | |
55 } | |
56 | |
57 if (logger.isDebugEnabled()) { | |
58 logger.debug("function: '" + function + "'"); | |
59 } | |
60 | |
61 return function; | |
62 } | |
63 | |
64 | |
65 /** Find first RangeWithValues for which the given location | |
66 * is within the range and return its values. | |
67 * @return values of first suitable rangewithvalues or null. | |
68 */ | |
69 public double[] getValuesForRange(double location) { | |
70 logger.debug("ExtemeAcces.getValuesForRange"); | |
71 for (RangeWithValues rangeValues: getRanges()) { | |
72 if (rangeValues.inside(location)) { | |
73 return rangeValues.getValues(); | |
74 } | |
75 } | |
76 return null; | |
77 } | |
78 | |
79 | |
80 public List<RangeWithValues> getRanges() { | |
81 | |
82 if (ranges == null) { | |
83 String rangesS = getString("ranges"); | |
84 if (rangesS == null) { | |
85 return null; | |
86 } | |
87 ranges = new ArrayList<RangeWithValues>(); | |
88 DoubleUtil.parseSegments(rangesS, new DoubleUtil.SegmentCallback() { | |
89 @Override | |
90 public void newSegment(double from, double to, double [] values) { | |
91 ranges.add(new RangeWithValues(from, to, values)); | |
92 } | |
93 }); | |
94 } | |
95 | |
96 if (logger.isDebugEnabled()) { | |
97 logger.debug("ranges: " + ranges); | |
98 } | |
99 | |
100 return ranges; | |
101 } | |
102 } | |
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |