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

View differences:

ProjectTemplateProcess.java
30 30
	public static String      FILENAME          = "FileName";
31 31
	public static String      EXPORT            = "Export";
32 32
	
33
	public static String      TEST              = "Test";
33 34
	public static String      TEST_EXTENT       = "TestExtent";
34 35
	public static String      TEST_WIDTH        = "TestWidth";
35 36
	public static String      TEST_HEIGHT       = "TestHeight";
36 37
	
38
	private boolean           test              = false;
37 39
	private RasterDataStore   store             = null;
38 40
	private String            filename          = null;
39 41
	private boolean           export            = true;
......
49 51
		registerInputParameter(PATH, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
50 52
		registerOutputParameter(FILENAME, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
51 53
		registerInputParameter(EXPORT, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
54
		registerInputParameter(TEST, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
52 55
		registerInputParameter(TEST_EXTENT, Extent.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
53 56
		registerInputParameter(TEST_WIDTH, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
54 57
		registerInputParameter(TEST_HEIGHT, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
......
59 62
		filename = getStringParam(PATH);
60 63
		export = getBooleanParam(EXPORT);
61 64
		
65
		test = getBooleanParam(TEST);
62 66
		testExtent = getParam(TEST_EXTENT) != null ? (Extent)getParam(TEST_EXTENT) : null;
63 67
		testWidth = getIntParam(TEST_WIDTH);
64 68
		testHeight = getIntParam(TEST_HEIGHT);
......
93 97
			int h = (int)store.getHeight();
94 98
			cellSize = store.getCellSize();
95 99
			
96
			if(testExtent != null) {
97
				windowExtent = testExtent;
98
				w = testWidth;
99
				h = testHeight;
100
				cellSize = testExtent.width() / w;
101
			}
102
			
103 100
			int inDataType = store.getDataType()[0];
104 101
			Buffer buf = RasterLocator.getManager().createBuffer(
105 102
					inDataType, 
......
109 106
					true);
110 107
			
111 108
			RasterQuery query = RasterLocator.getManager().createQuery();
112
			query.setAllDrawableBands();
109
			
110
			if(extent != null) {
111
				windowExtent = extent;
112
				w = outputWidth;
113
				h = outputHeight;
114
				cellSize = windowExtent.width() / w;
115
				query.setSupersamplingOption(true);
116
			} else {
117
				query.setSupersamplingOption(false);
118
			}
119

  
120
			if(test) {
121
				query.setReadOnly(false);
122
				query.forceRGBRequest();
123
				query.setDrawableBands(store.getRender().getRenderColorInterpretation().buildRenderBands());
124
			} else {
125
				query.setAllDrawableBands();
126
				query.setReadOnly(true);
127
			}
128
			
113 129
			query.setAreaOfInterest();
114 130
			Buffer sourceBuffer = null;
115 131
			try {
116 132
				sourceBuffer = store.query(query);
117
			} catch (RasterDriverException e) {
133
				sourceBuffer.setDataExtent(windowExtent.toRectangle2D());
134
			} catch (org.gvsig.fmap.dal.coverage.exception.QueryException e) {
118 135
				throw new ProjectTemplateException("");
119
			} catch (InvalidSetViewException e) {
120
				throw new ProjectTemplateException("");
121
			}
136
			} 
122 137
			
123 138
			
124 139
			//////////////////////////

Also available in: Unified diff