Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / gridCategorical / fragstatsArea / ClassInfo.java @ 59

History | View | Annotate | Download (2.55 KB)

1
package es.unex.sextante.gridCategorical.fragstatsArea;
2

    
3
import es.unex.sextante.math.simpleStats.SimpleStats;
4

    
5
public class ClassInfo {
6

    
7
   private double            m_dArea               = 0;
8
   private int               m_iAreaInCells        = 0;
9
   private double            m_dPerimeter          = 0;
10
   private int               m_iPerimeterInCells   = 0;
11
   private double            m_dLargestPatchArea   = 0;
12
   private double            m_dTotalLandscapeArea = 0;
13
   private int               m_iPatches            = 0;
14
   private final SimpleStats m_Area;
15
   private final SimpleStats m_RadiusOfGyration;
16

    
17

    
18
   public ClassInfo() {
19

    
20
      m_Area = new SimpleStats();
21
      m_RadiusOfGyration = new SimpleStats();
22

    
23
   }
24

    
25

    
26
   public void setTotalLandscapeArea(final double dArea) {
27

    
28
      m_dTotalLandscapeArea = dArea;
29

    
30
   }
31

    
32

    
33
   public void add(final PatchInfo info) {
34

    
35
      m_iPatches++;
36
      m_dArea += info.getArea();
37
      m_iAreaInCells += info.getAreaInCells();
38
      m_dPerimeter += info.getPerimeter();
39
      m_iPerimeterInCells += info.getPerimeterInCells();
40
      m_dLargestPatchArea = Math.max(m_dLargestPatchArea, info.getArea());
41
      m_Area.addValue(info.getArea());
42
      m_RadiusOfGyration.addValue(info.getRadiusOfGyration());
43

    
44
   }
45

    
46

    
47
   public double getTotalArea() {
48

    
49
      return m_dArea;
50

    
51
   }
52

    
53

    
54
   public double getPercentageOfLandscape() {
55

    
56
      return m_dArea / m_dTotalLandscapeArea * 100;
57

    
58
   }
59

    
60

    
61
   public int getPatchesCount() {
62

    
63
      return m_iPatches;
64

    
65
   }
66

    
67

    
68
   public double getPatchDensity() {
69

    
70
      return m_iPatches * 10000. / m_dTotalLandscapeArea * 100;
71

    
72
   }
73

    
74

    
75
   public double getTotalEdge() {
76

    
77
      return m_dPerimeter;
78

    
79
   }
80

    
81

    
82
   public double getEdgeDensity() {
83

    
84
      return m_dPerimeter * 10000. / m_dTotalLandscapeArea;
85

    
86
   }
87

    
88

    
89
   public double getLandscapeShapeIndex() {
90

    
91
      int min;
92
      final int n = (int) Math.floor(Math.sqrt(m_dArea));
93
      final double m = m_dArea - n * n;
94

    
95
      if (m == 0) {
96
         min = 4 * n;
97
      }
98
      else if (m_dArea > n * (n + 1)) {
99
         min = 4 * n + 4;
100
      }
101
      else {
102
         min = 4 * n + 2;
103
      }
104

    
105
      return (double) m_iPerimeterInCells / (double) min;
106
   }
107

    
108

    
109
   public double getLargestPatchIndex() {
110

    
111
      return m_dLargestPatchArea / m_dTotalLandscapeArea * 100;
112

    
113
   }
114

    
115

    
116
   public SimpleStats getPatchAreaDistribution() {
117

    
118
      return m_Area;
119

    
120
   }
121

    
122

    
123
   public SimpleStats getRadiusOfGyrationDistribution() {
124

    
125
      return m_RadiusOfGyration;
126

    
127
   }
128

    
129
}