]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/data/AltitudeRange.java
Version 1, September 2006
[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          * Add a value to the range
15          * @param inValue value to add, only positive values considered
16          */
17         public void addValue(Altitude inAltitude)
18         {
19                 if (inAltitude != null)
20                 {
21                         int altValue = inAltitude.getValue(_format);
22                         _range.addValue(altValue);
23                         if (_format == Altitude.FORMAT_NONE)
24                         {
25                                 _format = inAltitude.getFormat();
26                         }
27                 }
28         }
29
30
31         /**
32          * @return true if positive data values were found
33          */
34         public boolean hasData()
35         {
36                 return (_range.hasData());
37         }
38
39
40         /**
41          * @return minimum value, or -1 if none found
42          */
43         public int getMinimum()
44         {
45                 return _range.getMinimum();
46         }
47
48
49         /**
50          * @return maximum value, or -1 if none found
51          */
52         public int getMaximum()
53         {
54                 return _range.getMaximum();
55         }
56
57
58         /**
59          * @return the altitude format used
60          */
61         public int getFormat()
62         {
63                 return _format;
64         }
65 }