Revision 1927 org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/sources/algorithm/ProjectTemplateProcess.java

View differences:

ProjectTemplateProcess.java
4 4

  
5 5
import javax.swing.SwingUtilities;
6 6

  
7
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
7 8
import org.gvsig.fmap.dal.coverage.RasterLocator;
8 9
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
9 10
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
......
23 24
	public static String      PATH              = "Path";
24 25
	public static String      FILENAME          = "FileName";
25 26
	public static String      TIME              = "Time";
27
	public static String      EXPORT            = "Export";
26 28
	
29
	public static String      TEST_EXTENT       = "TestExtent";
30
	public static String      TEST_WIDTH        = "TestWidth";
31
	public static String      TEST_HEIGHT       = "TestHeight";
32
	
27 33
	private RasterDataStore   store             = null;
28 34
	private String            filename          = null;
29 35
	private long              millis            = 0;
36
	private boolean           export            = true;
30 37
	
38
	private Extent            testExtent        = null;
39
	private int               testWidth         = 0;
40
	private int               testHeight        = 0;
41
	
31 42
	public static void registerParameters() {
32 43
		RASTER_STORE1 = RasterBaseAlgorithmLibrary.registerInputParameter(RASTER_STORE1, RasterDataStore.class);
33 44
		PATH = RasterBaseAlgorithmLibrary.registerInputParameter(PATH, String.class);
34 45
		FILENAME = RasterBaseAlgorithmLibrary.registerOutputParameter(FILENAME, String.class);
35 46
		TIME = RasterBaseAlgorithmLibrary.registerOutputParameter(TIME, Long.class);
47
		EXPORT = RasterBaseAlgorithmLibrary.registerInputParameter(EXPORT, Boolean.class);
48
		TEST_EXTENT = RasterBaseAlgorithmLibrary.registerInputParameter(TEST_EXTENT, Extent.class);
49
		TEST_WIDTH = RasterBaseAlgorithmLibrary.registerInputParameter(TEST_WIDTH, Integer.class);
50
		TEST_HEIGHT = RasterBaseAlgorithmLibrary.registerInputParameter(TEST_HEIGHT, Integer.class);
36 51
	}
37 52
	
38 53
	public void init() {
39 54
		store = getParam(RASTER_STORE1) != null ? (RasterDataStore)getParam(RASTER_STORE1) : null;
40 55
		filename = getStringParam(PATH);
56
		export = getBooleanParam(EXPORT);
57
		
58
		testExtent = getParam(TEST_EXTENT) != null ? (Extent)getParam(TEST_EXTENT) : null;
59
		testWidth = getIntParam(TEST_WIDTH);
60
		testHeight = getIntParam(TEST_HEIGHT);
41 61
	}
42 62

  
43 63
	public void process() throws ProcessInterruptedException {
......
47 67
			if (store == null)
48 68
				throw new ProjectTemplateException("...");
49 69
			
70
			Extent windowExtent = store.getExtent();
71
			int w = (int)store.getWidth();
72
			int h = (int)store.getHeight();
73
			double cellSize = store.getCellSize();
74
			
75
			if(testExtent != null) {
76
				windowExtent = testExtent;
77
				w = testWidth;
78
				h = testHeight;
79
				cellSize = testExtent.width() / w;
80
			}
81
			
50 82
			int inDataType = store.getDataType()[0];
51 83
			Buffer buf = RasterLocator.getManager().createBuffer(
52 84
					inDataType, 
......
67 99
				throw new ProjectTemplateException("");
68 100
			}
69 101
			
102
			
103
			//////////////////////////
104
			//TODO:PROCESS!!
105
			
70 106
			//updatePercent(row, buf.getHeight());
71 107
			
72
			//super.exportRaster(filename, buf, cellsize, ulx, uly);
108
			/*if(export) {
109
			super.exportRaster(filename, 
110
					buf, 
111
					cellSize, 
112
					windowExtent.getULX(), 
113
					windowExtent.getULY());
114
			}*/
73 115
			
74 116
			long t2 = new java.util.Date().getTime();
75 117
			millis = t2 - t1;

Also available in: Unified diff