gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / pansharp / PanSharpeningFilter.java @ 2438
History | View | Annotate | Download (4.24 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.raster.impl.grid.filter.pansharp; |
23 |
|
24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
29 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
30 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
31 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
32 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
33 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
34 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
35 |
import org.gvsig.raster.impl.DefaultRasterManager; |
36 |
import org.gvsig.raster.impl.buffer.DefaultDataServerWriter; |
37 |
import org.gvsig.raster.impl.store.ParamsImpl; |
38 |
import org.gvsig.raster.util.DefaultColorConversion; |
39 |
|
40 |
|
41 |
|
42 |
/**
|
43 |
* Filtros de Pansharpening
|
44 |
* */
|
45 |
|
46 |
public class PanSharpeningFilter extends BaseRasterFilter { |
47 |
|
48 |
public static String[] names = new String[] {"pansharp"}; |
49 |
protected RasterDataStore dataset = null; |
50 |
protected int heightPancr = 0; |
51 |
protected int widthPancr = 0; |
52 |
protected int heightMultiespec = 0; |
53 |
protected int widthMultiespec = 0; |
54 |
protected int nBands = 0; |
55 |
protected int relX = 0; |
56 |
protected int relY = 0; |
57 |
protected int posPancromatica = 0; |
58 |
public ArrayList<Object> bandOrder = null; |
59 |
public int alpha = 0; |
60 |
public String method = ""; |
61 |
public String fileNameOutput = ""; |
62 |
public double coef = 0.0; |
63 |
public int coefBrovey = 0; |
64 |
protected int posPancromat = -1; |
65 |
protected Buffer bufferMultiespectral = null; |
66 |
protected Buffer bufferPancr = null; |
67 |
protected DefaultColorConversion colorConversion = null; |
68 |
|
69 |
public PanSharpeningFilter() {
|
70 |
super();
|
71 |
} |
72 |
|
73 |
public String getGroup() { |
74 |
return "espectrales"; |
75 |
} |
76 |
|
77 |
public int getInRasterDataType() { |
78 |
return 0; |
79 |
} |
80 |
|
81 |
public String[] getNames() { |
82 |
return names;
|
83 |
} |
84 |
|
85 |
public int getOutRasterDataType() { |
86 |
return 0; |
87 |
} |
88 |
|
89 |
|
90 |
public Params getUIParams(String nameFilter) { |
91 |
Params params = new ParamsImpl();
|
92 |
return params;
|
93 |
} |
94 |
|
95 |
|
96 |
public boolean isVisible() { |
97 |
return false; |
98 |
} |
99 |
|
100 |
public void post() { |
101 |
// Escritura del raster a disco en fichero temporal
|
102 |
RasterWriter grw = null;
|
103 |
DefaultDataServerWriter writerBufferServer = new DefaultDataServerWriter(rasterResult);
|
104 |
|
105 |
try {
|
106 |
grw = DefaultRasterManager.getInstance().createWriter(writerBufferServer, |
107 |
fileNameOutput, |
108 |
rasterResult.getBandCount(), |
109 |
dataset.getAffineTransformByProvider()[posPancromat], |
110 |
rasterResult.getWidth(), |
111 |
rasterResult.getHeight(), |
112 |
rasterResult.getDataType(), |
113 |
DefaultRasterManager.getInstance().createWriterParams(fileNameOutput), |
114 |
dataset.getProjection()); |
115 |
grw.setWkt(dataset.getWktProjection()); |
116 |
grw.dataWrite(); |
117 |
grw.writeClose(); |
118 |
|
119 |
} catch (NotSupportedExtensionException e) {
|
120 |
e.printStackTrace(); |
121 |
} catch (RasterDriverException e) {
|
122 |
e.printStackTrace(); |
123 |
} catch (IOException e) { |
124 |
e.printStackTrace(); |
125 |
} catch (ProcessInterruptedException e) {
|
126 |
//TODO: Gestionar cancelaci?n de escritura
|
127 |
} |
128 |
rasterResult.dispose(); |
129 |
} |
130 |
|
131 |
public void pre() { |
132 |
if(colorConversion == null) |
133 |
colorConversion = new DefaultColorConversion();
|
134 |
} |
135 |
|
136 |
public void process(int x, int y) { |
137 |
} |
138 |
|
139 |
} |