Mercurial > dive4elements > river
changeset 4852:9790a284246c
RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 12:27:00 +0100 |
parents | a1ce76091ade |
children | a0949259181e |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java |
diffstat | 2 files changed, 35 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java Wed Jan 23 12:12:22 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java Wed Jan 23 12:27:00 2013 +0100 @@ -20,12 +20,18 @@ private CallContext context; + public static enum KM_MODE { RANGE, LOCATIONS, NONE }; + + double[] kmRange; + Double from; Double to; Double step; + private KM_MODE mode; + public RangeAccess(FLYSArtifact artifact, CallContext context) { super(artifact); @@ -33,6 +39,29 @@ } + /** Evaluate the ld_mode data of artifact. */ + public KM_MODE getKmRangeMode() { + if (mode != null) { + return mode; + } + String modeData = getString("ld_mode"); + + if (modeData == null || modeData.length() == 0) { + mode = KM_MODE.NONE; + } + else if (modeData.equals("distance")) { + mode = KM_MODE.RANGE; + } + else if (modeData.equals("locations")) { + mode = KM_MODE.LOCATIONS; + } + else { + mode = KM_MODE.NONE; + } + + return mode; + } + /** * Return sorted array of locations at which stuff was calculated * (from ld_locations data), null if not parameterized this way.
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Wed Jan 23 12:12:22 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Wed Jan 23 12:27:00 2013 +0100 @@ -5,6 +5,8 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.Config; import de.intevation.artifacts.common.utils.XMLUtils; + +import de.intevation.flys.artifacts.access.RangeAccess; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.StaticWKmsArtifact; import de.intevation.flys.artifacts.WINFOArtifact; @@ -52,8 +54,6 @@ /** The logger that is used in this utility. */ private static Logger logger = Logger.getLogger(FLYSUtils.class); - public static enum KM_MODE { RANGE, LOCATIONS, NONE }; - /** * An enum that represents the 5 possible WQ modes in FLYS. The 5 values are * <i>QFREE</i> <i>QGAUGE</i> <i>WGAUGE</i> <i>WFREE</i> and <i>NONE</i>. @@ -219,19 +219,10 @@ } } - public static KM_MODE getKmRangeMode(FLYSArtifact flys) { - String mode = flys.getDataAsString("ld_mode"); - - if (mode == null || mode.length() == 0) { - return KM_MODE.NONE; - } - if (mode.equals("distance")) { - return KM_MODE.RANGE; - } - if (mode.equals("locations")) { - return KM_MODE.LOCATIONS; - } - return KM_MODE.NONE; + // TODO Moved to RangeAccess. Resolve remaining calls. + private static RangeAccess.KM_MODE getKmRangeMode(FLYSArtifact flys) { + RangeAccess rangeAccess = new RangeAccess(flys, null); + return rangeAccess.getKmRangeMode(); } /**