changeset 8646:8e5c026216fd

(issue1754) Extend RangeAccess to simplyfiy range access where it is assumed that from < to
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 30 Mar 2015 19:27:11 +0200
parents 5c4766ac20ba
children 5f60bd7c4b42
files artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java	Mon Mar 30 19:11:35 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java	Mon Mar 30 19:27:11 2015 +0200
@@ -125,6 +125,16 @@
         return to != null || (to = getDouble("ld_to")) != null;
     }
 
+    /* If left_to_right is set to true this returns
+     * the smaller value of from and to. */
+    public double getFrom(boolean left_to_right) {
+        if (!left_to_right) {
+            return getFrom();
+        }
+        double from = getFrom();
+        double to = getTo();
+        return from > to ? to : from;
+    }
 
     /** Return ld_from data (in km). If not found, the min. */
     public double getFrom() {
@@ -144,6 +154,16 @@
         return from.doubleValue();
     }
 
+    /* If left_to_right is set to true this returns
+     * the larger value of from and to. */
+    public double getTo(boolean left_to_right) {
+        if (!left_to_right) {
+            return getTo();
+        }
+        double from = getFrom();
+        double to = getTo();
+        return from > to ? from : to;
+    }
 
     /** Return ld_to data (in km), if not found, the max. */
     public double getTo() {

http://dive4elements.wald.intevation.org