Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java @ 8562:c62837ba37f3
(issue1755) Move KM Step handling from Winfo artifact to RangeAccess
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 16 Feb 2015 15:58:52 +0100 |
parents | e3a8aa6eee32 |
children | 8e5c026216fd |
comparison
equal
deleted
inserted
replaced
8561:2b3c8ea6cbee | 8562:c62837ba37f3 |
---|---|
14 | 14 |
15 import org.dive4elements.river.artifacts.D4EArtifact; | 15 import org.dive4elements.river.artifacts.D4EArtifact; |
16 import org.dive4elements.river.artifacts.WINFOArtifact; | 16 import org.dive4elements.river.artifacts.WINFOArtifact; |
17 | 17 |
18 import org.dive4elements.river.utils.RiverUtils; | 18 import org.dive4elements.river.utils.RiverUtils; |
19 import org.dive4elements.river.utils.DoubleUtil; | |
19 | 20 |
20 | 21 |
21 /** For the moment, light-weight wrapper around RiverUtils. */ | 22 /** For the moment, light-weight wrapper around RiverUtils. */ |
22 // TODO employ 'Caching' like other Accesses, remove usage of RiverUtils. | 23 // TODO employ 'Caching' like other Accesses, remove usage of RiverUtils. |
23 public class RangeAccess | 24 public class RangeAccess |
24 extends RiverAccess | 25 extends RiverAccess |
25 { | 26 { |
26 private static Logger log = Logger.getLogger(RangeAccess.class); | 27 private static Logger log = Logger.getLogger(RangeAccess.class); |
27 | 28 |
28 public static enum KM_MODE { RANGE, LOCATIONS, NONE }; | 29 public static enum KM_MODE { RANGE, LOCATIONS, NONE }; |
30 | |
31 /** The default step width between the start end end kilometer. */ | |
32 public static final double DEFAULT_KM_STEPS = 0.1; | |
29 | 33 |
30 double[] kmRange; | 34 double[] kmRange; |
31 | 35 |
32 Double from; | 36 Double from; |
33 | 37 |
212 | 216 |
213 | 217 |
214 public double[] getKmFromTo() { | 218 public double[] getKmFromTo() { |
215 return RiverUtils.getKmFromTo(this.getArtifact()); | 219 return RiverUtils.getKmFromTo(this.getArtifact()); |
216 } | 220 } |
221 | |
222 /** | |
223 * Returns the selected Kms in steps as specified. | |
224 * | |
225 * @return Each step for this range. | |
226 */ | |
227 public double[] getKmSteps() { | |
228 double step = getStep(); | |
229 | |
230 // transform step from 'm' into 'km' | |
231 step = step / 1000; | |
232 | |
233 if (step == 0d) { | |
234 step = DEFAULT_KM_STEPS; | |
235 } | |
236 | |
237 return DoubleUtil.explode(getFrom(), getTo(), step); | |
238 } | |
217 } | 239 } |
218 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 240 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |