[Dive4elements-commits] [PATCH] Datacage: toValue/fromValue: Use constant instead of hard coded number

Wald Commits scm-commit at wald.intevation.org
Tue Apr 9 08:28:13 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1365488887 -7200
# Node ID 7e837c5c377b3a3243a4473922a41bc031213219
# Parent  47e5bc64d3de13a7c18af6040865f39449804cfc
Datacage: toValue/fromValue: Use constant instead of hard coded number.

diff -r 47e5bc64d3de -r 7e837c5c377b flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java
--- 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;
         }
     }
 


More information about the Dive4elements-commits mailing list