Revision 18716
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/resources/org/gvsig/raster/tasseledcap/algorithm/i18n/text.properties | ||
---|---|---|
1 |
layers_dont_intersect=Las capas no intersectan |
|
2 |
roi_not_inside=La zona de estudio no esta contenida en la extensi?n de las capas |
|
3 |
preparing_buffers=Preparando buffers |
|
4 |
writting_in_buffer=Escribiendo en buffer de salida |
|
5 |
processing_tc=Procesando Tasseled Cap |
|
6 |
tasseled_cap=Tasseled Cap |
|
7 |
type=Tipo |
|
8 |
|
|
0 | 9 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/resources/org/gvsig/raster/tasseledcap/algorithm/i18n/text_en.properties | ||
---|---|---|
1 |
layers_dont_intersect=Layers do not intersect |
|
2 |
roi_not_inside=The region of interest are not inside the extension of the layers |
|
3 |
preparing_buffers=Preparing buffers |
|
4 |
writting_in_buffer=Writing in the output buffer |
|
5 |
processing_tc=Procesando Tasseled Cap |
|
6 |
tasseled_cap=Tasseled Cap |
|
7 |
type=Type |
|
0 | 8 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.tasseledcap.algorithm.TasseledCapAlgorithmLibrary |
|
0 | 2 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapAlgorithmLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import org.gvsig.i18n.Messages; |
|
4 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
5 |
import org.gvsig.tools.library.AbstractLibrary; |
|
6 |
import org.gvsig.tools.library.LibraryException; |
|
7 |
|
|
8 |
/** |
|
9 |
* Initialization of PrincipalComponentsAlgorithmLibrary library. |
|
10 |
*/ |
|
11 |
public class TasseledCapAlgorithmLibrary extends AbstractLibrary { |
|
12 |
public static final String TASSELEDCAP_PROCESS_LABEL = "TasseledCapProcess"; |
|
13 |
|
|
14 |
@Override |
|
15 |
protected void doInitialize() throws LibraryException { |
|
16 |
// Nothing to do |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
protected void doPostInitialize() throws LibraryException { |
|
21 |
//Registers the process and its parameters |
|
22 |
RasterBaseAlgorithmLibrary.register(TASSELEDCAP_PROCESS_LABEL, TasseledCapProcess.class); |
|
23 |
TasseledCapProcess.registerParameters(); |
|
24 |
|
|
25 |
Messages.addResourceFamily( |
|
26 |
"org.gvsig.raster.tasseledcap.algorithm", |
|
27 |
TasseledCapAlgorithmLibrary.class.getClassLoader(), |
|
28 |
TasseledCapAlgorithmLibrary.class.getClass().getName()); |
|
29 |
//registerGeoProcess(new RasterReprojectAlgorithmLibrary()); |
|
30 |
|
|
31 |
Messages.addResourceFamily("org.gvsig.raster.tasseledcap.algorithm.i18n.text", |
|
32 |
TasseledCapAlgorithmLibrary.class.getClassLoader(), |
|
33 |
TasseledCapAlgorithmLibrary.class.getClass().getName()); |
|
34 |
} |
|
35 |
} |
|
0 | 36 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapException.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
4 |
|
|
5 |
|
|
6 |
/** |
|
7 |
* This exception is thrown if happen problems processing data with this algorithm. |
|
8 |
*/ |
|
9 |
public class TasseledCapException extends ProcessException { |
|
10 |
private static final long serialVersionUID = -3022090543908771484L; |
|
11 |
|
|
12 |
public TasseledCapException(String msg){ |
|
13 |
super(msg); |
|
14 |
} |
|
15 |
|
|
16 |
public TasseledCapException(String msg, Throwable e){ |
|
17 |
super(msg, e); |
|
18 |
} |
|
19 |
} |
|
0 | 20 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapProcess.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
7 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
8 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
9 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
10 |
import org.gvsig.fmap.dal.coverage.exception.CloneException; |
|
11 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
12 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
13 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
14 |
import org.gvsig.i18n.Messages; |
|
15 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
16 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
17 |
import org.gvsig.raster.roi.ROI; |
|
18 |
|
|
19 |
/** |
|
20 |
* Tasseled Cab Process |
|
21 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
22 |
*/ |
|
23 |
public class TasseledCapProcess extends DataProcess { |
|
24 |
public static int LANDSAT_MS = 0; |
|
25 |
public static int LANDSAT_TM = 1; |
|
26 |
public static int LANDSAT_ETM = 2; |
|
27 |
|
|
28 |
public static String RASTER_STORE = "RASTER_STORE"; |
|
29 |
public static String PATH = "PATH"; |
|
30 |
public static String FILENAME = "FILENAME"; |
|
31 |
public static String LANDSAT_TYPE = "LANDSAT_TYPE"; |
|
32 |
|
|
33 |
public static final String BUFFERS = "BUFFERS"; |
|
34 |
public static final String GRAPHIC_DATA = "GRAPHIC_DATA"; |
|
35 |
public static final String BANDS = "BANDS"; |
|
36 |
|
|
37 |
private RasterDataStore store = null; |
|
38 |
private String filename = null; |
|
39 |
|
|
40 |
private List<ROI> rois = null; |
|
41 |
private Extent extentResult = null; |
|
42 |
private boolean[] bands = null; |
|
43 |
private NoData nodata = null; |
|
44 |
private double matrixParams[][] = null; |
|
45 |
private int type = LANDSAT_MS; |
|
46 |
|
|
47 |
// MATRICES DE COEFICIENTES PARA CADA TRANSFORMACI?N |
|
48 |
double LandSatMS[][] = { |
|
49 |
/* Brillo de suelo */ {0.433, 0.632, 0.586, 0.264 }, |
|
50 |
/* Indice de Verdor */ {-0.290, -0.562, 0.600, 0.491 }, |
|
51 |
/* Indice de Senescencia */ {-0.829, 0.522, -0.039, 0.194}, |
|
52 |
/* Cuarta */ {0.223, 0.012, -0.543, 0.810} |
|
53 |
}; |
|
54 |
|
|
55 |
double LandSatTM[][] = { |
|
56 |
/* Brillo */ {0.33183, 0.33121, 0.55177, 0.42514, 0.48087, 0.25252 }, |
|
57 |
/* Verdor */ {-0.24717, -0.16263, -0.40639, 0.85468, 0.05493, -0.11749 }, |
|
58 |
/* Tercera */ {0.13929, 0.22490, 0.40359, 0.25178, -0.70133, -0.45732 }, |
|
59 |
}; |
|
60 |
|
|
61 |
double LandSatETM[][] = { |
|
62 |
/* Brightness */ {0.3561, 0.3972, 0.3904, 0.6966, 0.2286, 0.1596 }, |
|
63 |
/* Greenness */ {-0.3344, -0.3544, -0.4556, 0.6966, -0.0242, -0.2630}, |
|
64 |
/* Vetness */ {0.2626, 0.2141, 0.0926, 0.0656, -0.7629, -0.5388 }, |
|
65 |
/* Fourth */ {0.0805, -0.0498, 0.1950, -0.1327, 0.5752, -0.7775 }, |
|
66 |
/* Fifth */ {-0.7252, -0.0202, 0.6683, 0.0631, -0.1494, -0.0274 }, |
|
67 |
/* Sixth */ {0.4000, -0.8172, 0.3832, 0.0602, -0.1095, -0.0985 } |
|
68 |
}; |
|
69 |
|
|
70 |
|
|
71 |
public static void registerParameters() { |
|
72 |
registerInputParameter(RASTER_STORE, RasterDataStore.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
73 |
registerInputParameter(PATH, String.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
74 |
registerInputParameter(BANDS, Boolean[].class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
75 |
registerInputParameter(LANDSAT_TYPE, Integer.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
76 |
|
|
77 |
registerOutputParameter(FILENAME, String.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
78 |
registerOutputParameter(GRAPHIC_DATA, Double[].class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
79 |
} |
|
80 |
|
|
81 |
public void init() { |
|
82 |
store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null; |
|
83 |
filename = getStringParam(PATH); |
|
84 |
bands = (boolean[]) getParam(BANDS); |
|
85 |
type = getIntParam(LANDSAT_TYPE); |
|
86 |
} |
|
87 |
|
|
88 |
private boolean loadCoefMatrix(int type) { |
|
89 |
switch (type) { |
|
90 |
case 0: |
|
91 |
matrixParams = LandSatMS; |
|
92 |
if(getNumberOfOutputBands(bands) != 4) { |
|
93 |
return false; |
|
94 |
} |
|
95 |
break; |
|
96 |
case 1: |
|
97 |
matrixParams = LandSatTM; |
|
98 |
if(getNumberOfOutputBands(bands) != 6) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
break; |
|
102 |
case 2: |
|
103 |
matrixParams = LandSatETM; |
|
104 |
if(getNumberOfOutputBands(bands) != 6) { |
|
105 |
return false; |
|
106 |
} |
|
107 |
break; |
|
108 |
} |
|
109 |
return true; |
|
110 |
} |
|
111 |
|
|
112 |
public void process() throws ProcessInterruptedException, ProcessException { |
|
113 |
insertLineLog(Messages.getText("processing_tc")); |
|
114 |
if (store == null) { |
|
115 |
throw new TasseledCapException(Messages.getText("need_a_input")); |
|
116 |
} |
|
117 |
|
|
118 |
if(!loadCoefMatrix(type)) { |
|
119 |
throw new TasseledCapException(Messages.getText("wrong_number_of_bands")); |
|
120 |
} |
|
121 |
|
|
122 |
if(getROIEPSG() != null) { |
|
123 |
try { |
|
124 |
rois = store.getRois(getROIEPSG()); |
|
125 |
} catch (ROIException e2) { |
|
126 |
logger.error(Messages.getText("error_getting_rois"), e2); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
try { |
|
131 |
store = ((RasterDataStore)store).cloneDataStore(); |
|
132 |
} catch (CloneException e) { |
|
133 |
new TasseledCapException("Error cloning the input DataStore", e); |
|
134 |
} |
|
135 |
|
|
136 |
extentResult = getExtentResult(getOutputWindow(), rois, store); |
|
137 |
Rectangle2D sourcePxBBox = getSourcePxBox(extentResult, store); |
|
138 |
|
|
139 |
double cellSize = store.getCellSize(); |
|
140 |
|
|
141 |
nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(1, Buffer.TYPE_DOUBLE); |
|
142 |
double nodataValue = nodata.getValue().doubleValue(); |
|
143 |
|
|
144 |
Buffer outputBuffer = createOutputBuffer((int)sourcePxBBox.getWidth(), (int)sourcePxBBox.getHeight(), matrixParams.length, Buffer.TYPE_FLOAT); |
|
145 |
Buffer sourceBuffer = createSourceBuffer(store, sourcePxBBox, bands); |
|
146 |
|
|
147 |
|
|
148 |
insertLineLog(Messages.getText("writting_in_buffer")); |
|
149 |
float resultValue = 0; |
|
150 |
|
|
151 |
for (int i = 0; i < sourceBuffer.getHeight(); i++) { |
|
152 |
for (int j = 0; j < sourceBuffer.getWidth(); j++) { |
|
153 |
if (isInsideOfROI(j, i, rois, extentResult)) { |
|
154 |
for (int coef = 0; coef < matrixParams.length; coef++) { |
|
155 |
for(int band = 0; band < matrixParams[0].length; band++) { |
|
156 |
resultValue += getValue(sourceBuffer, i, j, band, coef); |
|
157 |
} |
|
158 |
outputBuffer.setElem(i, j, coef, resultValue); |
|
159 |
resultValue = 0; |
|
160 |
} |
|
161 |
} else { |
|
162 |
for (int iBand = 0; iBand < outputBuffer.getBandCount(); iBand++) { |
|
163 |
outputBuffer.setElem(i, j, iBand, (float)nodataValue); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
updatePercent((int)(i * 100 / sourcePxBBox.getHeight()), 100); |
|
168 |
} |
|
169 |
|
|
170 |
super.exportRaster(filename, outputBuffer, cellSize, extentResult.getULX(), |
|
171 |
extentResult.getULY(), nodata, store.getProjection()); |
|
172 |
|
|
173 |
addOutputValue(FILENAME, filename); |
|
174 |
addOutputValue(GRAPHIC_DATA, filename); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Gets the number of the selected bands |
|
179 |
* @param bandsPCs |
|
180 |
* @return |
|
181 |
*/ |
|
182 |
private int getNumberOfOutputBands(boolean[] b) { |
|
183 |
int bandCount = 0; |
|
184 |
for (int i = 0; i < b.length; i++) { |
|
185 |
if(b[i]) |
|
186 |
bandCount++; |
|
187 |
} |
|
188 |
return bandCount; |
|
189 |
} |
|
190 |
|
|
191 |
private float getValue(Buffer sourceBuffer, int i, int j, int band, int coef) { |
|
192 |
if (sourceBuffer.getDataType() == Buffer.TYPE_BYTE) { |
|
193 |
return (float)((sourceBuffer.getElemByte(i, j, band) & 0xff) * matrixParams[coef][band]); |
|
194 |
} |
|
195 |
if (sourceBuffer.getDataType() == Buffer.TYPE_SHORT) { |
|
196 |
return (float)(sourceBuffer.getElemShort(i, j, band) * matrixParams[coef][band]); |
|
197 |
} |
|
198 |
if (sourceBuffer.getDataType() == Buffer.TYPE_INT) { |
|
199 |
return (float)(sourceBuffer.getElemInt(i, j, band) * matrixParams[coef][band]); |
|
200 |
} |
|
201 |
if (sourceBuffer.getDataType() == Buffer.TYPE_FLOAT) { |
|
202 |
return (float)(sourceBuffer.getElemFloat(i, j, band) * matrixParams[coef][band]); |
|
203 |
} |
|
204 |
if (sourceBuffer.getDataType() == Buffer.TYPE_DOUBLE) { |
|
205 |
return (float)(sourceBuffer.getElemDouble(i, j, band) * matrixParams[coef][band]); |
|
206 |
} |
|
207 |
return nodata.getValue().floatValue(); |
|
208 |
} |
|
209 |
|
|
210 |
public String getTitle() { |
|
211 |
return Messages.getText("tasseled_cap"); |
|
212 |
} |
|
213 |
} |
|
0 | 214 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/algorithm/i18n/text.properties | ||
---|---|---|
1 |
layers_dont_intersect=Las capas no intersectan |
|
2 |
roi_not_inside=La zona de estudio no esta contenida en la extensi?n de las capas |
|
3 |
preparing_buffers=Preparando buffers |
|
0 | 4 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/algorithm/i18n/text_en.properties | ||
---|---|---|
1 |
layers_dont_intersect=Layers do not intersect |
|
2 |
roi_not_inside=The region of interest are not inside the extension of the layers |
|
3 |
preparing_buffers=Preparing buffers |
|
0 | 4 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.algorithm/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.tasseledcap.algorithm</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.raster.tasseledcap.algorithm</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.raster.tasseledcap</artifactId> |
|
10 |
<version>2.2.197</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.raster.algorithm</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.i18n</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.ui</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
57 |
<scope>compile</scope> |
|
58 |
</dependency> |
|
59 |
<!-- |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
63 |
<scope>runtime</scope> |
|
64 |
</dependency> |
|
65 |
--> |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
69 |
<scope>compile</scope> |
|
70 |
</dependency> |
|
71 |
<dependency> |
|
72 |
<groupId>org.gvsig</groupId> |
|
73 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
74 |
<scope>compile</scope> |
|
75 |
</dependency> |
|
76 |
<dependency> |
|
77 |
<groupId>org.gvsig</groupId> |
|
78 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
79 |
<scope>compile</scope> |
|
80 |
</dependency> |
|
81 |
<dependency> |
|
82 |
<groupId>org.gvsig</groupId> |
|
83 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
84 |
<scope>runtime</scope> |
|
85 |
</dependency> |
|
86 |
<dependency> |
|
87 |
<groupId>org.gvsig</groupId> |
|
88 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
89 |
<scope>compile</scope> |
|
90 |
</dependency> |
|
91 |
<dependency> |
|
92 |
<groupId>org.gvsig</groupId> |
|
93 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
94 |
<scope>compile</scope> |
|
95 |
</dependency> |
|
96 |
<dependency> |
|
97 |
<groupId>org.gvsig</groupId> |
|
98 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
99 |
<scope>compile</scope> |
|
100 |
</dependency> |
|
101 |
<dependency> |
|
102 |
<groupId>org.gvsig</groupId> |
|
103 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
104 |
<scope>compile</scope> |
|
105 |
</dependency> |
|
106 |
<dependency> |
|
107 |
<groupId>org.gvsig.legacy</groupId> |
|
108 |
<artifactId>jama</artifactId> |
|
109 |
<scope>compile</scope> |
|
110 |
</dependency> |
|
111 |
</dependencies> |
|
112 |
</project> |
|
0 | 113 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.app.tasseledcapclient/buildNumber.properties | ||
---|---|---|
1 |
#Tue Sep 20 23:01:19 CEST 2022 |
|
2 |
buildNumber=203 |
|
0 | 3 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.app.tasseledcapclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
<!-- <file> |
|
17 |
<source>${user.home}/.m2/repository/org/gvsig/org.gvsig.raster.tasseledcap.toolbox.algorithm/${project.version}/org.gvsig.raster.tasseledcap.toolbox.algorithm-${project.version}.jar</source> |
|
18 |
<outputDirectory>install/files</outputDirectory> |
|
19 |
</file>--> |
|
20 |
</files> |
|
21 |
|
|
22 |
<fileSets> |
|
23 |
<fileSet> |
|
24 |
<directory>src/main/resources-plugin</directory> |
|
25 |
<outputDirectory>.</outputDirectory> |
|
26 |
</fileSet> |
|
27 |
</fileSets> |
|
28 |
|
|
29 |
|
|
30 |
<dependencySets> |
|
31 |
<dependencySet> |
|
32 |
<useProjectArtifact>false</useProjectArtifact> |
|
33 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
34 |
<outputDirectory>lib</outputDirectory> |
|
35 |
<includes> |
|
36 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.app.tasseledcapclient:jar</include> |
|
37 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.lib.api:jar</include> |
|
38 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.lib.impl:jar</include> |
|
39 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.swing.api:jar</include> |
|
40 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.swing.impl:jar</include> |
|
41 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.algorithm:jar</include> |
|
42 |
<include>org.gvsig:org.gvsig.raster.tasseledcap.toolbox.algorithm:jar</include> |
|
43 |
</includes> |
|
44 |
</dependencySet> |
|
45 |
</dependencySets> |
|
46 |
</assembly> |
|
0 | 47 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.app.tasseledcapclient/src/main/java/org/gvsig/raster/tasseledcap/app/MainWindow.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.tasseledcap.app; |
|
22 |
|
|
23 |
import java.awt.BorderLayout; |
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
|
|
27 |
import javax.swing.JComponent; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
32 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
33 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons |
|
38 |
* of Cancel, Accept and others. |
|
39 |
* |
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
41 |
*/ |
|
42 |
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener { |
|
43 |
|
|
44 |
private static final long serialVersionUID = -4401123724140025094L; |
|
45 |
private ActionListener listener = null; |
|
46 |
private WindowInfo info = null; |
|
47 |
|
|
48 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
49 |
|
|
50 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener) { |
|
51 |
this.listener = actionListener; |
|
52 |
|
|
53 |
setLayout(new BorderLayout()); |
|
54 |
add(panel, BorderLayout.CENTER); |
|
55 |
|
|
56 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
57 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
58 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
59 |
|
|
60 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
61 |
info.setTitle(title); |
|
62 |
info.setWidth(w); |
|
63 |
info.setHeight(h); |
|
64 |
} |
|
65 |
|
|
66 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener, boolean closeButton) { |
|
67 |
this.listener = actionListener; |
|
68 |
|
|
69 |
setLayout(new BorderLayout()); |
|
70 |
add(panel, BorderLayout.CENTER); |
|
71 |
|
|
72 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
73 |
|
|
74 |
if(closeButton) { |
|
75 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setVisible(false); |
|
76 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).setVisible(false); |
|
77 |
getButtonsPanel().addClose(); |
|
78 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CLOSE).addActionListener(this); |
|
79 |
} else { |
|
80 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
81 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
82 |
} |
|
83 |
|
|
84 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
85 |
info.setTitle(title); |
|
86 |
info.setWidth(w); |
|
87 |
info.setHeight(h); |
|
88 |
} |
|
89 |
|
|
90 |
public WindowInfo getWindowInfo() { |
|
91 |
return info; |
|
92 |
} |
|
93 |
|
|
94 |
public Object getWindowProfile() { |
|
95 |
return profile; |
|
96 |
} |
|
97 |
|
|
98 |
public void actionPerformed(ActionEvent e) { |
|
99 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
100 |
listener.actionPerformed(e); |
|
101 |
PluginServices.getMDIManager().closeWindow(this); |
|
102 |
} |
|
103 |
|
|
104 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) { |
|
105 |
listener.actionPerformed(e); |
|
106 |
} |
|
107 |
|
|
108 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) { |
|
109 |
PluginServices.getMDIManager().closeWindow(this); |
|
110 |
} |
|
111 |
|
|
112 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CLOSE)) { |
|
113 |
PluginServices.getMDIManager().closeWindow(this); |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.app.tasseledcapclient/src/main/java/org/gvsig/raster/tasseledcap/app/TasseledCapExtension.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.app; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
|
|
6 |
import org.gvsig.andami.IconThemeHelper; |
|
7 |
import org.gvsig.andami.PluginServices; |
|
8 |
import org.gvsig.andami.plugins.Extension; |
|
9 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
10 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
12 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
13 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
14 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
15 |
import org.gvsig.i18n.Messages; |
|
16 |
import org.gvsig.raster.algorithm.BasicAPISwingPanel; |
|
17 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
18 |
import org.gvsig.raster.fmap.layers.*; |
|
19 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
20 |
import org.gvsig.raster.tasseledcap.app.toolbox.ToolboxTasseledCapLoader; |
|
21 |
import org.gvsig.raster.tasseledcap.swing.TasseledCapSwingLocator; |
|
22 |
import org.gvsig.tools.ToolsLocator; |
|
23 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
24 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
25 |
|
|
26 |
|
|
27 |
public class TasseledCapExtension extends Extension implements ActionListener { |
|
28 |
private BasicAPISwingPanel mainPanel = null; |
|
29 |
private MainWindow windowMainPanel = null; |
|
30 |
private FLyrRaster lyr = null; |
|
31 |
|
|
32 |
public void initialize() { |
|
33 |
|
|
34 |
// Adds an entry to the TOC's floating menu to those layers defined in this extension |
|
35 |
|
|
36 |
//ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("My_TocActions"); |
|
37 |
//exPoint.append("MyMenuEntry", "", new PrincipalComponentsTocMenuEntry()); |
|
38 |
|
|
39 |
// Adds a new tab to the "add layer" dialog |
|
40 |
|
|
41 |
//AddLayer.addWizard(PrincipalComponentsWizard.class); |
|
42 |
|
|
43 |
// Adds a new button in the raster bar |
|
44 |
// TODO: Remove for providers |
|
45 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
46 |
ExtensionPoint point = extensionPoints.add("GenericToolBarMenu"); |
|
47 |
point.append("TasseledCap", "", TasseledCapTocMenuEntry.getSingleton()); |
|
48 |
TasseledCapTocMenuEntry.setExtension(this); |
|
49 |
|
|
50 |
Messages.addResourceFamily("org.gvsig.raster.tasseledcap.app.i18n.text", |
|
51 |
TasseledCapExtension.class.getClassLoader(), |
|
52 |
TasseledCapExtension.class.getClass().getName()); |
|
53 |
|
|
54 |
initilizeIcons(); |
|
55 |
} |
|
56 |
|
|
57 |
public void postInitialize() { |
|
58 |
new ToolboxTasseledCapLoader().registerTool(); |
|
59 |
} |
|
60 |
|
|
61 |
public void execute(String actionCommand) { |
|
62 |
if (actionCommand.compareTo("TasseledCap") == 0) { |
|
63 |
lyr = getSelectedLayer(); |
|
64 |
if(lyr == null) { |
|
65 |
RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_found"), null); |
|
66 |
return; |
|
67 |
} |
|
68 |
|
|
69 |
String defaultROIEPSG = getFirstMapCtrl().getProjection().getAbrev(); |
|
70 |
|
|
71 |
mainPanel = TasseledCapSwingLocator.getSwingManager().createTasseledCapMainPanel( |
|
72 |
lyr.getDataStore(), |
|
73 |
lyr.getName(), |
|
74 |
lyr.getDataStore().getBandCount(), |
|
75 |
defaultROIEPSG); |
|
76 |
|
|
77 |
windowMainPanel = new MainWindow(mainPanel.getComponent(), |
|
78 |
Messages.getText("tasseled_cap"), |
|
79 |
400, 420, |
|
80 |
this); |
|
81 |
|
|
82 |
PluginServices.getMDIManager().addCentredWindow(windowMainPanel); |
|
83 |
|
|
84 |
mainPanel.initialize(); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Gets the Mapcontrol for the first view found. |
|
90 |
* @return |
|
91 |
*/ |
|
92 |
private MapControl getFirstMapCtrl() { |
|
93 |
IWindow[] windowList = PluginServices.getMDIManager().getOrderedWindows(); |
|
94 |
for (int i = 0; i < windowList.length; i++) { |
|
95 |
if(windowList[i] instanceof IView) { |
|
96 |
return ((IView)windowList[i]).getMapControl(); |
|
97 |
} |
|
98 |
} |
|
99 |
return null; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Gets the selected and valid layer |
|
104 |
* @return |
|
105 |
*/ |
|
106 |
private FLyrRaster getSelectedLayer() { |
|
107 |
MapControl firstMapCtrl = getFirstMapCtrl(); |
|
108 |
if (firstMapCtrl != null) { |
|
109 |
|
|
110 |
FLayer[] lyrList = |
|
111 |
getFirstMapCtrl().getMapContext().getLayers().getActives(); |
|
112 |
if (lyrList.length <= 1) { |
|
113 |
|
|
114 |
for (int i = 0; i < lyrList.length; i++) { |
|
115 |
if (lyrList[i] instanceof FLyrRaster) { |
|
116 |
return (FLyrRaster) lyrList[i]; |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
return null; |
|
122 |
} |
|
123 |
|
|
124 |
public boolean isEnabled() { |
|
125 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
126 |
if (selectedLayer == null) { |
|
127 |
return false; |
|
128 |
} |
|
129 |
|
|
130 |
if (!(selectedLayer instanceof ILayerState)) |
|
131 |
return false; |
|
132 |
|
|
133 |
if (!((ILayerState) selectedLayer).isOpen()) |
|
134 |
return false; |
|
135 |
|
|
136 |
if((selectedLayer).getRender().getFilterList().get("colortable") != null) |
|
137 |
return false; |
|
138 |
|
|
139 |
if(selectedLayer.getDataStore().getBandCount() < 4) |
|
140 |
return false; |
|
141 |
|
|
142 |
return true; |
|
143 |
} |
|
144 |
|
|
145 |
public boolean isVisible() { |
|
146 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
147 |
if (selectedLayer == null) |
|
148 |
return false; |
|
149 |
|
|
150 |
if (!(selectedLayer instanceof IRasterLayerActions)) |
|
151 |
return false; |
|
152 |
|
|
153 |
return ((IRasterLayerActions) selectedLayer).isActionEnabled(IRasterLayerActions.ENHANCED); |
|
154 |
} |
|
155 |
|
|
156 |
void initilizeIcons(){ |
|
157 |
IconThemeHelper.registerIcon(null, "tasseled-cab", this); |
|
158 |
IconThemeHelper.registerIcon(null, "gvsig-icon", this); |
|
159 |
IconThemeHelper.registerIcon(null, "gvsig-icon16x16", this); |
|
160 |
} |
|
161 |
|
|
162 |
public void actionPerformed(ActionEvent e) { |
|
163 |
//ACCEPT MAIN PANEL |
|
164 |
if( e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY) || |
|
165 |
e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
166 |
DataProcess task = null; |
|
167 |
try { |
|
168 |
task = (DataProcess)mainPanel.getResult(); |
|
169 |
} catch (Exception e1) { |
|
170 |
RasterSwingLibrary.messageBoxError(Messages.getText("problems_creating_process"), null); |
|
171 |
return; |
|
172 |
} |
|
173 |
task.setActions(new ProcessEndActions(windowMainPanel, lyr)); |
|
174 |
task.init(); |
|
175 |
task.start(); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
public void interrupted() { |
|
180 |
|
|
181 |
} |
|
182 |
|
|
183 |
public void updateProgress(int current, int total) { |
|
184 |
|
|
185 |
} |
|
186 |
} |
|
0 | 187 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.197/org.gvsig.raster.tasseledcap.app.tasseledcapclient/src/main/java/org/gvsig/raster/tasseledcap/app/TasseledCapTocMenuEntry.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.app; |
|
2 |
|
|
3 |
import javax.swing.Icon; |
|
4 |
|
|
5 |
import org.gvsig.andami.IconThemeHelper; |
|
6 |
import org.gvsig.andami.plugins.Extension; |
|
7 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
8 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.i18n.Messages; |
|
11 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
12 |
import org.gvsig.raster.fmap.layers.ILayerState; |
|
13 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
14 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
|
15 |
|
|
16 |
public class TasseledCapTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
|
17 |
static private TasseledCapTocMenuEntry singleton = null; |
|
18 |
private static Extension extension = null; |
|
19 |
|
|
20 |
|
|
21 |
public static void setExtension(Extension ext) { |
|
22 |
extension = ext; |
|
23 |
} |
|
24 |
|
|
25 |
private TasseledCapTocMenuEntry() {} |
|
26 |
|
|
27 |
static public TasseledCapTocMenuEntry getSingleton() { |
|
28 |
if (singleton == null) |
|
29 |
singleton = new TasseledCapTocMenuEntry(); |
|
30 |
return singleton; |
|
31 |
} |
|
32 |
|
|
33 |
public String getGroup() { |
|
34 |
return "Multispectral"; |
|
35 |
} |
|
36 |
|
|
37 |
public int getGroupOrder() { |
|
38 |
return 55; |
|
39 |
} |
|
40 |
|
|
41 |
public int getOrder() { |
|
42 |
return 0; |
|
43 |
} |
|
44 |
|
|
45 |
public String getText() { |
|
46 |
return Messages.getText("tasseled_cap"); |
|
47 |
} |
|
48 |
|
|
49 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
50 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
51 |
return false; |
|
52 |
|
|
53 |
if (!(selectedItems[0] instanceof ILayerState)) |
|
54 |
return false; |
|
55 |
|
|
56 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
|
57 |
return false; |
|
58 |
|
|
59 |
if(((FLyrRaster) selectedItems[0]).getRender().getFilterList().get("colortable") != null) |
|
60 |
return false; |
|
61 |
|
|
62 |
if(((FLyrRaster) selectedItems[0]).getDataStore().getBandCount() < 4) |
|
63 |
return false; |
|
64 |
|
|
65 |
return true; |
|
66 |
} |
|
67 |
|
|
68 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
69 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
70 |
return false; |
|
71 |
|
Also available in: Unified diff