]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/data/AltitudeRange.java
Version 4, January 2008
[GpsPrune.git] / tim / prune / data / AltitudeRange.java
1 package tim.prune.data;
2
3 /**
4  * Represents a range of altitudes, taking units into account.
5  * Values assumed to be >= 0.
6  */
7 public class AltitudeRange
8 {
9         private IntegerRange _range = new IntegerRange();
10         private int _format = Altitude.FORMAT_NONE;
11
12
13         /**
14          * Clear the altitude range
15          */
16         public void clear()
17         {
18                 _range.clear();
19                 _format = Altitude.FORMAT_NONE;
20         }
21
22
23         /**
24          * Add a value to the range
25          * @param inAltitude value to add, only positive values considered
26          */
27         public void addValue(Altitude inAltitude)
28         {
29                 if (inAltitude != null)
30                 {
31                         int altValue = inAltitude.getValue(_format);
32                         _range.addValue(altValue);
33                         if (_format == Altitude.FORMAT_NONE)
34                         {
35                                 _format = inAltitude.getFormat();
36                         }
37                 }
38         }
39
40
41         /**
42          * @return true if positive data values were found
43          */
44         public boolean hasData()
45         {
46                 return (_range.hasData());
47         }
48
49
50         /**
51          * @return minimum value, or -1 if none found
52          */
53         public int getMinimum()
54         {
55                 return _range.getMinimum();
56         }
57
58
59         /**
60          * @return maximum value, or -1 if none found
61          */
62         public int getMaximum()
63         {
64                 return _range.getMaximum();
65         }
66
67
68         /**
69          * @return the altitude format used
70          */
71         public int getFormat()
72         {
73                 return _format;
74         }
75 }