Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / morphometry / fillElevationValues / ValueAndDistance.java @ 59

History | View | Annotate | Download (980 Bytes)

1
package es.unex.sextante.morphometry.fillElevationValues;
2

    
3
public class ValueAndDistance
4
         implements
5
            Comparable {
6

    
7
   private final double m_dValue;
8
   private final double m_dDist;
9

    
10

    
11
   public ValueAndDistance(final double dValue,
12
                           final double dDistance) {
13

    
14
      m_dValue = dValue;
15
      m_dDist = dDistance;
16

    
17
   }
18

    
19

    
20
   public double getDist() {
21

    
22
      return m_dDist;
23

    
24
   }
25

    
26

    
27
   public double getValue() {
28

    
29
      return m_dValue;
30

    
31
   }
32

    
33

    
34
   public int compareTo(final Object ob) throws ClassCastException {
35

    
36
      if (!(ob instanceof ValueAndDistance)) {
37
         throw new ClassCastException();
38
      }
39

    
40
      final double dValue = ((ValueAndDistance) ob).getDist();
41
      final double dDif = this.m_dDist - dValue;
42

    
43
      if (dDif > 0.0) {
44
         return 1;
45
      }
46
      else if (dDif < 0.0) {
47
         return -1;
48
      }
49
      else {
50
         return 0;
51
      }
52

    
53
   }
54

    
55
}