Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Calculation4Access.java @ 4812:65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 18 Jan 2013 19:33:26 +0100 |
parents | |
children | 61ebb6fb2ac4 |
comparison
equal
deleted
inserted
replaced
4811:a06e443f159a | 4812:65bfb6faa538 |
---|---|
1 package de.intevation.flys.artifacts.access; | |
2 | |
3 import de.intevation.flys.artifacts.FLYSArtifact; | |
4 | |
5 import de.intevation.flys.artifacts.model.Segment; | |
6 | |
7 import java.util.Collections; | |
8 import java.util.List; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 | |
12 import de.intevation.flys.utils.DoubleUtil; | |
13 import de.intevation.flys.utils.FLYSUtils; | |
14 | |
15 public class Calculation4Access | |
16 extends RiverAccess | |
17 { | |
18 private static Logger log = Logger.getLogger(Calculation4Access.class); | |
19 | |
20 protected List<Segment> segments; | |
21 | |
22 protected double [] fromToStep; | |
23 | |
24 protected Boolean isQ; | |
25 | |
26 protected Boolean isRange; | |
27 | |
28 public Calculation4Access() { | |
29 } | |
30 | |
31 public Calculation4Access(FLYSArtifact artifact) { | |
32 super(artifact); | |
33 } | |
34 | |
35 public List<Segment> getSegments() { | |
36 if (segments == null) { | |
37 String input = getString("wq_values"); | |
38 if (input == null || (input = input.trim()).length() == 0) { | |
39 log.warn("no wq_values given"); | |
40 segments = Collections.<Segment>emptyList(); | |
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 double [] fromTo = FLYSUtils.getKmRange(artifact); | |
71 | |
72 if (fromTo == null) { | |
73 return null; | |
74 } | |
75 | |
76 Double dStep = getDouble("ld_step"); | |
77 if (dStep == null) { | |
78 return null; | |
79 } | |
80 | |
81 fromToStep = new double [] { | |
82 fromTo[0], | |
83 fromTo[1], | |
84 DoubleUtil.round(dStep / 1000d) | |
85 }; | |
86 } | |
87 return fromToStep; | |
88 } | |
89 } | |
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |