Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / closestpts / PtAndDistance.java @ 59

History | View | Annotate | Download (925 Bytes)

1
package es.unex.sextante.closestpts;
2

    
3
public class PtAndDistance
4
         implements
5
            Comparable {
6

    
7
   private final Point3D m_Pt;
8
   private final double  m_dDist;
9

    
10

    
11
   public PtAndDistance(final Point3D pt,
12
                        final double dDistance) {
13

    
14
      m_Pt = pt;
15
      m_dDist = dDistance;
16

    
17
   }
18

    
19

    
20
   public double getDist() {
21

    
22
      return m_dDist;
23

    
24
   }
25

    
26

    
27
   public Point3D getPt() {
28

    
29
      return m_Pt;
30

    
31
   }
32

    
33

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

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

    
40
      final double dValue = ((PtAndDistance) 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
}