]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/DoubleRange.java
Version 16, February 2014
[GpsPrune.git] / tim / prune / data / DoubleRange.java
index e103759fb7eb20d83eb9f7ca6d94cd2ba675d672..3f252eed6cd2bcfe00bcdc272c2f1f82404dcbba 100644 (file)
@@ -45,6 +45,18 @@ public class DoubleRange
                _empty = false;
        }
 
+       /**
+        * Combine this range with another one
+        * @param inOtherRange other range to add to this one
+        */
+       public void combine(DoubleRange inOtherRange)
+       {
+               if (inOtherRange != null && inOtherRange.getRange() > 1.0)
+               {
+                       addValue(inOtherRange.getMinimum());
+                       addValue(inOtherRange.getMaximum());
+               }
+       }
 
        /**
         * @return true if data values were found
@@ -71,4 +83,30 @@ public class DoubleRange
        {
                return _max;
        }
+
+       /**
+        * @return range, as maximum - minimum
+        */
+       public double getRange()
+       {
+               return _max - _min;
+       }
+
+       /**
+        * @return mid value, halfway between min and max
+        */
+       public double getMidValue()
+       {
+               return (_max + _min) / 2.0;
+       }
+
+       /**
+        * Copy this range into a new object, which can then be modified without changing this one
+        * @return deep copy of this object
+        */
+       public DoubleRange copy()
+       {
+               if (_empty) return new DoubleRange();
+               return new DoubleRange(_min, _max);
+       }
 }