Revision 4830

View differences:

org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/series/TestSaveSerialToRmf.java
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.series;
23

  
24
import java.io.File;
25
import java.text.ParseException;
26

  
27
import org.gvsig.fmap.dal.coverage.BaseTestCase;
28
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
29
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
30
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
31
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
32
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
33
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
34
/**
35
 * Saves serial information to rmf file
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class TestSaveSerialToRmf extends BaseTestCase {
40
	private String            path1    = baseDir + "serie1.tif";
41
	private String            path2    = baseDir + "serie2.tif";
42
	private String            path3    = baseDir + "serie3.tif";
43
	private RasterDataStore   f1       = null;	
44
	private RasterDataStore   f2       = null;
45
	private RasterDataStore   f3       = null;
46
	//private RasterQuery       query    = null;
47
	protected Buffer          buf1     = null;
48
	
49
	public void start() throws Exception {
50
		this.setUp();
51
		this.testStack();
52
	}
53
	
54
	protected void doSetUp() throws Exception {
55
		System.err.println("TestSaveSerialToRmf running...");
56
		
57
		try {
58
			super.doSetUp();
59
		} catch (Exception e) {
60
			e.printStackTrace();
61
		}
62
		File a = new File(baseDir + "serie1.rmf");
63
		if(a.exists())
64
			a.delete();
65
		a = new File(baseDir + "serie2.rmf");
66
		if(a.exists())
67
			a.delete();
68
		a = new File(baseDir + "serie3.rmf");
69
		if(a.exists())
70
			a.delete();
71
		
72
		try {
73
			f1 = manager.open(path1);
74
			f2 = manager.open(path2);
75
			f3 = manager.open(path3);
76
		} catch (NotSupportedExtensionException e1) {
77
			e1.printStackTrace();
78
		} catch (RasterDriverException e1) {
79
			e1.printStackTrace();
80
		}
81
	}
82
	
83
	public void testStack() {
84
		TimeSeries serialInfo = null;
85
		try {
86
			serialInfo = f1.getTimeSerials(); //Lo da vacio pq antes hemos borrado el rmf
87
			serialInfo.setName("Katrina");
88
			serialInfo.setDescription("Evoluci?n del katrina");
89
			serialInfo.createNewTimeInterval("25/8/2005-00:05:00", "27/8/2005-14:36:00");
90
			f1.setTimeSerials(serialInfo);   //Salvamos la serie
91
			
92
			serialInfo.setName("Katrina2");
93
			serialInfo.setDescription("Evoluci?n del katrina en otra serie");
94
			serialInfo.createNewTimeInterval(152322, 152400);
95
			f1.setTimeSerials(serialInfo);   //Salvamos la serie
96
			
97
			//------------------------------------
98
			
99
			serialInfo = f2.getTimeSerials();
100
			serialInfo.setName("Katrina");
101
			serialInfo.setDescription("Evoluci?n del katrina");
102
			serialInfo.createNewTimeValue("28/8/2005-00:05:00");
103
			f2.setTimeSerials(serialInfo);
104
			
105
			serialInfo.setName("Katrina2");
106
			serialInfo.setDescription("Evoluci?n del katrina en otra serie");
107
			serialInfo.createNewTimeValue(152438);
108
			f2.setTimeSerials(serialInfo);   //Salvamos la serie
109
			
110
			//------------------------------------
111
			
112
			serialInfo = f3.getTimeSerials();
113
			serialInfo.setName("Katrina");
114
			serialInfo.setDescription("Evoluci?n del katrina");
115
			serialInfo.createNewTimeValue("29/8/2005");
116
			f3.setTimeSerials(serialInfo);
117
			
118
			serialInfo.setName("Katrina2");
119
			serialInfo.setDescription("Evoluci?n del katrina en otra serie");
120
			serialInfo.createNewTimeValue(152550.0);
121
			f3.setTimeSerials(serialInfo);   //Salvamos la serie
122
			
123
		} catch (RmfSerializerException e1) {
124
			// TODO Auto-generated catch block
125
			e1.printStackTrace();
126
		} catch (ParseException e) {
127
			// TODO Auto-generated catch block
128
			e.printStackTrace();
129
		}
130
		
131
		
132
		/*query = manager.createQuery();
133
		query.setAllDrawableBands();
134
		try {
135
			query.setAreaOfInterest(f1.getExtent().getMin().getX(), f1.getExtent().getMax().getY(), f1.getExtent().width(), f1.getExtent().height());
136
			buf1 = f1.query(query);
137
		} catch (RasterDriverException e) {
138
			e.printStackTrace();
139
		} catch (InvalidSetViewException e) {
140
			e.printStackTrace();
141
		} catch (ProcessInterruptedException e) {
142
			e.printStackTrace();
143
		}
144
		
145
		System.out.println("R:" + (buf1.getElemByte(0, 0, 0) & 0xff));
146
		System.out.println("G:" + (buf1.getElemByte(0, 0, 1) & 0xff));
147
		System.out.println("B:" + (buf1.getElemByte(0, 0, 2) & 0xff));*/
148
	}
149
}
0 150

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/series/TestReadDataTDataStore.java
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.series;
23

  
24
import java.text.ParseException;
25

  
26
import org.gvsig.fmap.dal.coverage.BaseTestCase;
27
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
28
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
29
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
30
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException;
31
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
32
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
33
import org.gvsig.fmap.dal.coverage.exception.TimeException;
34
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
35
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
36
/**
37
 * Saves serial information to rmf file
38
 * 
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class TestReadDataTDataStore extends BaseTestCase {
42
	private String            path1    = baseDir + "serie1.tif";
43
	private String            path2    = baseDir + "serie2.tif";
44
	private String            path3    = baseDir + "serie3.tif";
45
	private RasterDataStore   f1       = null;	
46
	private RasterDataStore   f2       = null;
47
	private RasterDataStore   f3       = null;
48
	//private RasterQuery       query    = null;
49
	protected Buffer          buf1     = null;
50
	
51
	public void start() throws Exception {
52
		this.setUp();
53
		this.testStack();
54
	}
55
	
56
	protected void doSetUp() throws Exception {
57
		System.err.println("TestSaveSerialToRmf running...");
58
		
59
		try {
60
			super.doSetUp();
61
		} catch (Exception e) {
62
			e.printStackTrace();
63
		}
64
		
65
		try {
66
			f1 = manager.open(path1);
67
			f2 = manager.open(path2);
68
			f3 = manager.open(path3);
69
		} catch (NotSupportedExtensionException e1) {
70
			e1.printStackTrace();
71
		} catch (RasterDriverException e1) {
72
			e1.printStackTrace();
73
		}
74
	}
75
	
76
	public void testStack() {
77
		/*try {
78
			RasterDataStore store = new DefaultTRasterStore(f1);
79
			store.addTemporalDataStore(f2);
80
			store.addTemporalDataStore(f3);*/
81
			
82
			//Selecci?n temporal por valor
83
			
84
			/*TimeInfo tInfo = new DefaultTimeInfo();
85
			tInfo.addValue("29/8/2005"); //Blue
86
			store.setTime(tInfo);
87
			
88
			Buffer buf = readData(store);
89
			byte[] data = new byte[3];
90
			buf.getElemByte(0, 0, data);
91
			assertEquals(0, data[0]);
92
			assertEquals(0, data[1]);
93
			assertEquals(-1, data[2]);
94
			System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]);*/
95
			
96
			
97
			//Selecci?n temporal por rango
98
			
99
			/*tInfo = new DefaultTimeInfo();
100
			tInfo.addValue("26/8/2005-10:05:00"); //Red
101
			tInfo.addValue("26/8/2005-12:36:00");
102
			store.setTime(tInfo);
103
			
104
			buf = readData(store);
105
			data = new byte[3];
106
			buf.getElemByte(0, 0, data);
107
			assertEquals(-1, data[0]);
108
			assertEquals(0, data[1]);
109
			assertEquals(0, data[2]);
110
			System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]);
111
			
112
			//Tests para los intervalos numericos
113
			tInfo = new DefaultTimeInfo();
114
			tInfo.addValue(152438); //Green
115
			store.selectSerial("Katrina2");
116
			store.setTime(tInfo);
117
			
118
			buf = readData(store);
119
			data = new byte[3];
120
			buf.getElemByte(0, 0, data);
121
			assertEquals(0, data[0]);
122
			assertEquals(-1, data[1]);
123
			assertEquals(0, data[2]);
124
			System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]);
125
			
126
			tInfo = new DefaultTimeInfo();
127
			tInfo.addValue(152340); //Red
128
			store.setTime(tInfo);
129
			
130
			buf = readData(store);
131
			data = new byte[3];
132
			buf.getElemByte(0, 0, data);
133
			assertEquals(-1, data[0]);
134
			assertEquals(0, data[1]);
135
			assertEquals(0, data[2]);
136
			System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]);
137
			
138
			tInfo = new DefaultTimeInfo();
139
			tInfo.addValue(152550); //Red
140
			store.setTime(tInfo);
141
			
142
			buf = readData(store);
143
			data = new byte[3];
144
			buf.getElemByte(0, 0, data);
145
			assertEquals(0, data[0]);
146
			assertEquals(0, data[1]);
147
			assertEquals(-1, data[2]);
148
			System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]);
149
			
150
		} catch (ParseException e) {
151
			e.printStackTrace();
152
		} catch (TimeException e) {
153
			e.printStackTrace();
154
		} catch (OperationNotSupportedException e) {
155
			e.printStackTrace();
156
		}*/
157
		
158
	}
159
	
160
	private Buffer readData(RasterDataStore store) {
161
		RasterQuery query = manager.createQuery();
162
		query.setAllDrawableBands();
163
		try {
164
			query.setAreaOfInterest(0, 0, (int)store.getWidth(), (int)store.getHeight());
165
			return store.query(query);
166
		} catch (InvalidSetViewException e1) {
167
			e1.printStackTrace();
168
		} catch (ProcessInterruptedException e) {
169
			e.printStackTrace();
170
		} catch (RasterDriverException e) {
171
			e.printStackTrace();
172
		}
173
		
174
		return null;
175
	}
176
}
0 177

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestStatistics.java
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.FileNotOpenException;
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.props.Statistics;
31
/**
32
 * Este test prueba el calculo de estadisticas de un dataset.
33
 * Comprueba que los valores obtenidos en las estadisticas son correctos.
34
 *
35
 * Algunos costes del calculo de estadistica en el raster completo
36
 *
37
 * Ordenador: AMD Athlon(tm) XP 1800+ 1540MHz, 256KB Cach?, 500M RAM
38
 * 	Coste 1:
39
 * 		Raster: 17910x16062, 275M (GTiff), 1 Banda byte
40
 * 		Tiempo: 74.295 segs (sgtes igual)
41
 * 	Coste 2:
42
 * 		Raster: 8955x8031, 69M (GTiff), 1 Banda byte
43
 *  	Tiempo: 18.905 segs (sgtes 3.362s)
44
 *  Coste 3:
45
 * 		Raster: 812x586, 2.8M (GTiff), 3 Banda short
46
 *  	Tiempo: 0.925 segs (sgtes 0.152s)
47
 *  Coste 4:
48
 * 		Raster: 870x870, 210K (Jpeg), 3 Banda byte
49
 *  	Tiempo: 0.318 segs (sgtes 0.255s)
50
 *
51
 * @author Nacho Brodin (nachobrodin@gmail.com)
52
 *
53
 */
54
public class TestStatistics extends BaseTestCase {
55
	private String path1 = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
56
	private String path2 = baseDir + "wcs16bits.tif";
57

  
58
	private RasterDataStore   f1       = null;	
59
	private RasterDataStore   f2       = null;
60
	protected Buffer           raster   = null;
61
	private Statistics         stats1   = null;
62
	private Statistics         stats2   = null;
63

  
64
	public void start() throws Exception {
65
		this.setUp();
66
		this.testStack();
67
	}
68

  
69
	protected void doSetUp() throws Exception {
70
		System.err.println("TestStatistics running...");
71
		
72
		try {
73
			super.doSetUp();
74
		} catch (Exception e) {
75
			e.printStackTrace();
76
		}
77
		
78
		try {
79
			deleteRMF(path1);
80
			deleteRMF(path2);
81
			f1 = manager.open(path1);
82
			f2 = manager.open(path2);
83
		} catch (NotSupportedExtensionException e) {
84
			e.printStackTrace();
85
		} catch (RasterDriverException e) {
86
			e.printStackTrace();
87
		}
88
		stats1 = f1.getStatistics();
89
		stats2 = f2.getStatistics();
90
	}
91

  
92
	public void testStack(){
93
		try {
94
			stats1.calculate();
95
		} catch (FileNotOpenException e) {
96
			e.printStackTrace();
97
		} catch (RasterDriverException e) {
98
			e.printStackTrace();
99
		} catch (ProcessInterruptedException e) {
100
			e.printStackTrace();
101
		}
102
//		print(stats1);
103
		dataTestB1(stats1);
104
		dataTestB2(stats1);
105
		dataTestB3(stats1);
106
		try {
107
			stats2.calculate();
108
		} catch (FileNotOpenException e) {
109
			e.printStackTrace();
110
		} catch (RasterDriverException e) {
111
			e.printStackTrace();
112
		} catch (ProcessInterruptedException e) {
113
			e.printStackTrace();
114
		}
115
//		print(stats2);
116
		dataTestB1_2(stats2);
117
		dataTestB2_2(stats2);
118
		dataTestB3_2(stats2);
119
	}
120

  
121
	private void dataTestB1(Statistics stats){
122
		assertEquals(new Double(stats.getMaxByteUnsigned()[0]), new Double(255.0));
123
		assertEquals(new Double(stats.getMinByteUnsigned()[0]), new Double(0.0));
124
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[0]), new Double(254.0));
125
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[0]), new Double(1.0));
126
		assertEquals((int)stats.getMean()[0], 109);
127
		assertEquals((int)stats.getVariance()[0], 6125);
128
	}
129
	
130
	private void dataTestB2(Statistics stats){
131
		assertEquals(new Double(stats.getMaxByteUnsigned()[1]), new Double(255.0));
132
		assertEquals(new Double(stats.getMinByteUnsigned()[1]), new Double(0.0));
133
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[1]), new Double(254.0));
134
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[1]), new Double(1.0));
135
		assertEquals((int)stats.getMean()[1], 111);
136
		assertEquals((int)stats.getVariance()[1], 5722);
137
	}
138
	
139
	private void dataTestB3(Statistics stats){
140
		assertEquals(new Double(stats.getMaxByteUnsigned()[2]), new Double(255.0));
141
		assertEquals(new Double(stats.getMinByteUnsigned()[2]), new Double(0.0));
142
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[2]), new Double(254.0));
143
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[2]), new Double(1.0));
144
		assertEquals((int)stats.getMean()[2], 98);
145
		assertEquals((int)stats.getVariance()[2], 5495);
146
	}
147

  
148
	private void dataTestB1_2(Statistics stats){
149
		assertEquals(new Double(stats.getMax()[0]), new Double(1269.0));
150
		assertEquals(new Double(stats.getMin()[0]), new Double(0.0));
151
		assertEquals(new Double(stats.getSecondMax()[0]), new Double(1235.0));
152
		assertEquals(new Double(stats.getSecondMin()[0]), new Double(6.0));
153
		assertEquals((int)stats.getMean()[0], 71);
154
		assertEquals((int)stats.getVariance()[0], 22678);
155
	}
156

  
157
	private void dataTestB2_2(Statistics stats){
158
		assertEquals(new Double(stats.getMax()[1]), new Double(1525.0));
159
		assertEquals(new Double(stats.getMin()[1]), new Double(0.0));
160
		assertEquals(new Double(stats.getSecondMax()[1]), new Double(1522.0));
161
		assertEquals(new Double(stats.getSecondMin()[1]), new Double(14.0));
162
		assertEquals((int)stats.getMean()[1], 104);
163
		assertEquals((int)stats.getVariance()[1], 37907);
164
	}
165

  
166
	private void dataTestB3_2(Statistics stats){
167
		assertEquals(new Double(stats.getMax()[2]), new Double(888.0));
168
		assertEquals(new Double(stats.getMin()[2]), new Double(0.0));
169
		assertEquals(new Double(stats.getSecondMax()[2]), new Double(884.0));
170
		assertEquals(new Double(stats.getSecondMin()[2]), new Double(13.0));
171
		assertEquals((int)stats.getMean()[2], 75);
172
		assertEquals((int)stats.getVariance()[2], 17437);
173
	}
174

  
175
	public void print(Statistics stats) {
176
		for (int iBand = 0; iBand < f1.getBandCount(); iBand++) {
177
			System.out.println("Band " + iBand);
178
			System.out.println("...Max: " + stats.getMax()[iBand]);
179
			System.out.println("...Min: " + stats.getMin()[iBand]);
180
			System.out.println("...SecondMax: " + stats.getSecondMax()[iBand]);
181
			System.out.println("...SecondMin: " + stats.getSecondMin()[iBand]);
182
			System.out.println("...Mean: " + stats.getMean()[iBand]);
183
			System.out.println("...Variance: " + stats.getVariance()[iBand]);
184
		}
185
	}
186
}
0 187

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestReadLineGdal.java
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 junit.framework.TestCase;
25
/**
26
 * Test para validar la lectura por l?neas de un fichero tratado con gdal.
27
 * Muestrea valores sobre toda la extensi?n leida y comprueba que el resultado
28
 * sea correcto
29
 * 
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 * TODO: Falta por hacer TestReadLineGdal
32
 */
33
public class TestReadLineGdal extends TestCase {
34
	
35
	public void start() throws Exception {
36
		this.setUp();
37
		this.testStack();
38
	}
39
	
40
	protected void doSetUp() throws Exception {
41
		System.err.println("TestReadLineGdal running...");
42
	}
43
	
44
	public void testStack(){
45
	}
46
}
0 47

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestGetWindowRasterBufferSizeMrSID.java
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.RasterLocator;
26
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
27
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
28
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
29
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
30
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
31
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
32
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
33

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

  
115
}
0 116

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestCompositeTilesSimplification.java
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

  
26
/**
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public class TestCompositeTilesSimplification extends BaseTestCase {
32
	
33
	public void start() throws Exception {
34
		this.setUp();
35
		this.testStack();
36
	}
37
	
38
	public void testStack() throws Exception {
39
		doSetUp();
40
		System.err.println("TestCompositeTilesSimplification running...");
41
		Integer[][] result = null;
42

  
43
		Integer[][] values = new Integer[10][10];
44
		for (int row = 3; row < 5; row++)
45
			for (int col = 3; col < 5; col++)
46
				values[row][col] = new Integer(new String(row + "" + col));
47
			
48
		result = compress(values);
49
		show(result);
50
		
51
		values = new Integer[10][10];
52
		for (int row = 0; row < 5; row++)
53
			for (int col = 0; col < 5; col++)
54
				values[row][col] = new Integer(new String(row + "" + col));
55
		
56
		result = compress(values);
57
		show(result);
58
		
59
		values = new Integer[10][10];
60
		for (int row = 5; row < 10; row++)
61
			for (int col = 5; col < 10; col++)
62
				values[row][col] = new Integer(new String(row + "" + col));
63
		
64
		result = compress(values);
65
		show(result);
66
	}
67
	
68
	private Integer[][] compress(Integer[][] values) {
69
		int n = values.length;
70
		int m = values[0].length;
71
		int posInitX = 0;
72
		int posInitY = 0;
73
		
74
		int nRows = n, nCols = m;
75
		//Contador de filas
76
		boolean first = true;
77
		for (int row = 0; row < n; row++) {
78
			boolean isNull = true;
79
			for (int col = 0; col < m; col++) {
80
				if(values[row][col] != null) {
81
					isNull = false;
82
					if(first) {
83
						posInitX = col;
84
						first = false;
85
					}
86
				}
87
			}			
88
			if(isNull)
89
				nRows --;
90
		}
91
		
92
		//Contador de columnas
93
		first = true;
94
		for (int col = 0; col < m; col++) {
95
			boolean isNull = true;
96
			for (int row = 0; row < n; row++) {
97
				if(values[row][col] != null) {
98
					isNull = false;
99
					if(first) {
100
						posInitY = row;
101
						first = false;
102
					}
103
				}
104
			}			
105
			if(isNull)
106
				nCols --;
107
		}
108
		System.out.println("Rows:" + nRows + " Cols:" + nCols );
109
		//Copia de datos
110
		Integer[][] result = new Integer[nRows][nCols];
111
		
112
		System.out.println("posInitX:" + posInitX + " posInitY:" + posInitY );
113
		
114
		for (int row = 0; row < result.length; row++) 
115
			for (int col = 0; col < result[row].length; col++) 
116
				result[row][col] = values[row + posInitY][col + posInitX];
117
		return result;
118
	}
119
	
120
	private void show(Integer[][] result) {
121
		for (int row = 0; row < result.length; row++) { 
122
			for (int col = 0; col < result[row].length; col++) { 
123
				System.out.print(result[row][col].intValue() + " ");
124
			}
125
			System.out.println();
126
		}
127
	}
128
}
0 129

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestDataByPixelGdal.java
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 junit.framework.TestCase;
25
/**
26
 * Este test que obtiene la informaci?n de un ?nico pixel. Repetira esta
27
 * operaci?n sobre varios pixels sobre una misma imagen comprobado que los resultados
28
 * sean correctos, es decir para la posici?n seleccionada existe ese pixel obtenido.
29
 * 
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 * TODO: Falta por hacer TestDataByPixelGdal
32
 */
33
public class TestDataByPixelGdal extends TestCase{
34
	
35
	public void start() throws Exception {
36
		this.setUp();
37
		this.testStack();
38
	}
39
	
40
	protected void doSetUp() throws Exception {
41
		System.err.println("TestDataByPixelGdal running...");
42
	}
43
	
44
	public void testStack(){
45
	}
46
}
0 47

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestBandList.java
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 junit.framework.TestCase;
25

  
26
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
27
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
28
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand;
29
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
30
import org.gvsig.raster.impl.datastruct.BandListImpl;
31
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
32
/**
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public class TestBandList extends TestCase {
36
	private boolean  showCode = false;
37
	private BandList bandList = null;
38

  
39
	public void start() throws Exception {
40
		this.setUp();
41
		this.testStack();
42
	}
43

  
44
	protected void setUp() throws Exception {
45
		System.err.println("TestBandList running...");
46
		bandList = new BandListImpl();
47
		for (int i = 0; i < 5; i++) {
48
			try {
49
				DatasetBand band = new DatasetBandImpl("fileName", i, Buffer.TYPE_BYTE, 5);
50
				bandList.addBand(band, i);
51
			} catch (BandNotFoundInListException ex) {
52
				// No a?adimos la banda
53
			}
54
		}
55
	}
56

  
57
	public void testStack() {
58
		bandList.clearDrawableBands();
59
		bandList.addDrawableBand(0, 1);
60
		bandList.addDrawableBand(1, 4);
61
		bandList.addDrawableBand(2, 3);
62

  
63
		bandList.clearDrawableBands();
64
		bandList.addDrawableBand(0, 3);
65
		bandList.addDrawableBand(1, 2);
66
		bandList.addDrawableBand(2, 4);
67
		bandList.addDrawableBand(3, 4);
68
		if (showCode)
69
			print();
70
	}
71

  
72
//	private void test2() {
73
//		assertEquals(bandList.getBandCount(), 5);
74
//		assertEquals(bandList.getDrawableBandsCount(), 4);
75
//		for (int i = 0; i < bandList.getBandCount(); i++) {
76
//
77
//			assertEquals((((Band) bandList.getBand(i)).getDataType()), 0);
78
//			assertEquals((((Band) bandList.getBand(i)).getFileName()), "fileName");
79
//			assertEquals((((Band) bandList.getBand(i)).getPosition()), i);
80
//		}
81
//	}
82

  
83
	/**
84
	 * Muestra la lista de bandas en modo texto
85
	 */
86
	public void print() {
87
		System.out.println("BandCount: " + bandList.getBandCount());
88
		System.out.println("DrawableBandsCount: " + bandList.getDrawableBandsCount());
89
		for (int i = 0; i < bandList.getBandCount(); i++) {
90
			System.out.println("");
91
			System.out.println("***********************");
92
			System.out.println("Band: " + i);
93
			System.out.println("DataType: " + ((DatasetBand) bandList.getBand(i)).getDataType());
94
			System.out.println("FileName: " + ((DatasetBand) bandList.getBand(i)).getFileName());
95
			System.out.println("Position: " + ((DatasetBand) bandList.getBand(i)).getPosition());
96
			if (((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw() != null) {
97
				System.out.print("Band Dst: ");
98
				for (int j = 0; j < ((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw().length; j++)
99
					System.out.print(((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw()[j] + " ");
100
			}
101
		}
102
	}
103
}
0 104

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestReadLineEcw.java
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 java.io.File;
25

  
26
import org.gvsig.fmap.dal.DALLocator;
27
import org.gvsig.fmap.dal.DataManager;
28
import org.gvsig.fmap.dal.coverage.BaseTestCase;
29
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
30
import org.gvsig.fmap.dal.coverage.exception.GridException;
31
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
32
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
33
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
34
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
35
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
36
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
37
import org.gvsig.raster.ermapper.io.ErmapperProvider;
38
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
39

  
40
/**
41
 * Test para validar la lectura por l?neas de un ecw.
42
 * Muestrea valores sobre toda la extensi?n leida y comprueba que el resultado sea correcto
43
 * @author Nacho Brodin (nachobrodin@gmail.com)
44
 *
45
 */
46
public class TestReadLineEcw extends BaseTestCase {
47
	private String path1 = baseDir + "miniraster30x30.jp2";
48
	
49
	private RasterDataStore   f1      = null;	
50
	private DefaultRasterProvider      f2      = null;
51
	protected Buffer           raster  = null;
52
	
53
	public void start() throws Exception {
54
		this.setUp();
55
		this.testStack();
56
	}
57
	
58
	protected void doSetUp() throws Exception {
59
		System.err.println("TestReadLineEcw running...");
60
		
61
		try {
62
			super.doSetUp();
63
		} catch (Exception e) {
64
			e.printStackTrace();
65
		}
66
		
67
		try {
68
			f1 = manager.open(path1);
69
			DataManager dm = DALLocator.getDataManager();
70
			FilesystemStoreParameters p = (FilesystemStoreParameters)dm.createStoreParameters(ErmapperProvider.NAME);
71
			p.setFile(new File(path1));
72
			f2 = (DefaultRasterProvider)loadProvider(p, (DataStoreProviderServices)f1);
73
		} catch (NotSupportedExtensionException e1) {
74
			e1.printStackTrace();
75
		} catch (RasterDriverException e1) {
76
			e1.printStackTrace();
77
		}
78
		
79
	}
80
	
81
	public void testStack() {
82
		try {
83
			Object line = null;
84
			for(int iBand = 0; iBand < f1.getBandCount(); iBand ++) {
85
				for(int iLine = 0; iLine < f1.getHeight(); iLine ++) {
86
					line = ((ErmapperProvider)f2).readCompleteLine(iLine, iBand);
87
					if(f1.getDataType()[iBand] == Buffer.TYPE_BYTE){
88
						byte[] b = (byte[])line;
89
						//printByteLine(b, iLine);
90
						if(iBand == 0 && iLine == 0)
91
							testLine0_Banda0(b);
92
						if(iBand == 0 && iLine == 9)
93
							testLine9_Banda0(b);
94
						if(iBand == 0 && iLine == 19)
95
							testLine19_Banda0(b);
96
						if(iBand == 0 && iLine == 29)
97
							testLine29_Banda0(b);
98
						
99
						if(iBand == 2 && iLine == 0)
100
							testLine0_Banda2(b);
101
						if(iBand == 2 && iLine == 9)
102
							testLine9_Banda2(b);
103
						if(iBand == 2 && iLine == 19)
104
							testLine19_Banda2(b);
105
						if(iBand == 2 && iLine == 29)
106
							testLine29_Banda2(b);
107
					}
108
				}
109
			}
110
		} catch (InvalidSetViewException e) {
111
			e.printStackTrace();
112
		} catch (FileNotOpenException e) {
113
			e.printStackTrace();
114
		} catch (GridException e) {
115
			e.printStackTrace();
116
		} catch (RasterDriverException e1) {
117
			e1.printStackTrace();
118
		}
119
	}
120
	
121
	/*private void printByteLine(byte[] line, int nLine){
122
		System.out.print("L?nea: " + nLine + "| ");
123
		for (int i = 0; i < line.length; i++)
124
			System.out.print((int)(line[i] & 0x000000ff) + " ");
125
		System.out.println();
126
	}*/
127
	
128
	public void testLine0_Banda0(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
129
		assertEquals((int)(line[0] & 0x000000ff), 43);
130
		assertEquals((int)(line[9] & 0x000000ff), 83);
131
		assertEquals((int)(line[19] & 0x000000ff), 75);
132
		assertEquals((int)(line[29] & 0x000000ff), 255);
133
	}
134
	
135
	public void testLine9_Banda0(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
136
		assertEquals((int)(line[0] & 0x000000ff), 118);
137
		assertEquals((int)(line[9] & 0x000000ff), 81);
138
		assertEquals((int)(line[19] & 0x000000ff), 105);
139
		assertEquals((int)(line[29] & 0x000000ff), 114);
140
	}
141
	
142
	public void testLine19_Banda0(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
143
		assertEquals((int)(line[0] & 0x000000ff), 70);
144
		assertEquals((int)(line[9] & 0x000000ff), 49);
145
		assertEquals((int)(line[19] & 0x000000ff), 63);
146
		assertEquals((int)(line[29] & 0x000000ff), 147);
147
	}
148
	
149
	public void testLine29_Banda0(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
150
		assertEquals((int)(line[0] & 0x000000ff), 175);
151
		assertEquals((int)(line[9] & 0x000000ff), 129);
152
		assertEquals((int)(line[19] & 0x000000ff), 15);
153
		assertEquals((int)(line[29] & 0x000000ff), 126);
154
	}
155
	
156
	public void testLine0_Banda2(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
157
		assertEquals((int)(line[0] & 0x000000ff), 26);
158
		assertEquals((int)(line[9] & 0x000000ff), 68);
159
		assertEquals((int)(line[19] & 0x000000ff), 70);
160
		assertEquals((int)(line[29] & 0x000000ff), 246);
161
	}
162
	
163
	public void testLine9_Banda2(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
164
		assertEquals((int)(line[0] & 0x000000ff), 96);
165
		assertEquals((int)(line[9] & 0x000000ff), 93);
166
		assertEquals((int)(line[19] & 0x000000ff), 93);
167
		assertEquals((int)(line[29] & 0x000000ff), 102);
168
	}
169
	
170
	public void testLine19_Banda2(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
171
		assertEquals((int)(line[0] & 0x000000ff), 81);
172
		assertEquals((int)(line[9] & 0x000000ff), 46);
173
		assertEquals((int)(line[19] & 0x000000ff), 63);
174
		assertEquals((int)(line[29] & 0x000000ff), 123);
175
	}
176
	
177
	public void testLine29_Banda2(byte[] line)throws InvalidSetViewException, FileNotOpenException, GridException{
178
		assertEquals((int)(line[0] & 0x000000ff), 147);
179
		assertEquals((int)(line[9] & 0x000000ff), 110);
180
		assertEquals((int)(line[19] & 0x000000ff), 14);
181
		assertEquals((int)(line[29] & 0x000000ff), 111);
182
	}
183

  
184
}
0 185

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestReadLineMrSID.java
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 junit.framework.TestCase;
25
/**
26
 * Test para validar la lectura por l?neas de un fichero MrSID.
27
 * Muestrea valores sobre toda la extensi?n leida y comprueba que el resultado
28
 * sea correcto
29
 * 
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 * TODO: Falta por hacer TestReadLineMrSID
32
 */
33
public class TestReadLineMrSID extends TestCase {
34
	
35
	public void start() throws Exception {
36
		this.setUp();
37
		this.testStack();
38
	}
39
	
40
	protected void doSetUp() throws Exception {
41
		System.err.println("TestReadLineMrSID running...");
42
	}
43
	
44
	public void testStack(){
45
	}
46
}
0 47

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestStatisticMultiFile.java
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 java.io.File;
25

  
26
import org.gvsig.fmap.dal.DALLocator;
27
import org.gvsig.fmap.dal.DataManager;
28
import org.gvsig.fmap.dal.coverage.BaseTestCase;
29
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
30
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException;
31
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
32
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
35
import org.gvsig.fmap.dal.exception.InitializeException;
36
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
37
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
38
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
39
import org.gvsig.raster.gdal.io.GdalProvider;
40
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
41
import org.gvsig.raster.impl.store.DefaultMultiRasterStore;
42
/**
43
 * Prueba el calculo de estadisticas para un dataset con multiples ficheros.
44
 * Comprueba que los valores obtenidos en las estadisticas son correctos.
45
 *
46
 * @author Nacho Brodin (nachobrodin@gmail.com)
47
 */
48
public class TestStatisticMultiFile extends BaseTestCase {
49
	private String path1 = baseDir + "band1-30x28byte.tif";
50
	private String path2 = baseDir + "band2-30x28byte.tif";
51
	private String path3 = baseDir + "band3-30x28byte.tif";
52

  
53
	private DefaultRasterProvider      f1       = null;	
54
	private DefaultRasterProvider      f2       = null;
55
	private DefaultRasterProvider      f3       = null;
56
	protected Buffer           raster   = null;
57

  
58
	public void start() throws Exception {
59
		this.setUp();
60
		this.testStack();
61
	}
62

  
63
	protected void doSetUp() throws Exception {
64
		System.err.println("TestStatisticMultiFile running...");
65
		
66
		try {
67
			super.doSetUp();
68
		} catch (Exception e) {
69
			e.printStackTrace();
70
		}
71
	}
72

  
73
	public void testStack() {
74
		DefaultMultiRasterStore grmf = new DefaultMultiRasterStore();
75
		
76
		try {
77
			deleteRMF(path1);
78
			deleteRMF(path2);
79
			deleteRMF(path3);
80
			DataManager dm = DALLocator.getDataManager();
81
			
82
			FilesystemStoreParameters p = (FilesystemStoreParameters)dm.createStoreParameters(GdalProvider.NAME);
83
			p.setFile(new File(path1));
84
			f1 = (DefaultRasterProvider)loadProvider(p, (DataStoreProviderServices)grmf);
85
			
86
			FilesystemStoreParameters p1 = (FilesystemStoreParameters)dm.createStoreParameters(GdalProvider.NAME);
87
			p.setFile(new File(path2));
88
			f2 = (DefaultRasterProvider)loadProvider(p1, (DataStoreProviderServices)grmf);
89
			
90
			FilesystemStoreParameters p2 = (FilesystemStoreParameters)dm.createStoreParameters(GdalProvider.NAME);
91
			p.setFile(new File(path3));
92
			f3 = (DefaultRasterProvider)loadProvider(p2, (DataStoreProviderServices)grmf);
93
			
94
		} catch (ProviderNotRegisteredException e) {
95
			e.printStackTrace();
96
		} catch (InitializeException e) {
97
			e.printStackTrace();
98
		}
99
		
100
		try {
101
			grmf.addDataStore(f1);
102
			grmf.addDataStore(f2);
103
			grmf.addDataStore(f3);
104
		} catch (OperationNotSupportedException e1) {
105
			// TODO Auto-generated catch block
106
			e1.printStackTrace();
107
		}
108
		try {
109
			grmf.getStatistics().calculate();
110
		} catch (FileNotOpenException e) {
111
			e.printStackTrace();
112
		} catch (RasterDriverException e) {
113
			e.printStackTrace();
114
		} catch (ProcessInterruptedException e) {
115
			e.printStackTrace();
116
		}
117
		//			print(grmf);
118
		dataTestB1(grmf.getStatistics());
119
		dataTestB2(grmf.getStatistics());
120
		dataTestB3(grmf.getStatistics());
121
	}
122

  
123
	private void dataTestB1(Statistics stats){
124
		assertEquals(new Double(stats.getMaxByteUnsigned()[0]), new Double(249.0));
125
		assertEquals(new Double(stats.getMinByteUnsigned()[0]), new Double(82.0));
126
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[0]), new Double(211.0));
127
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[0]), new Double(83.0));
128
		assertEquals((int)stats.getMean()[0], 119);
129
		assertEquals((int)stats.getVariance()[0], 584);
130
	}
131
	
132
	private void dataTestB2(Statistics stats){
133
		assertEquals(new Double(stats.getMaxByteUnsigned()[1]), new Double(234.0));
134
		assertEquals(new Double(stats.getMinByteUnsigned()[1]), new Double(49.0));
135
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[1]), new Double(216.0));
136
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[1]), new Double(50.0));
137
		assertEquals((int)stats.getMean()[1], 102);
138
		assertEquals((int)stats.getVariance()[1], 1107);
139
	}
140
	
141
	private void dataTestB3(Statistics stats){
142
		assertEquals(new Double(stats.getMaxByteUnsigned()[2]), new Double(255.0));
143
		assertEquals(new Double(stats.getMinByteUnsigned()[2]), new Double(28.0));
144
		assertEquals(new Double(stats.getSecondMaxByteUnsigned()[2]), new Double(250.0));
145
		assertEquals(new Double(stats.getSecondMinByteUnsigned()[2]), new Double(34.0));
146
		assertEquals((int)stats.getMean()[2], 115);
147
		assertEquals((int)stats.getVariance()[2], 2833);
148
	}
149

  
150
	public void print(RasterDataStore grmf) {
151
		for (int iBand = 0; iBand < grmf.getStatistics().getBandCount(); iBand++) {
152
			System.out.println("Band " + iBand);
153
			System.out.println("...Max: " + grmf.getStatistics().getMax()[iBand]);
154
			System.out.println("...Min: " + grmf.getStatistics().getMin()[iBand]);
155
			System.out.println("...SecondMax: " + grmf.getStatistics().getSecondMax()[iBand]);
156
			System.out.println("...SecondMin: " + grmf.getStatistics().getSecondMin()[iBand]);
157
			System.out.println("...Mean: " + grmf.getStatistics().getMean()[iBand]);
158
			System.out.println("...Variance: " + grmf.getStatistics().getVariance()[iBand]);
159
		}
160
	}
161
}
0 162

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.34/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestDataByPixelEcw.java
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.dataset.Buffer;
26
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
27
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
28
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff