Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/access/Calculation4Access.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Calculation4Access.java@f2e7f07f608d |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.access; | |
2 | |
3 import org.dive4elements.river.artifacts.FLYSArtifact; | |
4 | |
5 import org.dive4elements.river.artifacts.model.Segment; | |
6 | |
7 import java.util.Collections; | |
8 import java.util.List; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 | |
12 import org.dive4elements.river.utils.DoubleUtil; | |
13 | |
14 public class Calculation4Access | |
15 extends RangeAccess | |
16 { | |
17 private static Logger log = Logger.getLogger(Calculation4Access.class); | |
18 | |
19 protected List<Segment> segments; | |
20 | |
21 protected double [] fromToStep; | |
22 | |
23 protected Boolean isQ; | |
24 | |
25 protected Boolean isRange; | |
26 | |
27 | |
28 public Calculation4Access(FLYSArtifact artifact) { | |
29 super(artifact, null); | |
30 } | |
31 | |
32 public List<Segment> getSegments() { | |
33 if (segments == null) { | |
34 String input = getString("wq_values"); | |
35 if (input == null || (input = input.trim()).length() == 0) { | |
36 log.warn("no wq_values given"); | |
37 segments = Collections.<Segment>emptyList(); | |
38 } | |
39 else { | |
40 segments = Segment.parseSegments(input); | |
41 } | |
42 } | |
43 return segments; | |
44 } | |
45 | |
46 public boolean isQ() { | |
47 if (isQ == null) { | |
48 Boolean value = getBoolean("wq_isq"); | |
49 isQ = value != null && value; | |
50 } | |
51 return isQ; | |
52 } | |
53 | |
54 public boolean isRange() { | |
55 if (isRange == null) { | |
56 String mode = getString("ld_mode"); | |
57 isRange = mode == null || mode.equals("distance"); | |
58 } | |
59 return isRange; | |
60 } | |
61 | |
62 public double [] getFromToStep() { | |
63 if (fromToStep == null) { | |
64 // XXX: Is this really needed in this calculation? | |
65 if (!isRange()) { | |
66 return null; | |
67 } | |
68 | |
69 // XXX: FLYSArtifact sucks! | |
70 // TODO further use RangeAccess functionality. | |
71 double [] fromTo = getKmRange(); | |
72 | |
73 if (fromTo == null) { | |
74 return null; | |
75 } | |
76 | |
77 Double dStep = getDouble("ld_step"); | |
78 if (dStep == null) { | |
79 return null; | |
80 } | |
81 | |
82 fromToStep = new double [] { | |
83 fromTo[0], | |
84 fromTo[1], | |
85 DoubleUtil.round(dStep / 1000d) | |
86 }; | |
87 } | |
88 return fromToStep; | |
89 } | |
90 } | |
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |