changeset 5604:7e837c5c377b

Datacage: toValue/fromValue: Use constant instead of hard coded number.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 09 Apr 2013 08:28:07 +0200
parents 47e5bc64d3de
children 6372fd8bfb00
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Mon Apr 08 17:23:20 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Tue Apr 09 08:28:07 2013 +0200
@@ -23,6 +23,8 @@
 
     public static final String FUNCTION_NAMESPACE_URI = "dc";
 
+    public static final double FAR_AWAY = 99999d;
+
     public static final class Entry {
 
         String        name;
@@ -162,17 +164,17 @@
         Object from      = args.get(2);
 
         if (!(mode instanceof String)){
-            return -99999d;
+            return -FAR_AWAY;
         }
 
         if (mode.equals("locations")) {
             if (!(locations instanceof String)) {
-                return -99999d;
+                return -FAR_AWAY;
             }
             String loc = ((String)locations).replace(" ", "");
             String[] split = loc.split(",");
             if (split.length < 1) {
-                return -99999d;
+                return -FAR_AWAY;
             }
             try {
                 double min = Double.parseDouble(split[0]);
@@ -185,23 +187,23 @@
                 return min;
             }
             catch (NumberFormatException nfe) {
-                return -99999d;
+                return -FAR_AWAY;
             }
         }
         else if (mode.equals("distance")) {
             if (!(from instanceof String)) {
-                return -99999d;
+                return -FAR_AWAY;
             }
             String f = (String)from;
             try {
                 return Double.parseDouble(f);
             }
             catch(NumberFormatException nfe) {
-                return -99999d;
+                return -FAR_AWAY;
             }
         }
         else {
-            return -99999d;
+            return -FAR_AWAY;
         }
     }
 
@@ -214,18 +216,18 @@
         Object to        = args.get(2);
 
         if (!(mode instanceof String)){
-            return 99999d;
+            return FAR_AWAY;
         }
 
         if (mode.equals("locations")) {
             if (!(locations instanceof String)) {
-                return 99999d;
+                return FAR_AWAY;
             }
             try {
                 String loc = ((String)locations).replace(" ", "");
                 String[] split = loc.split(",");
                 if (split.length < 1) {
-                    return 99999d;
+                    return FAR_AWAY;
                 }
                 double max = Double.parseDouble(split[0]);
                 for (int i = 1; i < split.length; ++i) {
@@ -237,12 +239,12 @@
                 return max;
             }
             catch (NumberFormatException nfe) {
-                return 99999d;
+                return FAR_AWAY;
             }
         }
         else if (mode.equals("distance")) {
             if (!(to instanceof String)) {
-                return 99999d;
+                return FAR_AWAY;
             }
             else {
                 String t = (String)to;
@@ -250,12 +252,12 @@
                     return Double.parseDouble(t);
                 }
                 catch(NumberFormatException nfe) {
-                    return 99999d;
+                    return FAR_AWAY;
                 }
             }
         }
         else {
-            return 99999d;
+            return FAR_AWAY;
         }
     }
 

http://dive4elements.wald.intevation.org