Statistics
| Revision:

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

History | View | Annotate | Download (3.66 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;
23

    
24
import org.gvsig.fmap.dal.coverage.BaseTestCase;
25
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
26
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
27
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
28
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
29
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
30
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
31
/**
32
 * Test que compara los resultados de la llamada getWindowRaster en coordenadas pixel 
33
 * y coordenadas reales para comprobar que producen el mismo resultado para la misma extensi?n.
34
 * 
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class TestGetWindowRasterMrSID extends BaseTestCase {
38
        private String path1 = baseDir + "q101866.sid";
39
        private RasterDataStore   f1       = null;        
40
        private RasterDataStore   f2       = null;        
41
        private RasterQuery        query   = null;
42
        protected Buffer           buf1  = null;
43
        protected Buffer           buf2  = null;
44
        
45
        public void start() throws Exception {
46
                this.setUp();
47
                this.testStack();
48
        }
49
        
50
        protected void doSetUp() throws Exception {
51
                System.err.println("TestGetWindowRasterMrSID running...");
52
                
53
                try {
54
                        super.doSetUp();
55
                } catch (Exception e) {
56
                        e.printStackTrace();
57
                }
58
                
59
                try {
60
                        f1 = manager.open(path1);
61
                        f2 = manager.open(path1);
62
                } catch (NotSupportedExtensionException e1) {
63
                        e1.printStackTrace();
64
                } catch (RasterDriverException e1) {
65
                        e1.printStackTrace();
66
                }
67
        }
68
        
69
        public void testStack() {
70
                query = manager.createQuery();
71
                query.setAllDrawableBands();
72
                try {
73
                        query.setAreaOfInterest(f1.getExtent().getMin().getX(), f1.getExtent().getMax().getY(), f1.getExtent().width(), f1.getExtent().height());
74
                        buf1 = f1.query(query);
75
                } catch (RasterDriverException e) {
76
                        e.printStackTrace();
77
                } catch (InvalidSetViewException e) {
78
                        e.printStackTrace();
79
                } catch (ProcessInterruptedException e) {
80
                        e.printStackTrace();
81
                }
82
                
83
                try {
84
                        query.setAreaOfInterest(0, 0, (int)f2.getWidth(), (int)f2.getHeight());
85
                        buf2 = f2.query(query);
86
                } catch (InvalidSetViewException e) {
87
                        e.printStackTrace();
88
                } catch (ProcessInterruptedException e) {
89
                        e.printStackTrace();
90
                } catch (RasterDriverException e) {
91
                        e.printStackTrace();
92
                }
93
                
94
                for (int band = 0; band < buf1.getBandCount(); band++) {
95
                        for (int row = 0; row < buf1.getHeight(); row++) {
96
                                for (int col = 0; col < buf1.getWidth(); col++) {
97
                                        //try {
98
                                        assertEquals(buf1.getElemByte(row, col, band), buf2.getElemByte(row, col, band));
99
                                        //System.out.println(buf1.getElemByte(row, col, band) + " " + buf2.getElemByte(row, col, band));
100
                                        /*} catch (AssertionFailedError e) {
101
                                                System.out.println(band + " " + line + " " + column);
102
                                                
103
                                        }*/
104
                                }
105
                        }
106
                }
107
        }
108
}