Revision 2127 org.gvsig.raster.principalcomponents/trunk/org.gvsig.raster.principalcomponents/org.gvsig.raster.principalcomponents.algorithm/src/main/java/org/gvsig/raster/principalcomponents/algorithm/PCAStatisticsProcess.java

View differences:

PCAStatisticsProcess.java
32 32
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
33 33
import org.gvsig.fmap.dal.coverage.exception.CloneException;
34 34
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
35
import org.gvsig.fmap.dal.coverage.exception.ROIException;
35 36
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
36 37
import org.gvsig.fmap.dal.exception.CloseException;
37 38
import org.gvsig.raster.algorithm.process.DataProcess;
......
55 56
    public static final String 	 LAYER_ZONA_ESTUDIO 			= "LAYER_ZONA_ESTUDIO";
56 57
    public static String         BANDS 							= "BANDS";
57 58
    public static String         PATH 							= "PATH";
58
    public static String         ROI 							= "ROI";
59
    public static String         ROI_EPSG                       = "ROI_EPSG";
60
    public static String         WINDOW                         = "WINDOW";
59 61
    
60 62
	public static String         RASTER_STORE                   = "RASTER_STORE";
61 63
	public static String         STATS_RESULT                   = "STATS_RESULT";
......
69 71
	private double 				 coVar[][] 						= null;
70 72
	private static Logger 		 logger    		   				= LoggerFactory.getLogger(PCAStatisticsProcess.class.getName());
71 73
    private double[][] 			 maxminmean						= null;
74
    private	Extent 				 inputWindow					= null;
72 75
    private	Extent 				 extentResult					= null; 
73 76
    private String               path                           = null;
77
    private String               roiEPSG                        = null;
74 78
    private List<ROI>            rois                           = null;
75 79
    
76 80
    private boolean[]            statsByBandCalculated          = null;
......
79 83
		registerInputParameter(RASTER_STORE, RasterDataStore.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
80 84
		registerInputParameter(BANDS, Boolean[].class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
81 85
		registerInputParameter(PATH, String.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
82
		registerInputParameter(ROI, List.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
86
		registerInputParameter(ROI_EPSG, String.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
87
		registerInputParameter(WINDOW, Extent.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
83 88
		
84 89
		registerOutputParameter(STATS_RESULT, PCStatsDataStructure.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
85 90
		registerOutputParameter(PATH, String.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
86 91
		registerOutputParameter(BANDS, Boolean[].class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
87
		registerOutputParameter(ROI, List.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
92
		registerOutputParameter(ROI_EPSG, String.class, PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL);
88 93
	}
89 94
	
90
	@SuppressWarnings("unchecked")
91 95
	@Override
92 96
	public void init() {
93 97
		store = (RasterDataStore)getParam(RASTER_STORE);
94 98
		bands = (boolean[])getParam(BANDS);
95 99
		path = getStringParam(PATH);
96
		rois = getParam(ROI) != null ? (List<ROI>)getParam(ROI) : null;
100
		roiEPSG = getStringParam(ROI_EPSG);
101
		inputWindow = getParam(WINDOW) != null ? (Extent)getParam(WINDOW) : null;
97 102
	}
98 103
	
99 104
	public double[] getAutoValors() {
......
164 169
							dSum += valorBandai * valorBandaj;
165 170
							iValues++;
166 171
						}
167
						updatePercent((percent * 100) / maxCounter, 100);
168 172
					}
173
					updatePercent((percent * 100) / maxCounter, 100);
169 174
				}
170 175
				// Asigno el valor a la matriz 
171 176
				if (iValues > 1)
......
260 265
	public void process() throws ProcessInterruptedException, ProcessException {
261 266
		insertLineLog(Messages.getText("preparing_buffers"));
262 267

  
268
		if(roiEPSG != null) {
269
			try {
270
				rois = store.getRois(roiEPSG);
271
			} catch (ROIException e2) {
272
				logger.error(Messages.getText("error_getting_rois"), e2);
273
			}
274
		}
275
			
263 276
		try {
264 277
			store = store.cloneDataStore();
265 278
		} catch (CloneException e1) {
266 279
			throw new ProcessException("Error cloning the sources", e1);
267 280
		}
268

  
281
			
269 282
		//Calculo de datos de entrada
270
		extentResult = getExtentResult(rois, store);
283
		extentResult = getExtentResult(inputWindow, rois, store);
271 284
		Rectangle2D sourcePxBBox = getSourcePxBox(extentResult, store);
272 285

  
273 286
		buffer = createSourceBuffer(store, sourcePxBBox, bands);
......
295 308
		addOutputValue(STATS_RESULT, resultStatistics);
296 309
		addOutputValue(PATH, path);
297 310
		addOutputValue(BANDS, bands);
298
		addOutputValue(ROI, rois);
311
		addOutputValue(ROI_EPSG, roiEPSG);
299 312
		try {
300 313
			store.close();
301 314
		} catch (CloseException e) {

Also available in: Unified diff