root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / pansharp / PanSharpeningListManager.java @ 22422
History | View | Annotate | Download (8.27 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.grid.filter.pansharp; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
|
23 |
import org.gvsig.raster.dataset.Params; |
24 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
25 |
import org.gvsig.raster.grid.filter.IRasterFilterListManager; |
26 |
import org.gvsig.raster.grid.filter.RasterFilter; |
27 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
28 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
29 |
import org.gvsig.raster.hierarchy.IRasterDataset; |
30 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoint; |
31 |
/**
|
32 |
* Gestion de la lista de filtros
|
33 |
*/
|
34 |
public class PanSharpeningListManager implements IRasterFilterListManager { |
35 |
protected RasterFilterList filterList = null; |
36 |
|
37 |
// Constructor
|
38 |
public PanSharpeningListManager(RasterFilterListManager filterListManager){
|
39 |
this.filterList = filterListManager.getFilterList();
|
40 |
} |
41 |
|
42 |
/**
|
43 |
* Registra PanSharpeningListManager en los puntos de extension de RasterFilter
|
44 |
*/
|
45 |
public static void register() { |
46 |
ExtensionPoint point = ExtensionPoint.getExtensionPoint("RasterFilter");
|
47 |
point.register("PanSharpening", PanSharpeningListManager.class);
|
48 |
} |
49 |
|
50 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
51 |
if (classFilter.equals(PanSharpeningFilter.class)) {
|
52 |
String method = ""; |
53 |
String fileNameOutput = null; |
54 |
IRasterDataset dataset = null;
|
55 |
ArrayList order = null; |
56 |
int alpha = 0, coefBrovey = 0, posPancromatica = -1; |
57 |
double coef = 0; |
58 |
|
59 |
for (int i = 0; i < params.getNumParams(); i++) { |
60 |
if (params.getParam(i).id.equals("dataset")) |
61 |
dataset = (IRasterDataset) params.getParam(i); |
62 |
if (params.getParam(i).id.equals("posPancromatica")) |
63 |
posPancromatica = new Integer((String) params.getParam(i).defaultValue).intValue(); |
64 |
if (params.getParam(i).id.equals("order")) |
65 |
order = (ArrayList) params.getParam(i).defaultValue;
|
66 |
if (params.getParam(i).id.equals("alpha")) |
67 |
alpha = new Integer((String) params.getParam(i).defaultValue).intValue(); |
68 |
if (params.getParam(i).id.equals("method")) |
69 |
method = new String((String) params.getParam(i).defaultValue); |
70 |
if (params.getParam(i).id.equals("coef")) |
71 |
coef = new Double((String) params.getParam(i).defaultValue).doubleValue(); |
72 |
if (params.getParam(i).id.equals("coefBrovey")) |
73 |
coefBrovey = new Integer((String) params.getParam(i).defaultValue).intValue(); |
74 |
if (params.getParam(i).id.equals("fileNameOutput")) |
75 |
fileNameOutput = new String((String) params.getParam(i).defaultValue); |
76 |
} |
77 |
addPanSharpeningFilter(dataset, posPancromatica, order, alpha, method, coef, coefBrovey, fileNameOutput); |
78 |
} |
79 |
} |
80 |
|
81 |
/**
|
82 |
* A?ade un filtro pansharp a la pila de filtros.
|
83 |
* @param dataset: dataset con los ficheros
|
84 |
* @param posPancromatica posicion de la banda pancromatica
|
85 |
* @param orden: orden de asignacion de las bandas a RGB. El valor contenido en cada posicion del array
|
86 |
* se corresponde al n?mero de banda de fichero que se visualiza en R, G y B.
|
87 |
* @param alpha
|
88 |
* @param method metodo(HSL o Brovey)
|
89 |
* @param coef
|
90 |
* @param coefBrovey
|
91 |
* @throws FilterTypeException
|
92 |
*/
|
93 |
public void addPanSharpeningFilter(IRasterDataset dataset,int posPancromatica, ArrayList order, int alpha, String method, double coef, int coefBrovey,String fileNameOutput) throws FilterTypeException { |
94 |
RasterFilter filter = new PanSharpeningByteFilter();
|
95 |
|
96 |
if (filter != null) { |
97 |
filter.addParam("dataset", dataset);
|
98 |
filter.addParam("posPancromatica", new Integer(posPancromatica)); |
99 |
filter.addParam("order", order);
|
100 |
filter.addParam("alpha", new Integer(alpha)); |
101 |
filter.addParam("method", method);
|
102 |
filter.addParam("coef", new Double(coef)); |
103 |
filter.addParam("coefBrovey", new Integer(coefBrovey)); |
104 |
filter.addParam("fileNameOutput", fileNameOutput);
|
105 |
filterList.add(filter); |
106 |
} |
107 |
} |
108 |
|
109 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) { |
110 |
|
111 |
/* if ((fil.startsWith("filter.pansharpening.active")) && (RasterFilterListManager.getValue(fil).equals("true"))) {
|
112 |
|
113 |
int posPancromatica = 0;
|
114 |
int[] bandOrder = {0, 1, 2};
|
115 |
ArrayList files = new ArrayList();
|
116 |
IRasterDataset dataset=null;
|
117 |
int alpha = 0;
|
118 |
String method = "";
|
119 |
double coef = 0D;
|
120 |
int coefBrovey = 0;
|
121 |
|
122 |
for (int propFilter = 0;propFilter < filters.size();propFilter++) {
|
123 |
String elem = (String) filters.get(propFilter);
|
124 |
|
125 |
if (elem.startsWith("filter.pansharpening.dataset")) {
|
126 |
dataset = RasterFilterListManager.getValue(elem);
|
127 |
filters.remove(propFilter);
|
128 |
propFilter--;
|
129 |
}
|
130 |
if (elem.startsWith("filter.pansharpening.posPancromatica")) {
|
131 |
posPancromatica = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
132 |
filters.remove(propFilter);
|
133 |
propFilter--;
|
134 |
}
|
135 |
if (elem.startsWith("filter.pansharpening.bandOrder")) {
|
136 |
String rango = RasterFilterListManager.getValue(elem);
|
137 |
bandOrder[0] = Integer.parseInt(rango.substring(0, rango.indexOf(",")));
|
138 |
bandOrder[1] = Integer.parseInt(rango.substring(rango.indexOf(",") + 1, rango.lastIndexOf(",")));
|
139 |
bandOrder[2] = Integer.parseInt(rango.substring(rango.lastIndexOf(",") + 1, rango.length()));
|
140 |
filters.remove(propFilter);
|
141 |
propFilter--;
|
142 |
}
|
143 |
if (elem.startsWith("filter.pansharpening.file")) {
|
144 |
files.add(RasterFilterListManager.getValue(elem));
|
145 |
filters.remove(propFilter);
|
146 |
propFilter--;
|
147 |
}
|
148 |
if (elem.startsWith("filter.pansharpening.alpha")) {
|
149 |
alpha = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
150 |
filters.remove(propFilter);
|
151 |
propFilter--;
|
152 |
}
|
153 |
if (elem.startsWith("filter.pansharpening.method")) {
|
154 |
method = RasterFilterListManager.getValue(elem);
|
155 |
filters.remove(propFilter);
|
156 |
propFilter--;
|
157 |
}
|
158 |
if (elem.startsWith("filter.pansharpening.coefHSL")) {
|
159 |
coef = Double.parseDouble(RasterFilterListManager.getValue(elem));
|
160 |
filters.remove(propFilter);
|
161 |
propFilter--;
|
162 |
}
|
163 |
if (elem.startsWith("filter.pansharpening.coefBrovey")) {
|
164 |
coefBrovey = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
165 |
//filters.remove(propFilter);
|
166 |
//propFilter--;
|
167 |
}
|
168 |
}
|
169 |
|
170 |
addPanSharpeningFilter(dataset,posPancromatica, bandOrder, alpha, method, coef, coefBrovey);
|
171 |
}*/
|
172 |
return filteri;
|
173 |
} |
174 |
|
175 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
176 |
if (rf instanceof PanSharpeningFilter) { |
177 |
PanSharpeningFilter pansharpFilter = (PanSharpeningFilter) rf; |
178 |
filterList.add("filter.pansharpening.active=true");
|
179 |
filterList.add("filter.pansharpening.dataset=" + pansharpFilter.dataset);
|
180 |
filterList.add("filter.pansharpening.posPancromatica=" + pansharpFilter.posPancromatica);
|
181 |
filterList.add("filter.pansharpening.bandOrder=" + pansharpFilter.bandOrder.get(0) + "," + pansharpFilter.bandOrder.get(1) + "," + pansharpFilter.bandOrder.get(2)); |
182 |
filterList.add("filter.pansharpening.method=" + pansharpFilter.method);
|
183 |
filterList.add("filter.pansharpening.coefHSL=" + pansharpFilter.coef);
|
184 |
filterList.add("filter.pansharpening.coefBrovey=" + pansharpFilter.coefBrovey);
|
185 |
filterList.add("filter.pansharpening.alpha=" + pansharpFilter.alpha);
|
186 |
filterList.add("filter.pansharp.filterName=" + pansharpFilter.getName());
|
187 |
} |
188 |
return filterList;
|
189 |
} |
190 |
|
191 |
public ArrayList getRasterFilterList() { |
192 |
ArrayList filters = new ArrayList(); |
193 |
filters.add(PanSharpeningFilter.class); |
194 |
return filters;
|
195 |
} |
196 |
} |