<p style="margin-top:10px;margin-left:30px">Hi,</p><div><br></div><div>I'm trying to develop a web service for gdaltransform utility that gets four coordinates as input and write it in an input file. Then the gdaltransform utility is executed as in commandline to produce the output in the output file. I have the RPC file in the same path. The problem is the gdaltransform is not getting executed while I run the web service. But the same command works in normal commandline mode. Please help to resolve this problem. Thanks.</div>
<div><br></div><div><b>Code:</b></div><div><b>--------</b></div><div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
package org.gdaltrans;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
import java.io.*;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">import javax.jws.WebMethod;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
import javax.jws.WebParam;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">import javax.jws.WebService;</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">import org.apache.tools.ant.Project;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
import org.apache.tools.ant.taskdefs.ExecTask;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">import org.apache.tools.ant.types.Commandline;</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
/**</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> *</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
* <at> author dineshdass</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> */</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<at> WebService(serviceName = "gdaltransws")</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
public class gdaltransws {</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
/**</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> * This is a sample web service operation</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> */</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<at> WebMethod(operationName = "gdaltrans")</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
public void gdaltrans( <at> WebParam(name = "name") String llx,String lly,String urx,String ury) throws IOException {</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> String inputFilePath = "/home/dineshdass/Desktop/testdata/raw.tif";</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
// Creating the input and output text files containing user AOI to be given as arguments to gdaltransform</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
String inputAoiPath = "/home/dineshdass/Desktop/testdata/" + "inputAOI." + "txt";</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
String outputAoiPath = "/home/dineshdass/Desktop/testdata/" + "outputAOI." + "txt";</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
File inputAoi = new File(inputAoiPath);</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> File outputAoi = new File(outputAoiPath);</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> inputAoi.createNewFile();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
//outputAoi.createNewFile();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> Writer aoiWrite = new BufferedWriter(new FileWriter(inputAoi));</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> try {</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<span class="Apple-tab-span"></span>//aoiWrite.write(bbox.getMinX() + " " + bbox.getMinY() + "\n" + bbox.getMaxX() + " " + bbox.getMaxY());</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
aoiWrite.write(llx + " " + lly + "\n" + urx + " " + ury);</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
aoiWrite.close();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> } catch (IOException e) {</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> <span class="Apple-tab-span"></span>throw e;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
}</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> </div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
// Building gdaltransform command with arguments</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> String argument = " -i -rpc -to \"Method=RPC\" " + inputFilePath + " < " + inputAoiPath + " > " + outputAoiPath;</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> String arguments[] = new String[1];</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
arguments[0] = argument;</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> String gdalCommand = "gdaltransform" + argument;</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
// Execute gdaltransform command and the resulting AOI in pixel/line is stored in outputAoi</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
Project project = new Project();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> project.init();</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
ExecTask execTask = new ExecTask();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> execTask.setProject(project);</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> Commandline command = new Commandline(gdalCommand);</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> execTask.setCommand(command);</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
execTask.execute();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> File f=new File("/home/dineshdass/Desktop/testdata/op.txt");</div>
<div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"> execTask.setOutput(f);</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
execTask.execute();</div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
}<span class="Apple-tab-span"></span></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<b>inputAOI.txt </b></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><b>-----------------</b></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<div>180 -30</div><div>-40 -60</div></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
<b>op.txt (error shown)</b></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)"><b>---------</b></div><div style="color:rgb(34,34,34);font-family:palatino,georgia,verdana,arial,sans-serif;line-height:19px;text-align:justify;background-color:rgb(255,255,255)">
gdaltransform: error while loading shared libraries: libgdal1.7.0.so.1: cannot open shared object file: No such file or directory<br></div><br class="Apple-interchange-newline"></div><div><br></div>-- <br>Regards,<br>S.Dinesh Dass, <br>
M.Tech - Remote Sensing,<div>Institute of Remote Sensing,</div><div>Anna University,</div><div>Chennai.</div><div>Mob: +91-9976033932</div><br>