[gdal-dev] gdaltransform utility not working in web service

Dinesh Dass Subramanian sdineshdass at gmail.com
Mon Mar 19 10:44:03 EDT 2012


Hi,

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.

*Code:*
*--------*
package org.gdaltrans;

import java.io.*;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.ExecTask;
import org.apache.tools.ant.types.Commandline;

/**
 *
 * <at> author dineshdass
 */
<at> WebService(serviceName = "gdaltransws")
public class gdaltransws {

    /**
     * This is a sample web service operation
     */
    <at> WebMethod(operationName = "gdaltrans")
    public void gdaltrans( <at> WebParam(name = "name") String llx,String
lly,String urx,String ury) throws IOException {

        String inputFilePath = "/home/dineshdass/Desktop/testdata/raw.tif";

// Creating the input and output text files containing user AOI to be given
as arguments to gdaltransform
        String inputAoiPath = "/home/dineshdass/Desktop/testdata/" +
"inputAOI." + "txt";
        String outputAoiPath = "/home/dineshdass/Desktop/testdata/" +
"outputAOI." + "txt";
        File inputAoi = new File(inputAoiPath);
        File outputAoi = new File(outputAoiPath);
        inputAoi.createNewFile();
        //outputAoi.createNewFile();
        Writer aoiWrite = new BufferedWriter(new FileWriter(inputAoi));
        try {
        //aoiWrite.write(bbox.getMinX() + " " + bbox.getMinY() + "\n" +
bbox.getMaxX() + " " + bbox.getMaxY());
            aoiWrite.write(llx + " " + lly + "\n" + urx + " " + ury);
            aoiWrite.close();
        } catch (IOException e) {
        throw e;
        }

// Building gdaltransform command with arguments
        String argument = " -i -rpc -to \"Method=RPC\" " + inputFilePath +
" < " + inputAoiPath + " > " + outputAoiPath;
        String arguments[] = new String[1];
        arguments[0] = argument;
        String gdalCommand = "gdaltransform" + argument;

// Execute gdaltransform command and the resulting AOI in pixel/line is
stored in outputAoi
        Project project = new Project();
        project.init();

        ExecTask execTask = new ExecTask();
        execTask.setProject(project);
        Commandline command = new Commandline(gdalCommand);
        execTask.setCommand(command);
        execTask.execute();
        File f=new File("/home/dineshdass/Desktop/testdata/op.txt");
        execTask.setOutput(f);
        execTask.execute();

    }

*inputAOI.txt *
*-----------------*
180 -30
-40 -60

*op.txt (error shown)*
*---------*
gdaltransform: error while loading shared libraries: libgdal1.7.0.so.1:
cannot open shared object file: No such file or directory


-- 
Regards,
S.Dinesh Dass,
M.Tech - Remote Sensing,
Institute of Remote Sensing,
Anna University,
Chennai.
Mob: +91-9976033932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120319/e3647d0d/attachment-0001.html


More information about the gdal-dev mailing list