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