Revision 8125
org.gvsig.raster/tags/org.gvsig.raster-2.2.73/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.73/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.73/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.73/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.73/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.73/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.73/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; |
|
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.props.HistogramComputer; |
|
33 |
import org.gvsig.raster.impl.datastruct.serializer.HistogramRmfSerializer; |
|
34 |
|
|
35 |
/** |
|
36 |
* Test para comprobar la construcci?n de un histograma desde un XML. Este test calcula el histograma |
|
37 |
* de un raster y lo convierte a XML. Despu?s crear? un objeto Histogram a partir del XML. Finalmente |
|
38 |
* se comparar? el Histograma original con el final. |
|
39 |
* |
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
41 |
*/ |
|
42 |
public class TestHistogramSerializer extends BaseTestCase { |
|
43 |
private String path = baseDir + "miniraster30x30.jp2"; |
|
44 |
private RasterDataStore f = null; |
|
45 |
protected Buffer raster = null; |
|
46 |
|
|
47 |
public void start() throws Exception { |
|
48 |
this.setUp(); |
|
49 |
this.testStack(); |
|
50 |
} |
|
51 |
|
|
52 |
protected void doSetUp() throws Exception { |
|
53 |
System.err.println("TestHistogramSerializer running..."); |
|
54 |
//int[] drawableBands = {0, 1, 2}; |
|
55 |
try { |
|
56 |
super.doSetUp(); |
|
57 |
} catch (Exception e) { |
|
58 |
e.printStackTrace(); |
|
59 |
} |
|
60 |
|
|
61 |
try { |
|
62 |
f = manager.open(path); |
|
63 |
} catch (NotSupportedExtensionException e) { |
|
64 |
e.printStackTrace(); |
|
65 |
return; |
|
66 |
} catch (RasterDriverException e) { |
|
67 |
e.printStackTrace(); |
|
68 |
return; |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
public void testStack() { |
|
74 |
|
|
75 |
try { |
|
76 |
HistogramComputer dsh = f.getHistogramComputer(); |
|
77 |
BufferHistogram hist1 = null; |
|
78 |
hist1 = dsh.getBufferHistogram(); |
|
79 |
|
|
80 |
HistogramRmfSerializer serial1 = new HistogramRmfSerializer(hist1); |
|
81 |
String s = serial1.write(); |
|
82 |
//System.out.println(s); |
|
83 |
|
|
84 |
HistogramRmfSerializer serial2 = new HistogramRmfSerializer(); |
|
85 |
try { |
|
86 |
serial2.read(s); |
|
87 |
} catch (ParsingException e) { |
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
BufferHistogram hist2 = (BufferHistogram)serial2.getResult(); |
|
91 |
|
|
92 |
assertEquals(hist1.getNumBands(), hist2.getNumBands()); |
|
93 |
for (int iBand = 0; iBand < hist1.getNumBands(); iBand++) { |
|
94 |
for(int i = 0; i < hist1.getNumValues(); i++) |
|
95 |
assertEquals((long)hist1.getHistogramValue(iBand, i), (long)hist2.getHistogramValue(iBand, i)); |
|
96 |
} |
|
97 |
} catch (ProcessInterruptedException e) { |
|
98 |
e.printStackTrace(); |
|
99 |
} catch (HistogramException e) { |
|
100 |
e.printStackTrace(); |
|
101 |
} |
|
102 |
|
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
} |
|
0 | 107 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.73/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/io/TestGdalWriter.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.io; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
|
29 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
30 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
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.ProcessInterruptedException; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
35 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
|
36 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
37 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
38 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
|
39 |
import org.gvsig.raster.impl.buffer.DefaultDataServerWriter; |
|
40 |
|
|
41 |
/** |
|
42 |
* Test para salvar un raster a tif variando sus par?metros. |
|
43 |
* |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class TestGdalWriter extends BaseTestCase { |
|
48 |
private String path1 = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
49 |
private String out = baseDir + "testGdalWriter"; |
|
50 |
private Buffer buf = null; |
|
51 |
private RasterDataStore d = null; |
|
52 |
private RasterQuery query = null; |
|
53 |
|
|
54 |
public void start() throws Exception { |
|
55 |
this.setUp(); |
|
56 |
this.testStack(); |
|
57 |
} |
|
58 |
|
|
59 |
protected void doSetUp() throws Exception { |
|
60 |
System.err.println("TestGdalWriter running..."); |
|
61 |
|
|
62 |
try { |
|
63 |
super.doSetUp(); |
|
64 |
} catch (Exception e) { |
|
65 |
e.printStackTrace(); |
|
66 |
} |
|
67 |
|
|
68 |
try { |
|
69 |
d = manager.open(path1); |
|
70 |
} catch (NotSupportedExtensionException e) { |
|
71 |
e.printStackTrace(); |
|
72 |
} catch (RasterDriverException e) { |
|
73 |
e.printStackTrace(); |
|
74 |
} |
|
75 |
query = manager.createQuery(); |
|
76 |
query.setDrawableBands(new int[]{0, 1, 2}); |
|
77 |
try { |
|
78 |
query.setAreaOfInterest(0, 0, (int)d.getWidth(), (int)d.getHeight()); |
|
79 |
buf = d.query(query); |
|
80 |
} catch (InvalidSetViewException e) { |
|
81 |
e.printStackTrace(); |
|
82 |
} catch (ProcessInterruptedException e) { |
|
83 |
e.printStackTrace(); |
|
84 |
} catch (RasterDriverException e) { |
|
85 |
e.printStackTrace(); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
public void testStack(){ |
|
90 |
try { |
|
91 |
File f = new File(out + ".tif"); |
|
92 |
f.delete(); |
|
93 |
f = new File(out + ".tfw"); |
|
94 |
f.delete(); |
|
95 |
convertBufferToTif(out + ".tif", d.getAffineTransform(), buf); |
|
96 |
} catch (IOException e) { |
|
97 |
e.printStackTrace(); |
|
98 |
} catch (ProcessInterruptedException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Funci?n para pruebas. |
|
105 |
* Convierte los ficheros generados por la funci?n cachear en ficheros tif para comprobar que est?n |
|
106 |
* bien generados. |
|
107 |
* @param grf |
|
108 |
* @param pageBuffer |
|
109 |
* @param pageLines |
|
110 |
* @throws IOException |
|
111 |
*/ |
|
112 |
private void convertBufferToTif(String fileName, AffineTransform at, Buffer buffer)throws IOException, ProcessInterruptedException { |
|
113 |
DataServerWriter dataWriter1 = new DefaultDataServerWriter(buffer); |
|
114 |
RasterWriter grw = null; |
|
115 |
try { |
|
116 |
Params params = manager.createWriter(fileName).getParams(); |
|
117 |
params.changeParamValue("blocksize", "7");//posici?n 7 del array -> 512 |
|
118 |
params.changeParamValue("tfw", "true"); |
|
119 |
params.changeParamValue("interleave", new Integer(1));//posici?n 1 del array -> PIXEL |
|
120 |
grw = manager.createWriter(dataWriter1, |
|
121 |
fileName, |
|
122 |
buffer.getBandCount(), |
|
123 |
at, |
|
124 |
buffer.getWidth(), |
|
125 |
buffer.getHeight(), |
|
126 |
buffer.getDataType(), |
|
127 |
params, |
|
128 |
null); |
|
129 |
|
|
130 |
} catch (NotSupportedExtensionException e) { |
|
131 |
e.printStackTrace(); |
|
132 |
} catch (RasterDriverException e) { |
|
133 |
e.printStackTrace(); |
|
134 |
} |
|
135 |
grw.dataWrite(); |
|
136 |
grw.writeClose(); |
|
137 |
} |
|
138 |
} |
|
0 | 139 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.73/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/io/rmf/TestRmfWrite.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.io.rmf; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.io.File; |
|
26 |
import java.io.FileNotFoundException; |
|
27 |
import java.io.IOException; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.DALLocator; |
|
30 |
import org.gvsig.fmap.dal.DataManager; |
|
31 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
|
32 |
import org.gvsig.fmap.dal.coverage.datastruct.BufferHistogram; |
|
33 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.HistogramException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
38 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
41 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
42 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
43 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
44 |
import org.gvsig.raster.impl.datastruct.GeoPoint; |
|
45 |
import org.gvsig.raster.impl.datastruct.GeoPointList; |
|
46 |
import org.gvsig.raster.impl.datastruct.DefaultNoData; |
|
47 |
import org.gvsig.raster.impl.datastruct.DefaultViewPortData; |
|
48 |
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer; |
|
49 |
import org.gvsig.raster.impl.datastruct.serializer.HistogramRmfSerializer; |
|
50 |
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer; |
|
51 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
|
52 |
import org.gvsig.raster.impl.store.DefaultMultiRasterStore; |
|
53 |
import org.gvsig.raster.impl.store.QueryableRaster; |
|
54 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
55 |
import org.gvsig.raster.impl.store.properties.DataStoreStatistics; |
|
56 |
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager; |
|
57 |
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer; |
|
58 |
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer; |
|
59 |
import org.gvsig.raster.impl.store.serializer.GeoPointListRmfSerializer; |
|
60 |
import org.gvsig.raster.impl.store.serializer.StatisticsRmfSerializer; |
|
61 |
import org.gvsig.raster.lizardtech.io.LizardTechProvider; |
|
62 |
/** |
|
63 |
* Test de escritura de ficheros rmf. |
|
64 |
* Escribe un fichero rmf con distintos bloques y a continuaci?n le pasa un |
|
65 |
* test de lectura para comprobar que se ha generado bien. |
|
66 |
* |
|
67 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
68 |
*/ |
|
69 |
public class TestRmfWrite extends BaseTestCase { |
|
70 |
private RmfBlocksManager blocksManager = null; |
|
71 |
private String path = baseDir + "miniRaster25x24.tif"; |
|
72 |
private String pathGif = baseDir + "gifTransparente.gif"; |
|
73 |
private String pathJpg = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
74 |
private BufferHistogram histogram = null; |
|
75 |
private ColorTable colorTable = null; |
|
76 |
private RasterDataStore f = null; |
|
77 |
private DefaultRasterProvider f2 = null; |
|
78 |
|
|
79 |
public void start() throws Exception { |
|
80 |
this.setUp(); |
|
81 |
this.testStack(); |
|
82 |
} |
|
83 |
|
|
84 |
protected void doSetUp() throws Exception { |
|
85 |
try { |
|
86 |
super.doSetUp(); |
|
87 |
} catch (Exception e) { |
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
System.err.println("TestRmfWrite running..."); |
|
91 |
|
|
92 |
RasterDataStore f1 = null; |
|
93 |
try { |
|
94 |
deleteRMF(path); |
|
95 |
deleteRMF(pathGif); |
|
96 |
deleteRMF(pathJpg); |
|
97 |
f = manager.open(path); |
|
98 |
f1 = manager.open(pathGif); |
|
99 |
|
|
100 |
DefaultMultiRasterStore grmf = new DefaultMultiRasterStore(); |
|
101 |
|
|
102 |
DataManager dm = DALLocator.getDataManager(); |
|
103 |
FilesystemStoreParameters p = (FilesystemStoreParameters)dm.createStoreParameters(LizardTechProvider.NAME); |
|
104 |
p.setFile(new File(pathJpg)); |
|
105 |
f2 = (DefaultRasterProvider)loadProvider(p, (DataStoreProviderServices)grmf); |
|
106 |
|
|
107 |
} catch (NotSupportedExtensionException e) { |
|
108 |
return; |
|
109 |
} catch (RasterDriverException e) { |
|
110 |
return; |
|
111 |
} |
|
112 |
|
|
113 |
try { |
|
114 |
histogram = f.getHistogramComputer().getBufferHistogram(); |
|
115 |
colorTable = f1.getColorTable(); |
|
116 |
f.getStatistics().calculate(); |
|
117 |
} catch (FileNotOpenException e) { |
|
118 |
e.printStackTrace(); |
|
119 |
} catch (RasterDriverException e) { |
|
120 |
e.printStackTrace(); |
|
121 |
} catch (ProcessInterruptedException e) { |
|
122 |
e.printStackTrace(); |
|
123 |
} catch (HistogramException e) { |
|
124 |
e.printStackTrace(); |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
public void testStack() throws Exception { |
|
129 |
deleteRMF(baseDir + "writetest.rmf"); |
|
130 |
blocksManager = new RmfBlocksManager(baseDir + "writetest.rmf"); |
|
131 |
|
|
132 |
// Histograma |
|
133 |
HistogramRmfSerializer ser = new HistogramRmfSerializer(histogram); |
|
134 |
blocksManager.addClient(ser); |
|
135 |
|
|
136 |
// Tabla de color |
|
137 |
// colorTable.setName("Prueba Tabla de Color"); |
|
138 |
ColorTableRmfSerializer ser1 = new ColorTableRmfSerializer(colorTable); |
|
139 |
blocksManager.addClient(ser1); |
|
140 |
|
|
141 |
// Estadisticas |
|
142 |
DataStoreStatistics stat = ((QueryableRaster)f).getProvider(0).getStatistics(); |
|
143 |
stat.setTailTrimValue(3.0, new Double(10.0)); |
|
144 |
stat.setTailTrimValue(4.0, new Double(16.0)); |
|
145 |
StatisticsRmfSerializer ser2 = new StatisticsRmfSerializer(stat); |
|
146 |
blocksManager.addClient(ser2); |
|
147 |
|
|
148 |
// Georreferenciaci?n |
|
149 |
GeoInfoRmfSerializer ser3 = new GeoInfoRmfSerializer(f2); |
|
150 |
blocksManager.addClient(ser3); |
|
151 |
|
|
152 |
// Puntos de control |
|
153 |
GeoPoint p1 = new GeoPoint(); |
|
154 |
p1.pixelPoint = new Point2D.Double(10, 10); |
|
155 |
p1.mapPoint = new Point2D.Double(34223.3, 2344.2); |
|
156 |
p1.leftViewPort = new DefaultViewPortData(); |
|
157 |
p1.leftViewPort.setExtent(new ExtentImpl(30032.3, 2103.3, 50023.3, 1234.3)); |
|
158 |
p1.rightViewPort = new DefaultViewPortData(); |
|
159 |
p1.rightViewPort.setExtent(new ExtentImpl(30032.3, 2103.3, 50023.3, 1234.3)); |
|
160 |
p1.leftCenterPoint = new Point2D.Double(24223.3, 3244.2); |
|
161 |
p1.rightCenterPoint = new Point2D.Double(2433.3, 6244.2); |
|
162 |
GeoPoint p2 = new GeoPoint(); |
|
163 |
p2.pixelPoint = new Point2D.Double(10, 10); |
|
164 |
p2.mapPoint = new Point2D.Double(34223.3, 2344.2); |
|
165 |
p2.leftViewPort = new DefaultViewPortData(); |
|
166 |
p2.leftViewPort.setExtent(new ExtentImpl(30032.3, 2103.3, 50023.3, 1234.3)); |
|
167 |
p2.rightViewPort = new DefaultViewPortData(); |
|
168 |
p2.rightViewPort.setExtent(new ExtentImpl(30032.3, 2103.3, 50023.3, 1234.3)); |
|
169 |
p2.leftCenterPoint = new Point2D.Double(24223.3, 3244.2); |
|
170 |
p2.rightCenterPoint = new Point2D.Double(2433.3, 6244.2); |
|
171 |
|
|
172 |
p1.leftViewPort.pxSize = new Point2D.Double(32, 34); |
|
173 |
|
|
174 |
GeoPointList list = new GeoPointList(); |
|
175 |
list.add(p1); |
|
176 |
list.add(p2); |
|
177 |
GeoPointListRmfSerializer ser4 = new GeoPointListRmfSerializer(list, p1.leftViewPort); |
|
178 |
blocksManager.addClient(ser4); |
|
179 |
|
|
180 |
// Valor NoData |
|
181 |
NoDataRmfSerializer ser5 = new NoDataRmfSerializer(new DefaultNoData(5450.0, 2)); |
|
182 |
blocksManager.addClient(ser5); |
|
183 |
|
|
184 |
// Interpretaci?n de color |
|
185 |
ColorInterpretation ci = f.getColorInterpretation(); |
|
186 |
ci.setColorInterpValue(0, DataStoreColorInterpretation.BLUE_BAND); |
|
187 |
ci.setColorInterpValue(2, DataStoreColorInterpretation.RED_BAND); |
|
188 |
ColorInterpretationRmfSerializer ser6 = new ColorInterpretationRmfSerializer((DataStoreColorInterpretation)f.getColorInterpretation()); |
|
189 |
blocksManager.addClient(ser6); |
|
190 |
|
|
191 |
try { |
|
192 |
blocksManager.write(); |
|
193 |
} catch (FileNotFoundException e) { |
|
194 |
e.printStackTrace(); |
|
195 |
} catch (IOException e) { |
|
196 |
e.printStackTrace(); |
|
197 |
} |
|
198 |
|
|
199 |
// Pasamos el test de lectura para comprobar que se ha generado bien |
|
200 |
TestRmfRead t = new TestRmfRead(); |
|
201 |
t.file = "writetest.rmf"; |
|
202 |
t.start(); |
|
203 |
} |
|
204 |
} |
|
0 | 205 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.73/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/coverage/dataset/io/rmf/TestRmfRead.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.io.rmf; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLocator; |
|
28 |
import org.gvsig.fmap.dal.DataManager; |
|
29 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
|
30 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
31 |
import org.gvsig.fmap.dal.coverage.datastruct.BufferHistogram; |
|
32 |
import org.gvsig.fmap.dal.coverage.datastruct.HistogramClass; |
|
33 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
|
34 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
35 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
38 |
import org.gvsig.raster.impl.datastruct.BufferHistogramImpl; |
|
39 |
import org.gvsig.raster.impl.datastruct.DefaultNoData; |
|
40 |
import org.gvsig.raster.impl.datastruct.GeoPoint; |
|
41 |
import org.gvsig.raster.impl.datastruct.GeoPointList; |
|
42 |
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer; |
|
43 |
import org.gvsig.raster.impl.datastruct.serializer.HistogramRmfSerializer; |
|
44 |
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer; |
|
45 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
|
46 |
import org.gvsig.raster.impl.store.DefaultMultiRasterStore; |
|
47 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
48 |
import org.gvsig.raster.impl.store.properties.DataStoreStatistics; |
|
49 |
import org.gvsig.raster.impl.store.rmf.IRmfBlock; |
|
50 |
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager; |
|
51 |
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer; |
|
52 |
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer; |
|
53 |
import org.gvsig.raster.impl.store.serializer.GeoPointListRmfSerializer; |
|
54 |
import org.gvsig.raster.impl.store.serializer.StatisticsRmfSerializer; |
|
55 |
import org.gvsig.raster.lizardtech.io.LizardTechProvider; |
|
56 |
/** |
|
57 |
* Test de lectura para ficheros rmf. Obtiene distintos tipos de bloques y |
|
58 |
* comprueba que el objeto que han de generar es correcto. |
|
59 |
* |
|
60 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
61 |
*/ |
|
62 |
public class TestRmfRead extends BaseTestCase { |
|
63 |
private RmfBlocksManager blocksManager = null; |
|
64 |
public String file = "readtest.rmf"; |
|
65 |
private DefaultRasterProvider f2 = null; |
|
66 |
protected Buffer raster = null; |
|
67 |
private String path1 = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
68 |
|
|
69 |
public void start() throws Exception { |
|
70 |
this.setUp(); |
|
71 |
this.testStack(); |
|
72 |
} |
|
73 |
|
|
74 |
protected void doSetUp() throws Exception { |
|
75 |
try { |
|
76 |
super.doSetUp(); |
|
77 |
} catch (Exception e) { |
|
78 |
e.printStackTrace(); |
|
79 |
} |
|
80 |
System.err.println("TestRmfRead running..."); |
|
81 |
|
|
82 |
deleteRMF(path1); |
|
83 |
DefaultMultiRasterStore grmf = new DefaultMultiRasterStore(); |
|
84 |
|
|
85 |
DataManager dm = DALLocator.getDataManager(); |
|
86 |
FilesystemStoreParameters p = (FilesystemStoreParameters)dm.createStoreParameters(LizardTechProvider.NAME); |
|
87 |
p.setFile(new File(path1)); |
|
88 |
f2 = (DefaultRasterProvider)loadProvider(p, (DataStoreProviderServices)grmf); |
|
89 |
} |
|
90 |
|
|
91 |
public void testStack(){ |
|
92 |
blocksManager = new RmfBlocksManager(baseDir + file); |
|
93 |
if (!blocksManager.checkRmf()) |
|
94 |
assertEquals(0, 1); |
|
95 |
HistogramRmfSerializer ser = new HistogramRmfSerializer(); |
|
96 |
ColorTableRmfSerializer ser1 = new ColorTableRmfSerializer(); |
|
97 |
StatisticsRmfSerializer ser2 = new StatisticsRmfSerializer(); |
|
98 |
GeoInfoRmfSerializer ser3 = new GeoInfoRmfSerializer(f2); |
|
99 |
GeoPointListRmfSerializer ser4 = new GeoPointListRmfSerializer(); |
|
100 |
NoDataRmfSerializer ser5 = new NoDataRmfSerializer(); |
|
101 |
ColorInterpretationRmfSerializer ser6 = new ColorInterpretationRmfSerializer((DataStoreColorInterpretation)f2.getColorInterpretation()); |
|
102 |
|
|
103 |
blocksManager.addClient(ser); |
|
104 |
blocksManager.addClient(ser1); |
|
105 |
blocksManager.addClient(ser2); |
|
106 |
blocksManager.addClient(ser3); |
|
107 |
blocksManager.addClient(ser4); |
|
108 |
blocksManager.addClient(ser5); |
|
109 |
blocksManager.addClient(ser6); |
|
110 |
|
|
111 |
try { |
|
112 |
blocksManager.read(null); |
|
113 |
for (int i = 0; i < blocksManager.getClientsCount(); i++) { |
|
114 |
IRmfBlock client = blocksManager.getClient(i); |
|
115 |
if (client instanceof HistogramRmfSerializer) |
|
116 |
testHistogram((BufferHistogram) client.getResult()); |
|
117 |
if (client instanceof ColorTableRmfSerializer) { |
|
118 |
ColorTable colorTable = (ColorTable) client.getResult(); |
|
119 |
colorTable.setInterpolated(false); |
|
120 |
testColorTable(colorTable); |
|
121 |
} |
|
122 |
if (client instanceof StatisticsRmfSerializer) |
|
123 |
testStatistics((DataStoreStatistics) client.getResult()); |
|
124 |
if (client instanceof NoDataRmfSerializer) |
|
125 |
testNoData((DefaultNoData) client.getResult()); |
|
126 |
// if (client instanceof GeoInfoRmfSerializer) |
|
127 |
// testGeoInfo((RasterDataset) client.getResult()); |
|
128 |
if (client instanceof GeoPointListRmfSerializer) |
|
129 |
testGeoPoints((GeoPointList) client.getResult()); |
|
130 |
if (client instanceof ColorInterpretationRmfSerializer) { |
|
131 |
DataStoreColorInterpretation ci = (DataStoreColorInterpretation) client.getResult(); |
|
132 |
testColorInterpretation(ci); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
} catch (ParsingException e) { |
|
137 |
e.printStackTrace(); |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
141 |
|
|
142 |
public void testColorInterpretation(DataStoreColorInterpretation ci) { |
|
143 |
for (int j = 0; j < ci.length(); j++) { |
|
144 |
String value = ci.get(j); |
|
145 |
// System.out.println(value); |
|
146 |
if (j == 0) |
|
147 |
assertEquals(value, "Red"); |
|
148 |
if (j == 1) |
|
149 |
assertEquals(value, "Green"); |
|
150 |
if (j == 2) |
|
151 |
assertEquals(value, "Blue"); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
public void testHistogram(BufferHistogram h) { |
|
156 |
BufferHistogram h2 = BufferHistogramImpl.convertHistogramToRGB(h); |
|
157 |
|
|
158 |
HistogramClass[][] classes = h2.getHistogram(); |
|
159 |
for (int iBand = 0; iBand < classes.length; iBand++) |
|
160 |
for (int iValue = 0; iValue < classes[iBand].length; iValue++) { |
|
161 |
assertEquals((int) classes[iBand][iValue].getMin(), iValue); |
|
162 |
assertEquals((int) classes[iBand][iValue].getMax(), iValue + 1); |
|
163 |
} |
|
164 |
|
|
165 |
assertEquals((int) h.getHistogramValue(0, 0), 16); |
|
166 |
assertEquals((int) h.getHistogramValue(0, 1), 4); |
|
167 |
assertEquals((int) h.getHistogramValue(0, 23), 6); |
|
168 |
assertEquals((int) h.getHistogramValue(0, 48), 4); |
|
169 |
|
|
170 |
assertEquals((int) h.getHistogramValue(1, 0), 2); |
|
171 |
assertEquals((int) h.getHistogramValue(1, 4), 1); |
|
172 |
assertEquals((int) h.getHistogramValue(1, 7), 8); |
|
173 |
assertEquals((int) h.getHistogramValue(1, 20), 4); |
|
174 |
|
|
175 |
assertEquals((int) h.getHistogramValue(2, 0), 25); |
|
176 |
assertEquals((int) h.getHistogramValue(2, 2), 1); |
|
177 |
assertEquals((int) h.getHistogramValue(2, 13), 4); |
|
178 |
assertEquals((int) h.getHistogramValue(2, 21), 2); |
|
179 |
} |
|
180 |
|
|
181 |
public void testColorTable(ColorTable ct) { |
|
182 |
|
|
183 |
// byte[][] color = ct.getColorTableByBand(); |
|
184 |
|
|
185 |
// assertEquals(ct.getName(), "Prueba Tabla de Color"); |
|
186 |
|
|
187 |
assertEquals(ct.getRGBAByBand(15)[0] & 0xff, 95); |
|
188 |
assertEquals(ct.getRGBAByBand(15)[1] & 0xff, 95); |
|
189 |
assertEquals(ct.getRGBAByBand(15)[2] & 0xff, 95); |
|
190 |
|
|
191 |
assertEquals(ct.getRGBAByBand(22)[0] & 0xff, 0); |
|
192 |
assertEquals(ct.getRGBAByBand(22)[1] & 0xff, 0); |
|
193 |
assertEquals(ct.getRGBAByBand(22)[2] & 0xff, 0); |
|
194 |
|
|
195 |
assertEquals(ct.getRGBAByBand(24)[0] & 0xff, 0); |
|
196 |
assertEquals(ct.getRGBAByBand(24)[1] & 0xff, 0); |
|
197 |
assertEquals(ct.getRGBAByBand(24)[2] & 0xff, 0); |
|
198 |
|
|
199 |
assertEquals(ct.getRGBAByBand(28)[0] & 0xff, 0); |
|
200 |
assertEquals(ct.getRGBAByBand(28)[1] & 0xff, 0); |
|
201 |
assertEquals(ct.getRGBAByBand(28)[2] & 0xff, 0); |
|
202 |
|
|
203 |
assertEquals(ct.getRGBAByBand(0)[0] & 0xff, 255); |
|
204 |
assertEquals(ct.getRGBAByBand(0)[1] & 0xff, 255); |
|
205 |
assertEquals(ct.getRGBAByBand(0)[2] & 0xff, 255); |
|
206 |
|
|
207 |
assertEquals(ct.getRGBAByBand(1)[0] & 0xff, 0); |
|
208 |
assertEquals(ct.getRGBAByBand(1)[1] & 0xff, 0); |
|
209 |
assertEquals(ct.getRGBAByBand(1)[2] & 0xff, 0); |
|
210 |
|
|
211 |
assertEquals(ct.getRGBAByBand(2)[0] & 0xff, 0); |
|
212 |
assertEquals(ct.getRGBAByBand(2)[1] & 0xff, 102); |
|
213 |
assertEquals(ct.getRGBAByBand(2)[2] & 0xff, 255); |
|
214 |
|
|
215 |
// System.out.println(ct.getName()); |
Also available in: Unified diff