Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java @ 4850:c9a27912840d
RangeAccess: Add accidentally omitted implementation of getLocations from FLYSUtils.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 12:10:47 +0100 |
parents | 15e55fdbb402 |
children | 9790a284246c |
comparison
equal
deleted
inserted
replaced
4849:f86c8d75fd85 | 4850:c9a27912840d |
---|---|
1 package de.intevation.flys.artifacts.access; | 1 package de.intevation.flys.artifacts.access; |
2 | 2 |
3 import org.apache.log4j.Logger; | 3 import org.apache.log4j.Logger; |
4 | 4 |
5 import gnu.trove.TDoubleArrayList; | |
6 | |
5 import de.intevation.artifacts.CallContext; | 7 import de.intevation.artifacts.CallContext; |
6 import de.intevation.flys.artifacts.FLYSArtifact; | 8 import de.intevation.flys.artifacts.FLYSArtifact; |
9 import de.intevation.flys.artifacts.WINFOArtifact; | |
10 | |
7 import de.intevation.flys.utils.FLYSUtils; | 11 import de.intevation.flys.utils.FLYSUtils; |
12 | |
8 | 13 |
9 /** For the moment, light-weight wrapper around FLYSUtils. */ | 14 /** For the moment, light-weight wrapper around FLYSUtils. */ |
10 // TODO employ 'Caching' like other Accesses, remove usage of FLYSUtils. | 15 // TODO employ 'Caching' like other Accesses, remove usage of FLYSUtils. |
11 public class RangeAccess | 16 public class RangeAccess |
12 extends RiverAccess | 17 extends RiverAccess |
23 | 28 |
24 | 29 |
25 public RangeAccess(FLYSArtifact artifact, CallContext context) { | 30 public RangeAccess(FLYSArtifact artifact, CallContext context) { |
26 super(artifact); | 31 super(artifact); |
27 this.context = context; | 32 this.context = context; |
33 } | |
34 | |
35 | |
36 /** | |
37 * Return sorted array of locations at which stuff was calculated | |
38 * (from ld_locations data), null if not parameterized this way. | |
39 */ | |
40 public double[] getLocations() { | |
41 String locationStr = getString("ld_locations"); | |
42 | |
43 if (locationStr == null || locationStr.length() == 0) { | |
44 if (getArtifact() instanceof WINFOArtifact) { | |
45 WINFOArtifact winfo = (WINFOArtifact) getArtifact(); | |
46 if (winfo.getReferenceStartKm() != null && winfo.getReferenceEndKms() != null) { | |
47 return new double[] | |
48 { | |
49 winfo.getReferenceStartKm().doubleValue(), | |
50 winfo.getReferenceEndKms()[0] | |
51 }; | |
52 } | |
53 } | |
54 return null; | |
55 } | |
56 | |
57 String[] tmp = locationStr.split(" "); | |
58 TDoubleArrayList locations = new TDoubleArrayList(); | |
59 | |
60 for (String l: tmp) { | |
61 try { | |
62 locations.add(Double.parseDouble(l)); | |
63 } | |
64 catch (NumberFormatException nfe) { | |
65 logger.debug(nfe.getLocalizedMessage(), nfe); | |
66 } | |
67 } | |
68 | |
69 locations.sort(); | |
70 | |
71 return locations.toNativeArray(); | |
28 } | 72 } |
29 | 73 |
30 | 74 |
31 /** Return ld_from data (in km). */ | 75 /** Return ld_from data (in km). */ |
32 public double getFrom() { | 76 public double getFrom() { |
81 | 125 |
82 | 126 |
83 public double[] getKmFromTo() { | 127 public double[] getKmFromTo() { |
84 return FLYSUtils.getKmFromTo(this.getArtifact()); | 128 return FLYSUtils.getKmFromTo(this.getArtifact()); |
85 } | 129 } |
86 | |
87 | |
88 /** | |
89 * Return sorted array of locations at which stuff was calculated | |
90 * (from ld_locations data), null if not parameterized this way. | |
91 */ | |
92 public double[] getLocations() { | |
93 return FLYSUtils.getLocations(this.getArtifact()); | |
94 } | |
95 } | 130 } |
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 131 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |