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 / PanSharpeningListManager.java @ 1426
History | View | Annotate | Download (10.3 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.util.ArrayList; |
25 |
import java.util.List; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
28 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
29 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
30 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
31 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
33 |
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl; |
34 |
import org.gvsig.raster.impl.store.ParamImpl; |
35 |
import org.gvsig.tools.ToolsLocator; |
36 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
37 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
38 |
/**
|
39 |
* Gestion de la lista de filtros
|
40 |
*/
|
41 |
public class PanSharpeningListManager implements RasterFilterListManager { |
42 |
protected RasterFilterList filterList = null; |
43 |
|
44 |
/**
|
45 |
* Default constructor. Sets the filter list.
|
46 |
* @param filterList
|
47 |
*/
|
48 |
public PanSharpeningListManager(RasterFilterList filterList) {
|
49 |
this.filterList = filterList;
|
50 |
} |
51 |
|
52 |
// Constructor
|
53 |
public PanSharpeningListManager(RasterFilterListManagerImpl filterListManager){
|
54 |
this.filterList = filterListManager.getFilterList();
|
55 |
} |
56 |
|
57 |
/**
|
58 |
* Registra PanSharpeningListManager en los puntos de extension de RasterFilter
|
59 |
*/
|
60 |
public static void register() { |
61 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
62 |
ExtensionPoint point = extensionPoints.get("RasterFilter");
|
63 |
point.append("PanSharpening", "", PanSharpeningListManager.class); |
64 |
} |
65 |
|
66 |
public Class<?> getFilterClassByID(String id) { |
67 |
if(id.compareTo("pansharp") == 0) |
68 |
return PanSharpeningFilter.class;
|
69 |
return null; |
70 |
} |
71 |
|
72 |
/*
|
73 |
* (non-Javadoc)
|
74 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#addFilter(java.lang.Class, org.gvsig.fmap.dal.coverage.datastruct.Params)
|
75 |
*/
|
76 |
@SuppressWarnings("unchecked") |
77 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
78 |
if (PanSharpeningFilter.class.isAssignableFrom(classFilter)) {
|
79 |
String method = ""; |
80 |
String fileNameOutput = null; |
81 |
RasterDataStore dataset = null;
|
82 |
ArrayList order = null; |
83 |
int alpha = 0, coefBrovey = 0, posPancromatica = -1; |
84 |
double coef = 0; |
85 |
|
86 |
for (int i = 0; i < params.getNumParams(); i++) { |
87 |
if (((ParamImpl)params.getParam(i)).getId().equals("dataset")) |
88 |
dataset = (RasterDataStore) params.getParam(i); |
89 |
if (((ParamImpl)params.getParam(i)).getId().equals("posPancromatica")) |
90 |
posPancromatica = new Integer((String) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue(); |
91 |
if (((ParamImpl)params.getParam(i)).getId().equals("order")) |
92 |
order = (ArrayList) ((ParamImpl)params.getParam(i)).getDefaultValue();
|
93 |
if (((ParamImpl)params.getParam(i)).getId().equals("alpha")) |
94 |
alpha = new Integer((String) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue(); |
95 |
if (((ParamImpl)params.getParam(i)).getId().equals("method")) |
96 |
method = new String((String) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
97 |
if (((ParamImpl)params.getParam(i)).getId().equals("coef")) |
98 |
coef = new Double((String) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue(); |
99 |
if (((ParamImpl)params.getParam(i)).getId().equals("coefBrovey")) |
100 |
coefBrovey = new Integer((String) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue(); |
101 |
if (((ParamImpl)params.getParam(i)).getId().equals("fileNameOutput")) |
102 |
fileNameOutput = new String((String) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
103 |
} |
104 |
addPanSharpeningFilter(dataset, posPancromatica, order, alpha, method, coef, coefBrovey, fileNameOutput); |
105 |
} |
106 |
} |
107 |
|
108 |
/*
|
109 |
* (non-Javadoc)
|
110 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#addFilter(org.gvsig.fmap.dal.coverage.datastruct.Params)
|
111 |
*/
|
112 |
public void addFilter(Params params) throws FilterTypeException { |
113 |
addFilter(PanSharpeningFilter.class, params); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* A?ade un filtro pansharp a la pila de filtros.
|
118 |
* @param dataset: dataset con los ficheros
|
119 |
* @param posPancromatica posicion de la banda pancromatica
|
120 |
* @param orden: orden de asignacion de las bandas a RGB. El valor contenido en cada posicion del array
|
121 |
* se corresponde al n?mero de banda de fichero que se visualiza en R, G y B.
|
122 |
* @param alpha
|
123 |
* @param method metodo(HSL o Brovey)
|
124 |
* @param coef
|
125 |
* @param coefBrovey
|
126 |
* @throws FilterTypeException
|
127 |
*/
|
128 |
@SuppressWarnings("unchecked") |
129 |
public void addPanSharpeningFilter(RasterDataStore ldatastore,int posPancromatica, ArrayList order, int alpha, String method, double coef, int coefBrovey,String fileNameOutput) throws FilterTypeException { |
130 |
RasterFilter filter = new PanSharpeningByteFilter();
|
131 |
|
132 |
if (filter != null) { |
133 |
filter.addParam("dataset", ldatastore);
|
134 |
filter.addParam("posPancromatica", new Integer(posPancromatica)); |
135 |
filter.addParam("order", order);
|
136 |
filter.addParam("alpha", new Integer(alpha)); |
137 |
filter.addParam("method", method);
|
138 |
filter.addParam("coef", new Double(coef)); |
139 |
filter.addParam("coefBrovey", new Integer(coefBrovey)); |
140 |
filter.addParam("fileNameOutput", fileNameOutput);
|
141 |
filterList.add(filter); |
142 |
} |
143 |
} |
144 |
|
145 |
public int createFilterListFromStrings(List<String> filters, String fil, int filteri) { |
146 |
|
147 |
/* if ((fil.startsWith("filter.pansharpening.active")) && (RasterFilterListManager.getValue(fil).equals("true"))) {
|
148 |
|
149 |
int posPancromatica = 0;
|
150 |
int[] bandOrder = {0, 1, 2};
|
151 |
ArrayList files = new ArrayList();
|
152 |
IRasterDataset dataset=null;
|
153 |
int alpha = 0;
|
154 |
String method = "";
|
155 |
double coef = 0D;
|
156 |
int coefBrovey = 0;
|
157 |
|
158 |
for (int propFilter = 0;propFilter < filters.size();propFilter++) {
|
159 |
String elem = (String) filters.get(propFilter);
|
160 |
|
161 |
if (elem.startsWith("filter.pansharpening.dataset")) {
|
162 |
dataset = RasterFilterListManager.getValue(elem);
|
163 |
filters.remove(propFilter);
|
164 |
propFilter--;
|
165 |
}
|
166 |
if (elem.startsWith("filter.pansharpening.posPancromatica")) {
|
167 |
posPancromatica = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
168 |
filters.remove(propFilter);
|
169 |
propFilter--;
|
170 |
}
|
171 |
if (elem.startsWith("filter.pansharpening.bandOrder")) {
|
172 |
String rango = RasterFilterListManager.getValue(elem);
|
173 |
bandOrder[0] = Integer.parseInt(rango.substring(0, rango.indexOf(",")));
|
174 |
bandOrder[1] = Integer.parseInt(rango.substring(rango.indexOf(",") + 1, rango.lastIndexOf(",")));
|
175 |
bandOrder[2] = Integer.parseInt(rango.substring(rango.lastIndexOf(",") + 1, rango.length()));
|
176 |
filters.remove(propFilter);
|
177 |
propFilter--;
|
178 |
}
|
179 |
if (elem.startsWith("filter.pansharpening.file")) {
|
180 |
files.add(RasterFilterListManager.getValue(elem));
|
181 |
filters.remove(propFilter);
|
182 |
propFilter--;
|
183 |
}
|
184 |
if (elem.startsWith("filter.pansharpening.alpha")) {
|
185 |
alpha = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
186 |
filters.remove(propFilter);
|
187 |
propFilter--;
|
188 |
}
|
189 |
if (elem.startsWith("filter.pansharpening.method")) {
|
190 |
method = RasterFilterListManager.getValue(elem);
|
191 |
filters.remove(propFilter);
|
192 |
propFilter--;
|
193 |
}
|
194 |
if (elem.startsWith("filter.pansharpening.coefHSL")) {
|
195 |
coef = Double.parseDouble(RasterFilterListManager.getValue(elem));
|
196 |
filters.remove(propFilter);
|
197 |
propFilter--;
|
198 |
}
|
199 |
if (elem.startsWith("filter.pansharpening.coefBrovey")) {
|
200 |
coefBrovey = Integer.parseInt(RasterFilterListManager.getValue(elem));
|
201 |
//filters.remove(propFilter);
|
202 |
//propFilter--;
|
203 |
}
|
204 |
}
|
205 |
|
206 |
addPanSharpeningFilter(dataset,posPancromatica, bandOrder, alpha, method, coef, coefBrovey);
|
207 |
}*/
|
208 |
return filteri;
|
209 |
} |
210 |
|
211 |
public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
212 |
if (rf instanceof PanSharpeningFilter) { |
213 |
PanSharpeningFilter pansharpFilter = (PanSharpeningFilter) rf; |
214 |
filterList.add("filter.pansharpening.active=true");
|
215 |
filterList.add("filter.pansharpening.dataset=" + pansharpFilter.dataset);
|
216 |
filterList.add("filter.pansharpening.posPancromatica=" + pansharpFilter.posPancromatica);
|
217 |
filterList.add("filter.pansharpening.bandOrder=" + pansharpFilter.bandOrder.get(0) + "," + pansharpFilter.bandOrder.get(1) + "," + pansharpFilter.bandOrder.get(2)); |
218 |
filterList.add("filter.pansharpening.method=" + pansharpFilter.method);
|
219 |
filterList.add("filter.pansharpening.coefHSL=" + pansharpFilter.coef);
|
220 |
filterList.add("filter.pansharpening.coefBrovey=" + pansharpFilter.coefBrovey);
|
221 |
filterList.add("filter.pansharpening.alpha=" + pansharpFilter.alpha);
|
222 |
filterList.add("filter.pansharp.filterName=" + pansharpFilter.getName());
|
223 |
} |
224 |
return filterList;
|
225 |
} |
226 |
|
227 |
public List<Class<?>> getRasterFilterList() { |
228 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
229 |
filters.add(PanSharpeningFilter.class); |
230 |
return filters;
|
231 |
} |
232 |
|
233 |
/*
|
234 |
* (non-Javadoc)
|
235 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#getFilterList()
|
236 |
*/
|
237 |
public RasterFilterList getFilterList() {
|
238 |
return filterList;
|
239 |
} |
240 |
|
241 |
/*
|
242 |
* (non-Javadoc)
|
243 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#setFilterList(org.gvsig.fmap.dal.coverage.grid.RasterFilterList)
|
244 |
*/
|
245 |
public void setFilterList(RasterFilterList filterList) { |
246 |
this.filterList = filterList;
|
247 |
} |
248 |
|
249 |
/*
|
250 |
* (non-Javadoc)
|
251 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#createFilter(org.gvsig.fmap.dal.coverage.datastruct.Params)
|
252 |
*/
|
253 |
public RasterFilter createFilter(Params params) {
|
254 |
return null; |
255 |
} |
256 |
} |