Revision 1927
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/sextante_template/sources/ProjectTemplateSextanteAlgorithm.java | ||
---|---|---|
69 | 69 |
task.addParam(ProjectTemplateProcess.PATH, fileName); |
70 | 70 |
task.addParam(ProjectTemplateProcess.RASTER_STORE1, lyrRaster.getDataStore()); |
71 | 71 |
//TODO:Add parameters |
72 |
//task.addParam(ProjectTemplateProcess.EXPORT, true);
|
|
72 |
task.addParam(ProjectTemplateProcess.EXPORT, true); |
|
73 | 73 |
task.addParam(ProjectTemplateProcess.TEST_EXTENT, bbox); |
74 | 74 |
task.addParam(ProjectTemplateProcess.TEST_WIDTH, ext.getNX()); |
75 | 75 |
task.addParam(ProjectTemplateProcess.TEST_HEIGHT, ext.getNY()); |
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_with_preview_template/sources/algorithm/ProjectTemplateProcess.java | ||
---|---|---|
86 | 86 |
cellSize = testExtent.width() / w; |
87 | 87 |
} |
88 | 88 |
|
89 |
////////////////////////// |
|
90 |
//TODO:PROCESS!! |
|
91 |
|
|
92 | 89 |
RasterQuery query = RasterLocator.getManager().createQuery(); |
93 | 90 |
query.setAllDrawableBands(); |
94 | 91 |
query.setAreaOfInterest(testExtent, testWidth, testHeight); |
... | ... | |
102 | 99 |
throw new ProjectTemplateException(""); |
103 | 100 |
} |
104 | 101 |
bufferForTest = sourceBuffer; |
102 |
|
|
103 |
////////////////////////// |
|
104 |
//TODO:PROCESS!! |
|
105 |
|
|
105 | 106 |
//int inDataType = store.getDataType()[0]; |
106 | 107 |
//Buffer buf = RasterLocator.getManager().createBuffer( |
107 | 108 |
// inDataType, |
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/README.txt | ||
---|---|---|
2 | 2 |
----------------------- |
3 | 3 |
Version: 2.0.0 |
4 | 4 |
Author: Nacho Brodin (nachobrodin@gmail.com) |
5 |
gvSIG version needed 2.1.0 |
|
5 | 6 |
|
6 | 7 |
This folder contains Ant scripts to create projects for raster |
7 | 8 |
Now it is possible to build two types of projects |
... | ... | |
14 | 15 |
- A Swing library for the GUI (with API and implementation) |
15 | 16 |
- A library for the algorithm. This library lacks of API because the algorithms will be registered. |
16 | 17 |
- The plugin for gvSIG |
18 |
- Optionally, a library with the Sextante process |
|
17 | 19 |
|
18 | 20 |
Ant commands to build the structure |
19 | 21 |
|
20 | 22 |
Basic task: ant -Dproject="myprojectname" -Dtoken="MyProjectName" |
21 | 23 |
Task with preview: ant -Dproject="myprojectname" -Dtoken="MyProjectName" preview |
22 | 24 |
|
25 |
In both cases, if you need a library to build the Sextante process you can add the parameter -Dsextantelib=true |
|
26 |
|
|
27 |
Basic task: ant -Dproject="myprojectname" -Dtoken="MyProjectName" -Dsextantelib=true |
|
28 |
Task with preview: ant -Dproject="myprojectname" -Dtoken="MyProjectName" -Dsextantelib=true preview |
|
29 |
|
|
23 | 30 |
After execute the command, inside the current directory will be created a maven project named org.gvsig.raster.<myprojectname> compiled and ready to be imported in Eclipse. The rest of work is in your hands. |
24 | 31 |
|
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/sources/algorithm/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