Revision 1861
org.gvsig.raster.tools/trunk/templates/examples/org.gvsig.raster.roimask/org.gvsig.raster.roimask.algorithm/src/main/java/org/gvsig/raster/roimask/algorithm/ROIMaskProcess.java | ||
---|---|---|
6 | 6 |
|
7 | 7 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
8 | 8 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
9 |
import org.gvsig.fmap.dal.coverage.dataset.BufferParam; |
|
9 | 10 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
10 | 11 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
11 | 12 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
... | ... | |
16 | 17 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
17 | 18 |
import org.gvsig.i18n.Messages; |
18 | 19 |
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary; |
20 |
import org.gvsig.raster.tools.algorithm.base.process.ProcessException; |
|
19 | 21 |
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess; |
20 | 22 |
|
21 | 23 |
/** |
... | ... | |
88 | 90 |
nodata = getParam(NODATA) != null ? (NoData)getParam(NODATA) : null; |
89 | 91 |
} |
90 | 92 |
|
91 |
public void process() throws ProcessInterruptedException { |
|
93 |
public void process() throws ProcessInterruptedException, ProcessException {
|
|
92 | 94 |
long t1 = new java.util.Date().getTime(); |
93 | 95 |
insertLineLog(Messages.getText("...")); |
94 | 96 |
try { |
... | ... | |
150 | 152 |
} |
151 | 153 |
} |
152 | 154 |
|
153 |
private void processRGB(Extent extent, int w, int h, double cellsize) throws ProcessInterruptedException { |
|
154 |
alphaBand = RasterLocator.getManager().createBuffer( |
|
155 |
store.getDataType()[0], w, h, 4, true); |
|
155 |
private void processRGB(Extent extent, int w, int h, double cellsize) throws ProcessInterruptedException, ProcessException { |
|
156 |
BufferParam params = RasterLocator.getManager().getBufferFactory().createBufferParams( |
|
157 |
w, h, 4, store.getDataType()[0], true); |
|
158 |
try { |
|
159 |
alphaBand = RasterLocator.getManager().getBufferFactory().createBuffer(params); |
|
160 |
} catch (Exception e) { |
|
161 |
throw new ProcessException("Error creating buffer", e); |
|
162 |
} |
|
156 | 163 |
|
157 | 164 |
for (int row = 0; row < h; row++) { |
158 | 165 |
for (int col = 0; col < w; col++) { |
... | ... | |
180 | 187 |
} |
181 | 188 |
} |
182 | 189 |
|
183 |
private Buffer processMDT(Extent extent, Buffer inputBuffer, double cellsize) throws ProcessInterruptedException { |
|
190 |
private Buffer processMDT(Extent extent, Buffer inputBuffer, double cellsize) throws ProcessInterruptedException, ProcessException {
|
|
184 | 191 |
int w = inputBuffer.getWidth(); |
185 | 192 |
int h = inputBuffer.getHeight(); |
186 |
Buffer outputBuffer = RasterLocator.getManager().createBuffer( |
|
187 |
inputBuffer.getDataType(), w, h, inputBuffer.getBandCount(), true); |
|
188 |
|
|
193 |
Buffer outputBuffer = null; |
|
194 |
|
|
195 |
BufferParam params = RasterLocator.getManager().getBufferFactory().createBufferParams( |
|
196 |
w, h, inputBuffer.getBandCount(), inputBuffer.getDataType(), true); |
|
197 |
try { |
|
198 |
outputBuffer = RasterLocator.getManager().getBufferFactory().createBuffer(params); |
|
199 |
} catch (Exception e) { |
|
200 |
throw new ProcessException("Error creating buffer", e); |
|
201 |
} |
|
202 |
|
|
189 | 203 |
for (int row = 0; row < h; row++) { |
190 | 204 |
for (int col = 0; col < w; col++) { |
191 | 205 |
for (int nband = 0; nband < inputBuffer.getBandCount(); nband++) { |
Also available in: Unified diff