V1_0.java [src/java/m/watershed/flow_accumulate] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.watershed.flow_accumulate;
import csip.ModelDataService;
import javax.ws.rs.Path;
import csip.annotations.*;
import java.io.*;
import csip.annotations.Resource;
import static csip.annotations.ResourceType.*;
import csip.api.server.Executable;
/**
* Flow accumulate
*
* @author JK (using OD's template)
*/
@Name("flow_accumulate")
@Description("Example of eight direction flow accumulation")
@Path("m/flow_accumulate/1.0")
//@Resource(file = "mpirun", type = REFERENCE, id = "mpirun")
@Resource(file = "/bin/lin-amd64/aread8", type = EXECUTABLE, id = "aread8")
public class V1_0 extends ModelDataService {
// 2) watershed
@Override
protected void doProcess() throws Exception {
String file1 = parameter().getString("flow_8_dir");
File file_obj = attachments().getFile(file1);
String flow_8dir_path = file_obj.getPath();
String wd = workspace().getDir().toString();
//Executable e = resources().getExe("mpirun");
//File e2 = resources().getFile("aread8");
Executable e = resources().getExe("aread8");
//e.addArguments("-np", "2", "-host", "localhost", e2.getAbsolutePath(), "-p", flow_8dir_path, "-ad8", wd + "/ad8.tif", "-nc");
e.addArguments("-p", flow_8dir_path, "-ad8", wd + "/ad8.tif", "-nc");
e.exec();
}
// 3) provide the result.
@Override
protected void postProcess() throws Exception {
File ws = workspace().getDir();
results().put(new File(ws, "ad8.tif"), "flow accumulation");
}
}