root / trunk / extensions / extRasterTools-SE / src-test / org / gvsig / fmap / raster / grid / roi / TestRoiStatistics.java @ 13340
History | View | Annotate | Download (2.54 KB)
1 |
package org.gvsig.fmap.raster.grid.roi; |
---|---|
2 |
|
3 |
import junit.framework.TestCase; |
4 |
|
5 |
import org.gvsig.raster.buffer.RasterBufferInvalidException; |
6 |
import org.gvsig.raster.dataset.IBuffer; |
7 |
import org.gvsig.raster.grid.Grid; |
8 |
import org.gvsig.raster.grid.GridExtent; |
9 |
import org.gvsig.raster.grid.OutOfGridException; |
10 |
|
11 |
/*import com.iver.cit.gvsig.fmap.core.GeneralPathX;
|
12 |
import com.iver.cit.gvsig.fmap.core.IGeometry;
|
13 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory;*/
|
14 |
|
15 |
/**
|
16 |
* Test sobre la obtenci?n de estad?sticas de regiones de inter?s.
|
17 |
*
|
18 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
19 |
*
|
20 |
*/
|
21 |
public class TestRoiStatistics extends TestCase { |
22 |
Grid grid = null;
|
23 |
GridExtent extent = null;
|
24 |
int cellSize = 1; |
25 |
double xMin = 0; |
26 |
double xMax = 10; |
27 |
double yMin = 0; |
28 |
double yMax = 10; |
29 |
VectorialROI roi = null;
|
30 |
/*GeneralPathX path = null;
|
31 |
IGeometry geometry = null;*/
|
32 |
|
33 |
public void setUp() { |
34 |
int bands[] = {0}; |
35 |
extent = new GridExtent();
|
36 |
extent.setCellSize(cellSize); |
37 |
extent.setXRange(xMin, xMax); |
38 |
extent.setYRange(yMin, yMax); |
39 |
try {
|
40 |
grid = new Grid(extent, extent, IBuffer.TYPE_DOUBLE, bands);
|
41 |
for (int x = 0; x<5; x++) |
42 |
for (int y = 0; y<5; y++){ |
43 |
grid.setCellValue(x, y, 0.0);
|
44 |
} |
45 |
for (int x = 5; x<xMax; x++) |
46 |
for (int y = 0; y<5; y++){ |
47 |
grid.setCellValue(x, y, 1.0);
|
48 |
} |
49 |
for (int x = 0; x<5; x++) |
50 |
for (int y = 5; y<10; y++){ |
51 |
grid.setCellValue(x, y, 2.0);
|
52 |
} |
53 |
for (int x = 5; x<9; x++) |
54 |
for (int y = 5; y<10; y++){ |
55 |
grid.setCellValue(x, y, 3.0);
|
56 |
} |
57 |
} catch (RasterBufferInvalidException e) {
|
58 |
// TODO Auto-generated catch block
|
59 |
e.printStackTrace(); |
60 |
} catch (OutOfGridException e) {
|
61 |
// TODO Auto-generated catch block
|
62 |
e.printStackTrace(); |
63 |
} |
64 |
|
65 |
} |
66 |
|
67 |
public void start() { |
68 |
this.setUp();
|
69 |
this.testStack();
|
70 |
} |
71 |
|
72 |
public void testStack() { |
73 |
|
74 |
/*path = new GeneralPathX();
|
75 |
|
76 |
|
77 |
path.moveTo(4,4);
|
78 |
path.lineTo(4,0);
|
79 |
path.lineTo(0,0);
|
80 |
path.lineTo(0,4);
|
81 |
path.closePath();
|
82 |
|
83 |
geometry=ShapeFactory.createPolygon2D(path);
|
84 |
|
85 |
roi = new VectorialROI(grid);
|
86 |
roi.addGeometry(geometry);
|
87 |
assertEquals(2.0,roi.getMaxValue(),0.0);
|
88 |
assertEquals(2.0,roi.getMeanValue(),0.0);
|
89 |
assertEquals(2.0,roi.getMinValue(),0.0);
|
90 |
|
91 |
|
92 |
path = new GeneralPathX();
|
93 |
|
94 |
path.moveTo(9,4);
|
95 |
path.lineTo(9,2);
|
96 |
path.lineTo(6,2);
|
97 |
path.lineTo(6,4);
|
98 |
path.closePath();
|
99 |
|
100 |
geometry=ShapeFactory.createPolygon2D(path);
|
101 |
|
102 |
roi = new VectorialROI(grid);
|
103 |
roi.addGeometry(geometry);
|
104 |
assertEquals(3.0,roi.getMaxValue(),0.0);
|
105 |
assertEquals(3.0,roi.getMeanValue(),0.0);
|
106 |
assertEquals(3.0,roi.getMinValue(),0.0);*/
|
107 |
} |
108 |
} |