svn-gvsig-desktop / trunk / libraries / libRaster / src-test / org / gvsig / raster / dataset / io / rmf / TestRmfWrite.java @ 11652
History | View | Annotate | Download (3.09 KB)
1 |
/*
|
---|---|
2 |
* Created on 9-ago-2006
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*/
|
25 |
package org.gvsig.raster.dataset.io.rmf; |
26 |
|
27 |
import java.io.FileNotFoundException; |
28 |
import java.io.IOException; |
29 |
|
30 |
import junit.framework.TestCase; |
31 |
|
32 |
import org.gvsig.raster.RasterLibrary; |
33 |
import org.gvsig.raster.buffer.BufferFactory; |
34 |
import org.gvsig.raster.dataset.FileNotOpenException; |
35 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
36 |
import org.gvsig.raster.dataset.RasterDataset; |
37 |
import org.gvsig.raster.dataset.RasterDriverException; |
38 |
import org.gvsig.raster.dataset.properties.HistogramRmfSerializer; |
39 |
import org.gvsig.raster.util.Histogram; |
40 |
|
41 |
/**
|
42 |
* Test de escritura de ficheros rmf.
|
43 |
* Escribe un fichero rmf con distintos bloques y a continuaci?n le pasa un
|
44 |
* test de lectura para comprobar que se ha generado bien.
|
45 |
*
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
47 |
*
|
48 |
*/
|
49 |
public class TestRmfWrite extends TestCase { |
50 |
|
51 |
private RmfBlocksManager manager = null; |
52 |
private String baseDir = "./test-images/"; |
53 |
private String path = baseDir + "miniRaster25x24.tif"; |
54 |
private Histogram histogram = null; |
55 |
|
56 |
static {
|
57 |
RasterLibrary.wakeUp(); |
58 |
} |
59 |
|
60 |
public void start() { |
61 |
this.setUp();
|
62 |
this.testStack();
|
63 |
} |
64 |
|
65 |
public void setUp() { |
66 |
System.err.println("TestRmfWrite running..."); |
67 |
|
68 |
RasterDataset f = null;
|
69 |
try {
|
70 |
f = RasterDataset.open(null, path);
|
71 |
} catch (NotSupportedExtensionException e) {
|
72 |
return;
|
73 |
} catch (RasterDriverException e) {
|
74 |
return;
|
75 |
} |
76 |
BufferFactory ds = new BufferFactory(f);
|
77 |
ds.setAreaOfInterest(); |
78 |
|
79 |
try {
|
80 |
histogram = f.getHistogram().getHistogram(); |
81 |
} catch (FileNotOpenException e) {
|
82 |
e.printStackTrace(); |
83 |
} catch (RasterDriverException e) {
|
84 |
e.printStackTrace(); |
85 |
} |
86 |
|
87 |
} |
88 |
|
89 |
public void testStack(){ |
90 |
manager = new RmfBlocksManager(baseDir + "writetest.rmf"); |
91 |
HistogramRmfSerializer ser = new HistogramRmfSerializer(histogram);
|
92 |
manager.addClient(ser); |
93 |
try {
|
94 |
manager.write(); |
95 |
} catch (FileNotFoundException e) { |
96 |
e.printStackTrace(); |
97 |
} catch (IOException e) { |
98 |
e.printStackTrace(); |
99 |
} |
100 |
|
101 |
//Pasamos el test de lectura para comprobar que se ha generado bien
|
102 |
TestRmfRead t = new TestRmfRead();
|
103 |
t.file = "writetest.rmf";
|
104 |
t.start(); |
105 |
} |
106 |
|
107 |
} |