Revision 3174 org.gvsig.raster.tasseledcap/trunk/org.gvsig.raster.tasseledcap/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/java/org/gvsig/raster/tasseledcap/TasseledCapSextanteAlgorithm.java
TasseledCapSextanteAlgorithm.java | ||
---|---|---|
30 | 30 |
public static final String LAYER = TasseledCapProcess.RASTER_STORE; |
31 | 31 |
public static final String USE_ROI = "USE_ROI"; |
32 | 32 |
public static final String TYPE = "TYPE"; |
33 |
|
|
33 |
|
|
34 | 34 |
public static String[] LANDSAT_TYPES = new String[]{"Landsat MS" , "Landsat TM", "Landsat ETM"}; |
35 |
|
|
36 |
|
|
35 |
|
|
36 |
|
|
37 | 37 |
private boolean useROI = false; |
38 | 38 |
private DataProcess taskStats = null; |
39 | 39 |
private DataProcess taskPC = null; |
40 | 40 |
private int type = 0; |
41 |
|
|
42 | 41 |
|
42 |
|
|
43 | 43 |
public void defineCharacteristics() { |
44 | 44 |
setName(getTranslation("tasseledcap")); |
45 | 45 |
setGroup(getTranslation("multispectral")); |
46 |
|
|
46 |
|
|
47 | 47 |
try { |
48 | 48 |
m_Parameters.addInputRasterLayer(LAYER, getTranslation("Input_layer"), true); |
49 | 49 |
m_Parameters.addBoolean(USE_ROI, getTranslation("use_roi"), false); |
... | ... | |
59 | 59 |
if(existsOutPutFile(TasseledCapSextanteAlgorithm.RESULT, 0)) { |
60 | 60 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
61 | 61 |
} |
62 |
|
|
62 |
|
|
63 | 63 |
IRasterLayer input = m_Parameters.getParameterValueAsRasterLayer(LAYER); |
64 | 64 |
useROI = m_Parameters.getParameterValueAsBoolean(USE_ROI); |
65 | 65 |
String value = m_Parameters.getParameterValueAsString(TYPE); |
... | ... | |
68 | 68 |
if(LANDSAT_TYPES[j].equals(value)) |
69 | 69 |
type = j; |
70 | 70 |
} |
71 |
|
|
71 |
|
|
72 | 72 |
FLyrRaster lyrRaster = ((FLyrRaster)input.getBaseDataObject()); |
73 | 73 |
IRasterLayer output = null; |
74 | 74 |
|
75 | 75 |
output = getNewRORasterLayer( |
76 |
RESULT,
|
|
77 |
Sextante.getText("tasseledcap_description"),
|
|
78 |
input.getDataType(),
|
|
76 |
RESULT, |
|
77 |
Sextante.getText("tasseledcap_description"), |
|
78 |
input.getDataType(), |
|
79 | 79 |
input.getBandsCount()); |
80 | 80 |
|
81 |
String fileName = ((FLyrRasterIRasterLayer)output).getFileName(); //getOutPutFile(RESULT);
|
|
81 |
String fileName = ((FLyrRasterIRasterLayer)output).getName();
|
|
82 | 82 |
|
83 | 83 |
try { |
84 | 84 |
setProgressText(getTranslation("calculating")); |
... | ... | |
89 | 89 |
Sextante.addErrorToLog(e); |
90 | 90 |
} catch (ProcessException e) { |
91 | 91 |
Sextante.addErrorToLog(e); |
92 |
}
|
|
92 |
} |
|
93 | 93 |
|
94 | 94 |
if(getTaskMonitor().isCanceled()) |
95 | 95 |
return false; |
96 | 96 |
|
97 | 97 |
return true; |
98 | 98 |
} |
99 |
|
|
99 |
|
|
100 | 100 |
private DataProcess createTasseledCapProcess(RasterDataStore inputStore, String fileName, int type) throws ProcessException { |
101 | 101 |
DataProcess taskPC = RasterBaseAlgorithmLibrary.getManager().createRasterTask(TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
102 | 102 |
taskPC.setActions(this); |
... | ... | |
107 | 107 |
if(paramType == RasterDataStore.class) { |
108 | 108 |
taskPC.addParam(paramName, (RasterDataStore)inputStore); |
109 | 109 |
} |
110 |
|
|
110 |
|
|
111 | 111 |
if(paramType == Boolean[].class) { |
112 | 112 |
boolean[] bands = new boolean[type == 0 ? 4 : 6]; |
113 | 113 |
for (int j = 0; j < bands.length; j++) { |
... | ... | |
115 | 115 |
} |
116 | 116 |
taskPC.addParam(paramName, bands); |
117 | 117 |
} |
118 |
|
|
118 |
|
|
119 | 119 |
if(paramType == Integer.class) { |
120 | 120 |
taskPC.addParam(paramName, type); |
121 | 121 |
} |
122 |
|
|
122 |
|
|
123 | 123 |
if(paramName.equals("PATH")) { |
124 | 124 |
taskPC.addParam(paramName, fileName); |
125 | 125 |
} |
126 |
|
|
126 |
|
|
127 | 127 |
if(paramName.equals("ROI_EPSG") && useROI) { |
128 | 128 |
taskPC.addParam(paramName, "EPSG:4326"); |
129 | 129 |
} |
130 |
|
|
130 |
|
|
131 | 131 |
if(paramName.equals("WINDOW")) { |
132 | 132 |
AnalysisExtent ext = getAnalysisExtent(); |
133 | 133 |
Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent( |
134 | 134 |
ext.getXMin(), ext.getYMax(), ext.getXMax(), ext.getYMin()); |
135 | 135 |
Extent inputBbox = inputStore.getExtent(); |
136 |
if(bbox.getULX() != inputBbox.getULX() ||
|
|
137 |
bbox.getULY() != inputBbox.getULY() ||
|
|
138 |
bbox.getLRX() != inputBbox.getLRX() ||
|
|
136 |
if(bbox.getULX() != inputBbox.getULX() || |
|
137 |
bbox.getULY() != inputBbox.getULY() || |
|
138 |
bbox.getLRX() != inputBbox.getLRX() || |
|
139 | 139 |
bbox.getLRY() != inputBbox.getLRY()) { |
140 | 140 |
taskPC.addParam(paramName, bbox); |
141 | 141 |
} |
... | ... | |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
public void interrupted() { |
148 |
|
|
148 |
|
|
149 | 149 |
} |
150 | 150 |
|
151 | 151 |
public void end(Object param) { |
152 |
|
|
152 |
|
|
153 | 153 |
} |
154 | 154 |
|
155 | 155 |
public void updateProgress(int current, int total) { |
156 | 156 |
boolean cancelled = setProgress(current, total); |
157 |
|
|
157 |
|
|
158 | 158 |
if(!cancelled) { |
159 | 159 |
if(taskStats != null) |
160 | 160 |
taskStats.actionCanceled(null); |
... | ... | |
162 | 162 |
taskPC.actionCanceled(null); |
163 | 163 |
} |
164 | 164 |
} |
165 |
|
|
165 |
|
|
166 | 166 |
/* |
167 | 167 |
* TODO: Customized panels |
168 | 168 |
@Override |
Also available in: Unified diff