# HG changeset patch # User Felix Wolfsteller # Date 1358940420 -3600 # Node ID 9790a284246c0e940815a43173fbd6049f550a15 # Parent a1ce76091ade355425fbb4cf0f56db3e5df18e82 RangeAccess, FLYSUtils; Moved getKmRangeMode implementation to RangeAccess. diff -r a1ce76091ade -r 9790a284246c flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RangeAccess.java --- 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. diff -r a1ce76091ade -r 9790a284246c flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java --- 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 * QFREE QGAUGE WGAUGE WFREE and NONE. @@ -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(); } /**