Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / dataset / io / TestWriterParams.java @ 2443

History | View | Annotate | Download (4.35 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.dal.coverage.dataset.io;
23

    
24
import org.gvsig.fmap.dal.coverage.BaseTestCase;
25
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
26
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
27
import org.gvsig.fmap.dal.coverage.store.RasterWriter;
28
import org.gvsig.raster.impl.store.ParamsImpl;
29
import org.gvsig.raster.impl.store.ParamsImpl.ParamImpl;
30

    
31

    
32
/**
33
 * Prueba para la inserci?n y extracci?n de par?metros de los driver de escritura.
34
 * Lee primero los valores asignados en la inicializaci?n y luego hace algunas
35
 * variaciones comprobando que los resultados sean correctos.
36
 *
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class TestWriterParams extends BaseTestCase {
41
        private RasterWriter grw = null;
42
        private ParamsImpl wp = null;
43

    
44
        public void start() throws Exception {
45
                this.setUp();
46
                this.testStack();
47
        }
48

    
49
        protected void doSetUp() throws Exception {
50
                System.err.println("TestWriterParams running...");
51
                
52
                try {
53
                        super.doSetUp();
54
                } catch (Exception e) {
55
                        e.printStackTrace();
56
                }
57
                
58
                //Extensi?n gestionada por gdal
59
                try {
60
                        grw = manager.createWriter("prueba.tif");
61
                } catch (NotSupportedExtensionException e) {
62
                        e.printStackTrace();
63
                } catch (RasterDriverException e) {
64
                        e.printStackTrace();
65
                }
66
                wp = (ParamsImpl)grw.getParams();
67
        }
68

    
69
        public void testStack(){
70
                ParamImpl param;
71
//                String blockSize = "512";
72
//                Param param = wp.getParamById("blocksize");
73
//                blockSize = param.list[((Integer) param.defaultValue).intValue()];
74

    
75
                String photometric = "RGB";
76
                param = (ParamsImpl.ParamImpl)wp.getParamById("photometric");
77
                photometric = param.getList()[((Integer) param.getDefaultValue()).intValue()];
78

    
79
                String interleave = "BAND";
80
                param = (ParamsImpl.ParamImpl)wp.getParamById("interleave");
81
                interleave = param.getList()[((Integer) param.getDefaultValue()).intValue()];
82

    
83
                String compression = "NONE";
84
                param = (ParamsImpl.ParamImpl)wp.getParamById("compression");
85
                compression = param.getList()[((Integer) param.getDefaultValue()).intValue()];
86

    
87
                String tfw = (String) ((ParamsImpl.ParamImpl)wp.getParamById("tfw")).getDefaultValue().toString();
88

    
89
//                assertEquals(blockSize, "512");
90
//                assertEquals(georef, "true");
91
                assertEquals(photometric, "RGB");
92
                assertEquals(interleave, "BAND");
93
                assertEquals(compression, "NONE");
94
                assertEquals(tfw, "false");
95

    
96
                wp.changeParamValue("blocksize", "6"/*"256"*/);
97
                //wp.changeParamValue("georef", "false");
98
                wp.changeParamValue("photometric", "1"/*"MINISBLACK"*/);
99
                wp.changeParamValue("interleave", "1"/*"PIXEL"*/);
100
                wp.changeParamValue("compression", "0"/*LZW*/);
101
                wp.changeParamValue("tfw", "true");
102

    
103
//                param = wp.getParamById("blocksize");
104
//                blockSize = param.list[((Integer)param.defaultValue).intValue()];
105
                param = (ParamsImpl.ParamImpl)wp.getParamById("photometric");
106
                photometric = param.getList()[Integer.parseInt((String) param.getDefaultValue())];
107
                param = (ParamsImpl.ParamImpl)wp.getParamById("interleave");
108
                interleave = param.getList()[Integer.parseInt((String) param.getDefaultValue())];
109
                param = (ParamsImpl.ParamImpl)wp.getParamById("compression");
110
                compression = param.getList()[Integer.parseInt((String) param.getDefaultValue())];
111
                tfw = (String) ((ParamsImpl.ParamImpl)wp.getParamById("tfw")).getDefaultValue().toString();
112

    
113
//                assertEquals(blockSize, "256");
114
//                assertEquals(georef, "false");
115
                assertEquals(photometric, "MINISBLACK");
116
                assertEquals(interleave, "PIXEL");
117
                assertEquals(compression, "LZW");
118
                assertEquals(tfw, "true");
119
        }
120
}