gvsig-geoprocess / org.gvsig.geoprocess / branches / refactor-2018 / org.gvsig.geoprocess / org.gvsig.geoprocess.lib / org.gvsig.geoprocess.lib.sextante / src / main / java / org / gvsig / geoprocess / lib / sextante / dataObjects / BufferWriteOnlyIRasterLayer.java @ 1058
History | View | Annotate | Download (5.31 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2012 gvSIG Association.
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.geoprocess.lib.sextante.dataObjects; |
25 |
|
26 |
import java.awt.geom.Rectangle2D; |
27 |
|
28 |
import es.unex.sextante.core.AnalysisExtent; |
29 |
import es.unex.sextante.core.Sextante; |
30 |
import es.unex.sextante.dataObjects.AbstractRasterLayer; |
31 |
import es.unex.sextante.gui.core.SextanteGUI; |
32 |
import es.unex.sextante.outputs.IOutputChannel; |
33 |
|
34 |
import org.cresques.cts.IProjection; |
35 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
36 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
37 |
|
38 |
/**
|
39 |
*
|
40 |
* @author volaya, nacho brodin (nachobrodin@gmail.com)
|
41 |
*
|
42 |
*/
|
43 |
public class BufferWriteOnlyIRasterLayer |
44 |
extends
|
45 |
AbstractRasterLayer { |
46 |
|
47 |
private String m_sFilename; |
48 |
private IProjection m_Projection;
|
49 |
protected RasterDriver m_RasterDriver;
|
50 |
|
51 |
|
52 |
public void create(final String sName, |
53 |
final String sFilename, |
54 |
final AnalysisExtent ae,
|
55 |
final int iDataType, |
56 |
final int iNumBands, |
57 |
final Object crs) throws BufferException { |
58 |
|
59 |
final RasterDriver rmd = new RasterDriver(ae, iDataType, iNumBands); |
60 |
rmd.setName(sName); |
61 |
rmd.setNoDataValue(SextanteGUI.getOutputFactory().getDefaultNoDataValue()); |
62 |
|
63 |
m_RasterDriver = rmd; |
64 |
m_sFilename = sFilename; |
65 |
m_Projection = (IProjection) crs; |
66 |
|
67 |
} |
68 |
|
69 |
|
70 |
public void create(final String sName, |
71 |
final String sFilename, |
72 |
final AnalysisExtent ge,
|
73 |
final int iDataType, |
74 |
final Object crs) { |
75 |
|
76 |
try {
|
77 |
create(sName, sFilename, ge, iDataType, 1, crs);
|
78 |
} catch (final BufferException e) { |
79 |
Sextante.addErrorToLog(e); |
80 |
} |
81 |
|
82 |
} |
83 |
|
84 |
|
85 |
@Override
|
86 |
public int getDataType() { |
87 |
|
88 |
return m_RasterDriver.getRasterBuf().getBand(0).getDataType(); |
89 |
|
90 |
} |
91 |
|
92 |
|
93 |
@Override
|
94 |
public void setCellValue(final int x, |
95 |
final int y, |
96 |
final int iBand, |
97 |
final double dValue) { |
98 |
|
99 |
m_RasterDriver.setCellValue(x, y, iBand, dValue); |
100 |
|
101 |
} |
102 |
|
103 |
|
104 |
@Override
|
105 |
public void setNoDataValue(final double dNoDataValue) { |
106 |
|
107 |
m_RasterDriver.setNoDataValue(dNoDataValue); |
108 |
|
109 |
} |
110 |
|
111 |
|
112 |
@Override
|
113 |
public void setNoData(final int x, |
114 |
final int y) { |
115 |
|
116 |
m_RasterDriver.setNoData(x, y); |
117 |
|
118 |
} |
119 |
|
120 |
|
121 |
@Override
|
122 |
public double getNoDataValue() { |
123 |
|
124 |
return m_RasterDriver.getNoDataValue();
|
125 |
|
126 |
} |
127 |
|
128 |
|
129 |
@Override
|
130 |
public double getCellValueInLayerCoords(final int x, |
131 |
final int y, |
132 |
final int band) { |
133 |
|
134 |
return m_RasterDriver.getCellValue(x, y, band);
|
135 |
|
136 |
} |
137 |
|
138 |
|
139 |
@Override
|
140 |
public int getBandsCount() { |
141 |
|
142 |
return m_RasterDriver.getRasterBuf().getBandCount();
|
143 |
|
144 |
} |
145 |
|
146 |
|
147 |
@Override
|
148 |
public String getName() { |
149 |
|
150 |
return m_RasterDriver.getName();
|
151 |
|
152 |
} |
153 |
|
154 |
|
155 |
@Override
|
156 |
public void postProcess() { |
157 |
|
158 |
m_RasterDriver.export(m_sFilename, m_Projection); |
159 |
|
160 |
} |
161 |
|
162 |
|
163 |
@Override
|
164 |
public void open() { |
165 |
|
166 |
} |
167 |
|
168 |
|
169 |
@Override
|
170 |
public void close() { |
171 |
|
172 |
m_RasterDriver.free(); |
173 |
|
174 |
} |
175 |
|
176 |
|
177 |
@Override
|
178 |
public Rectangle2D getFullExtent() { |
179 |
|
180 |
return m_RasterDriver.getGridExtent().getAsRectangle2D();
|
181 |
|
182 |
} |
183 |
|
184 |
|
185 |
@Override
|
186 |
public AnalysisExtent getLayerGridExtent() {
|
187 |
|
188 |
return m_RasterDriver.getGridExtent();
|
189 |
|
190 |
} |
191 |
|
192 |
|
193 |
@Override
|
194 |
public double getLayerCellSize() { |
195 |
|
196 |
|
197 |
return m_RasterDriver.getGridExtent().getCellSize();
|
198 |
|
199 |
|
200 |
} |
201 |
|
202 |
/**
|
203 |
*
|
204 |
* @return
|
205 |
*/
|
206 |
public String getFilename() { |
207 |
|
208 |
|
209 |
return m_sFilename;
|
210 |
|
211 |
} |
212 |
|
213 |
|
214 |
@Override
|
215 |
public Object getCRS() { |
216 |
|
217 |
return m_Projection;
|
218 |
|
219 |
} |
220 |
|
221 |
|
222 |
@Override
|
223 |
public void setName(final String name) { |
224 |
|
225 |
m_RasterDriver.setName(name); |
226 |
|
227 |
} |
228 |
|
229 |
|
230 |
@Override
|
231 |
public Object getBaseDataObject() { |
232 |
|
233 |
return m_RasterDriver;
|
234 |
|
235 |
} |
236 |
|
237 |
|
238 |
@Override
|
239 |
public void free() { |
240 |
// TODO Auto-generated method stub
|
241 |
|
242 |
} |
243 |
|
244 |
@Override
|
245 |
public IOutputChannel getOutputChannel() {
|
246 |
// TODO Auto-generated method stub
|
247 |
return null; |
248 |
} |
249 |
|
250 |
public Buffer getBuffer() { |
251 |
return m_RasterDriver.getRasterBuf();
|
252 |
} |
253 |
|
254 |
} |