Revision 12453

View differences:

org.gvsig.raster/tags/org.gvsig.raster-2.2.131/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.131/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.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/store/TestGetTileUsingStores.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.store;
23

  
24
import java.io.File;
25

  
26
import org.gvsig.fmap.dal.coverage.BaseTestCase;
27
import org.gvsig.fmap.dal.coverage.RasterLocator;
28
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
29
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
30
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
31
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
32
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
33
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
34
import org.gvsig.raster.cache.tile.provider.TileServer;
35
import org.gvsig.raster.impl.datastruct.ExtentImpl;
36
import org.gvsig.raster.tilecache.io.TileDataParametersImpl;
37
import org.gvsig.raster.tilecache.io.TileProvider;
38
import org.gvsig.tools.locator.LocatorException;
39
/**
40
 * 
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class TestGetTileUsingStores extends BaseTestCase {
44
	private String        path    = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
45
	
46
	public void start() throws Exception {
47
		this.setUp();
48
		this.testStack();
49
	}
50
	
51
	protected void doSetUp() throws Exception {
52
		System.err.println("TestGetTileUsingStores running...");
53
		
54
	}
55
	
56
	public void testStack() {
57
		TileDataParametersImpl params = new TileDataParametersImpl();
58
		params.setFile(new File(path));
59
		RasterDataStore store = null;
60
		try {
61
			store = RasterLocator.getManager().open(params);
62
		} catch (LocatorException e) {
63
			e.printStackTrace();
64
		} catch (NotSupportedExtensionException e) {
65
			e.printStackTrace();
66
		} catch (RasterDriverException e) {
67
			e.printStackTrace();
68
		}
69
		TileProvider prov = (TileProvider)store.getProvider();
70
		TileServer server = prov.getInternalProvider().getTileServer();
71
		double ps = server.getStruct().getPixelSizeByLevel(15);
72
		double tileSize = server.getStruct().getTileSizeByLevel(15)[0];
73
		double xMax = 645740.00390625 + (tileSize * ps);
74
		double yMin = 4924990.522216797 - (tileSize * ps);
75
		Extent extent = new ExtentImpl(645740.00390625, 4924990.522216797, xMax, yMin);
76
		RasterQuery query = RasterLocator.getManager().createQuery();
77
		query.setTileParameters(15, 16912, 12357, extent, server.getStruct());
78
		
79
		try {
80
			Buffer b = store.query(query);
81
			System.out.println("" + b);
82
		} catch (ProcessInterruptedException e) {
83
			e.printStackTrace();
84
		} catch (RasterDriverException e) {
85
			e.printStackTrace();
86
		} catch (InvalidSetViewException e) {
87
			e.printStackTrace();
88
		}
89
		
90
	}
91
}
0 92

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/util/TestAdjustExtentToRotateRaster.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.util;
23

  
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.NoninvertibleTransformException;
26
import java.awt.geom.Point2D;
27

  
28
import org.gvsig.fmap.dal.coverage.BaseTestCase;
29
import org.gvsig.fmap.dal.coverage.RasterLocator;
30
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
31
import org.gvsig.raster.impl.datastruct.ExtentImpl;
32
/**
33
 * Comprueba la llamada de RasterUtilities calculateAdjustedView con un raster
34
 * rotado. Le pasar? un extent y este tiene que ser devuelto ajustado a la
35
 * transformaci?n indicada. Como comprobaci?n se convertir? el resultado a
36
 * valores pixel y se mirar? que esten entre el rango 0-width, 0-height
37
 * 
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class TestAdjustExtentToRotateRaster extends BaseTestCase {
41
	private int w = 870, h = 870;
42
	
43
	public void start() throws Exception {
44
		this.setUp();
45
		this.testStack();
46
	}
47

  
48
	protected void doSetUp() throws Exception {
49
		System.err.println("TestAdjustExtentToRotateRaster running...");
50
		
51
		try {
52
			super.doSetUp();
53
		} catch (Exception e) {
54
			e.printStackTrace();
55
		}
56
	}
57

  
58
	public void testStack() {
59
		AffineTransform at = new AffineTransform(2.4, 0.2, 0.2, -2.4, 644850.0, 4925250.0);
60
		Extent ext = new ExtentImpl(644823.3, 4925240.5, 644930.5, 4925123.6);
61
		Extent e = RasterLocator.getManager().getRasterUtils().calculateAdjustedView(ext, at, w, h);
62
//		System.out.println("-UL=" + e.minX() + " " + e.maxY());
63
//		System.out.println("-LR=" + e.maxX() + " " + e.minY());
64
		
65
		Point2D ul = new Point2D.Double(e.minX(), e.maxY());
66
		Point2D lr = new Point2D.Double(e.maxX(), e.minY());
67

  
68
		try {
69
			at.inverseTransform(ul, ul);
70
			at.inverseTransform(lr, lr);
71
		} catch (NoninvertibleTransformException exc) {
72
			exc.printStackTrace();
73
		}
74
		
75
//		System.out.println("*UL=" + ul.getX() + " " + ul.getY());
76
//		System.out.println("*LR=" + lr.getX() + " " + lr.getY());
77

  
78
		if (ul.getX() < 0 || ul.getY() < 0 || lr.getX() < 0 || lr.getY() < 0)
79
			assertEquals(0, 1);
80

  
81
		if (ul.getX() >= w || ul.getY() >= h || lr.getX() >= w || lr.getY() >= h)
82
			assertEquals(0, 1);
83
		
84
//		System.out.println("-UL=" + e.minX() + " " + e.maxY());
85
//		System.out.println("-LR=" + e.maxX() + " " + e.minY());
86
	}
87
}
0 88

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/util/TransparencyRangeTest.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.util;
23

  
24
import java.util.ArrayList;
25

  
26
import org.gvsig.fmap.dal.coverage.BaseTestCase;
27
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange;
28
import org.gvsig.raster.impl.datastruct.TransparencyRangeImpl;
29
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
30

  
31

  
32
/**
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public class TransparencyRangeTest extends BaseTestCase {
36
		
37
	private TransparencyRange tr = new TransparencyRangeImpl();
38
	private TransparencyRange tr1 = new TransparencyRangeImpl();
39
	private TransparencyRange tr2 = new TransparencyRangeImpl();
40
	private TransparencyRange tr3 = new TransparencyRangeImpl();
41
	
42
    public void start() throws Exception {
43
		this.setUp();
44
		this.testStack();
45
	}
46
	
47
	protected void doSetUp() throws Exception {
48
		System.err.println("TransparencyRangeTest running...");
49
		
50
		try {
51
			super.doSetUp();
52
		} catch (Exception e) {
53
			e.printStackTrace();
54
		}
55
		
56
		//Simplificaciones entre dos intervalos
57
		
58
		tr.setRed(new int[]{3 , 5});
59
		tr.setGreen(new int[]{4 , 7});
60
		tr.setBlue(new int[]{1 , 5});
61
		tr.setAnd(true);
62
		tr.loadStrEntryFromValues();
63
		
64
		tr1.setRed(new int[]{4 , 7});
65
		tr1.setGreen(new int[]{3 , 5});
66
		tr1.setBlue(new int[]{2 , 4});
67
		tr1.setAnd(true);
68
		tr1.loadStrEntryFromValues();
69
		
70
		tr2.setRed(new int[]{5 , 10});
71
		tr2.setGreen(new int[]{10 , 15});
72
		tr2.setBlue(new int[]{5 , 14});
73
		tr2.setAnd(true);
74
		tr2.loadStrEntryFromValues();
75
		
76
		tr3.setRed(new int[]{6 , 12});
77
		tr3.setGreen(new int[]{14 , 20});
78
		tr3.setBlue(new int[]{16 , 24});
79
		tr3.setAnd(true);
80
		tr3.loadStrEntryFromValues();
81
	}
82
	
83
	public void testStack(){
84
		int[] r = tr.union(tr1.getRed(), DefaultRasterProvider.RED_BAND);
85
		int[] g = tr.union(tr1.getGreen(), DefaultRasterProvider.GREEN_BAND);
86
		int[] b = tr.union(tr1.getBlue(), DefaultRasterProvider.BLUE_BAND);
87
		
88
		assertEquals(r[0], 3);
89
		assertEquals(r[1], 7);
90
		assertEquals(g[0], 3);
91
		assertEquals(g[1], 7);
92
		assertEquals(b[0], 1);
93
		assertEquals(b[1], 5);
94
		
95
		//Simplificaciones de una lista de intervalos
96
		ArrayList<TransparencyRange> l = new ArrayList<TransparencyRange>();
97
		l.add(tr);
98
		l.add(tr1);
99
		l.add(tr2);
100
		l.add(tr3);
101
		
102
		/*Transparency t = new Transparency();
103
		t.setTransparencyRangeList(l);
104
		t.simplify();
105
		
106
		for (int i = 0; i < l.size(); i++)
107
			System.out.println("Entrada: " + ((TransparencyRange)l.get(i)).getStrEntry());*/
108
	}
109
	
110
}
0 111

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/util/TestIntersectExtent.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.util;
23

  
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.NoninvertibleTransformException;
26
import java.awt.geom.Point2D;
27

  
28
import org.gvsig.fmap.dal.coverage.BaseTestCase;
29
import org.gvsig.fmap.dal.coverage.RasterLocator;
30
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
31
import org.gvsig.raster.impl.datastruct.ExtentImpl;
32

  
33
/**
34
 * Comprueba la llamada de RasterUtilities intersects con un raster rotado. Esta llamada comprueba
35
 * si dos extents intersectan.
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class TestIntersectExtent extends BaseTestCase {
41

  
42
	public void start() throws Exception {
43
		this.setUp();
44
		this.testStack();
45
	}
46
	
47
	protected void doSetUp() throws Exception {
48
		System.err.println("TestIntersectsExtent running...");
49
	}
50
	
51
	public void testStack(){
52
		AffineTransform at = new AffineTransform(2.0707369692354263, -1.2132800188916328, -1.2132800188916328, -2.0707369692354263, 645519.8062266004, 4925635.747389836);
53
		Point2D ul = new Point2D.Double(645519.8062266004, 4925635.747389836);
54
		Point2D ll = new Point2D.Double(644464.2526101647, 4923834.206226601);
55
		Point2D ur = new Point2D.Double(647321.3473898353, 4924580.193773401);
56
		Point2D lr = new Point2D.Double(646265.7937733995, 4922778.652610166);
57

  
58
		Point2D ulA = new Point2D.Double(645021.0, 4925601.0);
59
		Point2D lrA = new Point2D.Double(645973.0, 4924920.0);
60
		
61
		Point2D ulB = new Point2D.Double(646008.0, 4923286.0);
62
		Point2D lrB = new Point2D.Double(646614.0, 4922830.0);
63
		
64
		Point2D ulC = new Point2D.Double(646475.0, 4925468.0);
65
		Point2D lrC = new Point2D.Double(646822.0, 4925156.0);
66
		
67
		Extent e1 = new ExtentImpl(ul, lr, ur, ll);
68
		Extent e2 = new ExtentImpl(ulA, lrA);
69
		Extent e3 = new ExtentImpl(ulB, lrB);
70
		Extent e4 = new ExtentImpl(ulC, lrC);
71
		
72
		try {
73
			RasterUtils util = RasterLocator.getManager().getRasterUtils();
74
			assertEquals(util.intersects(e1, e2, at), true);
75
			assertEquals(util.intersects(e1, e3, at), true);
76
			assertEquals(util.intersects(e1, e4, at), false);
77
		} catch (NoninvertibleTransformException e) {
78
			e.printStackTrace();
79
		}
80
	}
81

  
82
}
0 83

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/util/TestIsInsideRaster.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.util;
23

  
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.Point2D;
26

  
27
import org.gvsig.fmap.dal.coverage.BaseTestCase;
28
import org.gvsig.fmap.dal.coverage.RasterLocator;
29
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
30
import org.gvsig.raster.impl.datastruct.ExtentImpl;
31

  
32
/**
33
 * Comprueba la llamada de RasterUtilities isInside con un raster rotado. Esta llamada cmprueba
34
 * si un punto se encuentra dentro de un Extent o fuera. Para esto convierte ambos a coordenadas
35
 * pixel y comprueba si el punto est? entre 0 y maxX y 0 y maxY. 
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class TestIsInsideRaster extends BaseTestCase {
41
	
42
	public void start() throws Exception {
43
		this.setUp();
44
		this.testStack();
45
	}
46
	
47
	protected void doSetUp() throws Exception {
48
		System.err.println("TestIsInsideRaster running...");
49
		
50
		try {
51
			super.doSetUp();
52
		} catch (Exception e) {
53
			e.printStackTrace();
54
		}
55
	}
56
	
57
	public void testStack(){
58
		AffineTransform at = new AffineTransform(2.0707369692354263, -1.2132800188916328, -1.2132800188916328, -2.0707369692354263, 645519.8062266004, 4925635.747389836);
59
		Point2D ul = new Point2D.Double(645519.8062266004, 4925635.747389836);
60
		Point2D ll = new Point2D.Double(644464.2526101647, 4923834.206226601);
61
		Point2D ur = new Point2D.Double(647321.3473898353, 4924580.193773401);
62
		Point2D lr = new Point2D.Double(646265.7937733995, 4922778.652610166);
63
		Extent e = new ExtentImpl(ul, lr, ur, ll);
64
		
65
		assertEquals(RasterLocator.getManager().getRasterUtils().isInside(new Point2D.Double(645915.55, 4924461.97), e, at), true);
66
		assertEquals(RasterLocator.getManager().getRasterUtils().isInside(new Point2D.Double(646161.22, 4925326.38), e, at), false);
67
	}
68

  
69
}
0 70

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/util/TestGetParams.java
1
package org.gvsig.fmap.dal.coverage.util;
2

  
3
import org.gvsig.fmap.dal.coverage.BaseTestCase;
4
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
5
import org.gvsig.raster.ermapper.io.ErmapperDataParameters;
6
import org.gvsig.raster.gdal.io.GdalDataParameters;
7
import org.gvsig.raster.lizardtech.io.LizardTechDataParameters;
8
import org.gvsig.raster.util.DefaultProviderServices;
9

  
10
public class TestGetParams extends BaseTestCase {
11
	
12
	protected void doSetUp() throws Exception {
13
		try {
14
			super.doSetUp();
15
		} catch (Exception e) {
16
			e.printStackTrace();
17
		}
18
	}
19
	
20
	public void testStack() {
21
		ProviderServices ps = (DefaultProviderServices)manager.getProviderServices();
22
		RasterDataParameters params = ps.createParameters("file.jp2");
23
		assertTrue(params instanceof ErmapperDataParameters);
24
		params = ps.createParameters("file.tif");
25
		assertTrue(params instanceof GdalDataParameters);
26
		params = ps.createParameters("file.sid");
27
		assertTrue(params instanceof LizardTechDataParameters);
28
	}
29

  
30
}
0 31

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/datastruct/TestColorTable.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.datastruct;
23

  
24
import java.awt.Color;
25
import java.util.ArrayList;
26

  
27
import org.gvsig.fmap.dal.coverage.BaseTestCase;
28
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
29
import org.gvsig.raster.impl.datastruct.ColorItemImpl;
30
import org.gvsig.raster.impl.store.properties.DataStoreColorTable;
31
/**
32
 * Test para comprobar el funcionamiento de las tablas de color.
33
 * @version 12/05/2008
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class TestColorTable extends BaseTestCase {
37
	private String path = baseDir + "gifTransparente.gif";
38

  
39
    protected void doSetUp() throws Exception {
40
		try {
41
			super.doSetUp();
42
		} catch (Exception e) {
43
			e.printStackTrace();
44
		}
45
		System.err.println("TestColorTable running...");
46
	}
47

  
48
	public void testStack() {
49
		dataTest1();
50
		dataTest2();
51
	}
52

  
53
	/**
54
	 * Compara un array de bytes con sus respectivos valores de color
55
	 * @param item
56
	 * @param red
57
	 * @param green
58
	 * @param blue
59
	 * @param alpha
60
	 */
61
	private void compareColor(byte[] item, int red, int green, int blue, int alpha) {
62
		assertEquals((item[0] & 0xff), red);
63
		assertEquals((item[1] & 0xff), green);
64
		assertEquals((item[2] & 0xff), blue);
65
		assertEquals((item[3] & 0xff), alpha);
66
	}
67

  
68
	/**
69
	 * Comprueba la tabla de color de una imagen existente
70
	 */
71
	private void dataTest1() {
72
		open(path);
73
		ColorTable table = dataStore.getColorTable();
74
		compareColor(table.getColorTableByBand()[0],  255, 255, 255,   0);
75
		compareColor(table.getColorTableByBand()[1],    0,   0,   0, 255);
76
		compareColor(table.getColorTableByBand()[2],    0, 102, 255, 255);
77
		compareColor(table.getColorTableByBand()[3],    0, 153, 255, 255);
78
		compareColor(table.getColorTableByBand()[4],    0,   0, 255, 255);
79
		compareColor(table.getColorTableByBand()[5],    0,  51, 255, 255);
80
		compareColor(table.getColorTableByBand()[6],   55,  55, 255, 255);
81
		compareColor(table.getColorTableByBand()[7],    0, 204, 255, 255);
82
		compareColor(table.getColorTableByBand()[8],  191, 191, 255, 255);
83
		compareColor(table.getColorTableByBand()[9],  191, 242, 255, 255);
84
		compareColor(table.getColorTableByBand()[10], 223, 223, 223, 255);
85
		compareColor(table.getColorTableByBand()[11], 127, 127, 127, 255);
86
		compareColor(table.getColorTableByBand()[12],  63,  63,  63, 255);
87
		compareColor(table.getColorTableByBand()[13], 159, 159, 159, 255);
88
		compareColor(table.getColorTableByBand()[14],  31,  31,  31, 255);
89
		compareColor(table.getColorTableByBand()[15],  95,  95,  95, 255);
90
		compareColor(table.getColorTableByBand()[16], 191, 191, 191, 255);
91
	}
92

  
93
	/**
94
	 * Comprueba una tabla de color creada a mano
95
	 */
96
	@SuppressWarnings("unchecked")
97
	private void dataTest2() {
98
		ColorTable table = new DataStoreColorTable("dataTest2");
99
		ArrayList list = new ArrayList();
100
		ColorItem item = new ColorItemImpl();
101
		item.setValue(0.0f);
102
		item.setColor(Color.black);
103
		list.add(item);
104
		item = new ColorItemImpl();
105
		item.setValue(10.0f);
106
		item.setColor(Color.white);
107
		list.add(item);
108
		item = new ColorItemImpl();
109
		item.setValue(20.0f);
110
		item.setColor(Color.red);
111
		list.add(item);
112

  
113
		table.createPaletteFromColorItems(list, false);
114
		table.setInterpolated(false);
115

  
116
		compareColor(table.getRGBAByBand(0.0f),    0,   0,   0, 255);
117
		compareColor(table.getRGBAByBand(10.0f), 255, 255, 255, 255);
118
		compareColor(table.getRGBAByBand(20.0f), 255,   0,   0, 255);
119
	}
120
}
0 121

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/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;
29
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
30
import org.gvsig.raster.impl.store.DefaultMultiRasterStore;
31

  
32
/**
33
 * Este test que obtiene la informaci?n de un ?nico pixel. Repetira esta
34
 * operaci?n sobre varios pixels sobre una misma imagen comprobado que los resultados
35
 * sean correctos, es decir para la posici?n seleccionada existe ese pixel obtenido.
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class TestDataByPixelEcw extends BaseTestCase {
41
	private String             path1   = baseDir + "miniraster30x30.jp2";
42
	private DefaultMultiRasterStore       f       = null;	
43
	protected Buffer           raster  = 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("TestDataByPixelEcw running...");
52
		
53
		try {
54
			super.doSetUp();
55
		} catch (Exception e) {
56
			e.printStackTrace();
57
		}
58
		
59
		try {
60
			f = (DefaultMultiRasterStore)manager.open(path1);
61
		} catch (NotSupportedExtensionException e1) {
62
			e1.printStackTrace();
63
		} catch (RasterDriverException e1) {
64
			e1.printStackTrace();
65
		}
66
		
67
	}
68
	
69
	public void testStack(){
70
		try {
71
			testPixelsValues();
72
		} catch (InvalidSetViewException e) {
73
			e.printStackTrace();
74
		} catch (FileNotOpenException e) {
75
			e.printStackTrace();
76
		} catch (RasterDriverException e1) {
77
			e1.printStackTrace();
78
		}
79
	}
80
	
81
	public void testPixelsValues()throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
82
		assertEquals(((Integer)f.getData(1, 1, 0)).intValue(), 73);
83
		assertEquals(((Integer)f.getData(1, 1, 1)).intValue(), 87);
84
		assertEquals(((Integer)f.getData(1, 1, 2)).intValue(), 72);
85
		
86
		assertEquals(((Integer)f.getData(18, 16, 0)).intValue(), 61);
87
		assertEquals(((Integer)f.getData(18, 16, 1)).intValue(), 74);
88
		assertEquals(((Integer)f.getData(18, 16, 2)).intValue(), 57);
89
		
90
		assertEquals(((Integer)f.getData(17, 23, 0)).intValue(), 172);
91
		assertEquals(((Integer)f.getData(17, 23, 1)).intValue(), 154);
92
		assertEquals(((Integer)f.getData(17, 23, 2)).intValue(), 140);
93
		
94
		assertEquals(((Integer)f.getData(23, 3, 0)).intValue(), 188);
95
		assertEquals(((Integer)f.getData(23, 3, 1)).intValue(), 186);
96
		assertEquals(((Integer)f.getData(23, 3, 2)).intValue(), 189);
97
		
98
		assertEquals(((Integer)f.getData(29, 29, 0)).intValue(), 126);
99
		assertEquals(((Integer)f.getData(29, 29, 1)).intValue(), 134);
100
		assertEquals(((Integer)f.getData(29, 29, 2)).intValue(), 111);
101
		
102
		assertEquals(((Integer)f.getData(0, 29, 0)).intValue(), 175);
103
		assertEquals(((Integer)f.getData(0, 29, 1)).intValue(), 175);
104
		assertEquals(((Integer)f.getData(0, 29, 2)).intValue(), 147);
105
		
106
		assertEquals(((Integer)f.getData(0, 0, 0)).intValue(), 43);
107
		assertEquals(((Integer)f.getData(0, 0, 1)).intValue(), 53);
108
		assertEquals(((Integer)f.getData(0, 0, 2)).intValue(), 26);
109
		
110
		assertEquals(((Integer)f.getData(29, 0, 0)).intValue(), 255);
111
		assertEquals(((Integer)f.getData(29, 0, 1)).intValue(), 252);
112
		assertEquals(((Integer)f.getData(29, 0, 2)).intValue(), 246);
113
	}
114

  
115
}
0 116

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestDataByPixelMrSID.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 TestDataByPixelMrSID
32
 */
33
public class TestDataByPixelMrSID 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("TestDataByPixelMrSID running...");
42
	}
43
	
44
	public void testStack(){
45
	}
46
}
0 47

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestReadBlockMrSID.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.InvalidSetViewException;
31
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
32
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
33
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
34
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
35
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
36
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
37
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
38
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
39
import org.gvsig.raster.lizardtech.io.LizardTechProvider;
40

  
41
/**
42
 * Test del uso de la funci?n readBlock de MrSID. Cargar? un dataset del formato mrsid y recorrer? todo
43
 * el raster con la llamada readBlock. El resultado de los datos leidos con esta llamada ser?n 
44
 * comparados a los leidos con setAreaOfInterest
45
 * 
46
 * @author Nacho Brodin (nachobrodin@gmail.com)
47
 *
48
 */
49
public class TestReadBlockMrSID extends BaseTestCase {
50
	private String path1 = baseDir + "q101866.sid";
51
	private RasterDataStore   f1       = null;	
52
	private DefaultRasterProvider      f2       = null;	
53
	private RasterQuery        query   = null;
54
	protected Buffer           buf1  = null;
55
	
56
	public void start() throws Exception {
57
		this.setUp();
58
		this.testStack();
59
	}
60
	
61
	protected void doSetUp() throws Exception {
62
		System.err.println("TestReadBlockMrSID running...");
63
		
64
		try {
65
			super.doSetUp();
66
		} catch (Exception e) {
67
			e.printStackTrace();
68
		}
69
		
70
		try {
71
			f1 = manager.open(path1);
72
			DataManager dm = DALLocator.getDataManager();
73
			FilesystemStoreParameters p = (FilesystemStoreParameters)dm.createStoreParameters(LizardTechProvider.NAME);
74
			p.setFile(new File(path1));
75
			f2 = (DefaultRasterProvider)loadProvider(p, (DataStoreProviderServices)f1);
76
		} catch (NotSupportedExtensionException e1) {
77
			e1.printStackTrace();
78
		} catch (RasterDriverException e1) {
79
			e1.printStackTrace();
80
		}
81
	}
82
	
83
	public void testStack() {
84
		query = manager.createQuery();
85
		query.setAllDrawableBands();
86
		try {
87
			query.setAreaOfInterest(f1.getExtent().getMin().getX(), f1.getExtent().getMax().getY(), f1.getExtent().width(), f1.getExtent().height());
88
			buf1 = f1.query(query);
89
		} catch (RasterDriverException e1) {
90
			e1.printStackTrace();
91
		} catch (InvalidSetViewException e1) {
92
			e1.printStackTrace();
93
		} catch (ProcessInterruptedException e) {
94
			e.printStackTrace();
95
		}
96
		
97
		int block = 100;
98
		int nblocks = (int)Math.ceil(f1.getHeight() / block);
99
		try {
100
			int line = 0;
101
			int initBand = 0;
102
			int column = 0;
103
			for (int i = 0; i < nblocks; i++) {
104
				byte[][][] buf = (byte[][][])f2.readBlock(i * block, block);
105
				initBand = i * block;
106
				for (int band = 0; band < buf.length; band++) {
107
					line = initBand;
108
					for (int row = 0; row < buf[band].length; row++) {
109
						column = 0;
110
						for (int col = 0; col < buf[band][row].length; col++) {
111
							//try {
112
							assertEquals(buf[band][row][col], buf1.getElemByte(line, column, band));
113
							/*} catch (AssertionFailedError e) {
114
								System.out.println(band + " " + line + " " + column);
115
								
116
							}*/
117
							column ++;
118
						}
119
						line ++;
120
					}
121
					
122
				}
123
			}
124
		} catch (InvalidSetViewException e) {
125
			e.printStackTrace();
126
		} catch (FileNotOpenException e) {
127
			e.printStackTrace();
128
		} catch (RasterDriverException e) {
129
			e.printStackTrace();
130
		} catch (ProcessInterruptedException e) {
131
			e.printStackTrace();
132
		}
133
		
134
	}
135

  
136
}
0 137

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestGetWindowRasterMrSID.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.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
}
0 109

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.131/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/TestHistogramSerializer.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.datastruct.BufferHistogram;
26
import org.gvsig.fmap.dal.coverage.exception.HistogramException;
27
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
28
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff