V1_0.java [src/java/m/watershed/dist2stream] 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.dist2stream;
import csip.ModelDataService;
import javax.ws.rs.Path;
import csip.annotations.*;
import java.io.*;
import csip.api.server.Executable;
import csip.annotations.Resource;
import static csip.annotations.ResourceType.*;
/**
* distance to stream
*
* @author JK (using OD's template)
*/
@Name("dist2stream")
@Description("Example of distance to stream")
@Path("m/dist2stream/1.0")
//@Resource(file = "mpirun", type = REFERENCE, id = "mpirun")
@Resource(file = "/bin/lin-amd64/d8hdisttostrm", type = EXECUTABLE, id = "d8hdisttostrm")
public class V1_0 extends ModelDataService {
// 2) watershed
@Override
protected void doProcess() throws Exception {
String file1 = parameter().getString("flow_dir");
File file_obj_1 = attachments().getFile(file1);
String flow_8dir_path = file_obj_1.getPath();
String file2 = parameter().getString("src");
File file_obj_2 = attachments().getFile(file2);
String src_path = file_obj_2.getPath();
String wd = workspace().getDir().toString();
//Executable e = resources().getExe("mpirun");
//File e2 = resources().getFile("d8hdisttostrm");
Executable e = resources().getExe("d8hdisttostrm");
//e.addArguments("-np", "2", "-host", "localhost", e2.getAbsolutePath(), "-p", flow_8dir_path, "-src", src_path, "-dist", wd + "/tempdist.tif");
e.addArguments("-p", flow_8dir_path, "-src", src_path, "-dist", wd + "/tempdist.tif");
e.exec();
}
// 3) provide the result.
@Override
protected void postProcess() throws Exception {
File ws = workspace().getDir();
results().put(new File(ws, "tempdist.tif"), "distance");
}
}