1 |
package appl.parallel.test; |
2 |
|
3 |
|
4 |
import java.awt.Rectangle; |
5 |
import java.io.File; |
6 |
import java.io.FileNotFoundException; |
7 |
|
8 |
import appl.parallel.spmd.split.WritableGridPartition; |
9 |
import appl.parallel.util.PartitionUtil; |
10 |
import appl.util.RasterUtil; |
11 |
import de.schmitzm.geotools.data.WritableGridRaster; |
12 |
import de.schmitzm.geotools.io.GeoExportUtil; |
13 |
import de.schmitzm.geotools.io.GeoImportUtil; |
14 |
|
15 |
/** |
16 |
* Simple JUnit Test |
17 |
* @author Dominik Appl |
18 |
*/ |
19 |
public class PartitialGridTest { |
20 |
|
21 |
/** |
22 |
* @throws java.lang.Exception |
23 |
*/ |
24 |
public void setUp() throws Exception { |
25 |
} |
26 |
|
27 |
/** |
28 |
* @throws java.lang.Exception |
29 |
*/ |
30 |
public void tearDown() throws Exception { |
31 |
} |
32 |
|
33 |
/** |
34 |
* Test method for {@link appl.parallel.util.PartitionUtil#getPartitialGrid2D(schmitzm.data.WritableGrid, Rectangle, int)}. |
35 |
*/ |
36 |
public void testGetPartitialGrid2D() { |
37 |
WritableGridRaster baseGrid; |
38 |
try { |
39 |
baseGrid = GeoImportUtil |
40 |
.readGridRasterFromArcInfoASCII(new File( |
41 |
"../Xulu-Data/minigrid.arc")); |
42 |
GeoExportUtil.writeGridRasterToArcInfoASCII(baseGrid, new File( |
43 |
"TEST_getpartitialgrid2d_o1")); |
44 |
RasterUtil.printGrid(baseGrid, 4, 0, "base partition"); |
45 |
//make five partitions: four quarters and one inner partition |
46 |
RasterUtil.printGrid(PartitionUtil.getPartitialGrid2D(baseGrid, new Rectangle(0, 0, 5, 5),0),4,0, "upperleft partition"); |
47 |
RasterUtil.printGrid(PartitionUtil.getPartitialGrid2D(baseGrid,new Rectangle( 5, 0, 5, 5),0),4,0, "upperright partition"); |
48 |
RasterUtil.printGrid(PartitionUtil.getPartitialGrid2D(baseGrid, new Rectangle(0, 5, 5, 5),0),4,0, "lowerleft partition"); |
49 |
RasterUtil.printGrid(PartitionUtil.getPartitialGrid2D(baseGrid, new Rectangle(5, 5, 5, 5),0),4,0, "lowerright partition"); |
50 |
WritableGridPartition baseGrid2 = PartitionUtil.getPartitialGrid2D(baseGrid,new Rectangle( 0, 0, 10, 10),0); |
51 |
System.out.println("********************* Starting test 2 *********************"); |
52 |
RasterUtil.printGrid(baseGrid2,5,0, "baseGrid2"); |
53 |
WritableGridPartition baseGrid2partition = PartitionUtil.getPartitialGrid2D(baseGrid, new Rectangle(0, 0, 5, 5),0); |
54 |
RasterUtil.printGrid(baseGrid2partition,5,0, "baseGrid2 partition"); |
55 |
baseGrid2.setPartition(baseGrid2partition, new Rectangle(1,1,5,5)); |
56 |
RasterUtil.printGrid(baseGrid2,5,0, "baseGrid2 (after setting baseGrid2-partition to (1,1)"); |
57 |
|
58 |
} catch (FileNotFoundException e) { |
59 |
// TODO Auto-generated catch block |
60 |
e.printStackTrace(); |
61 |
} catch (Exception e) { |
62 |
// TODO Auto-generated catch block |
63 |
e.printStackTrace(); |
64 |
} |
65 |
|
66 |
} |
67 |
} |