javaPS icon indicating copy to clipboard operation
javaPS copied to clipboard

How to publish & call a command line utility as WPS using JavaPS?

Open houzw opened this issue 5 years ago • 2 comments

I have several algorithms that run as commandline utilities. I have to publish them as WPS processes. Some of these processes need geotiff files as input.

I hava tried to use the GenericFileDataWithGTBinding and GenericFileDataWithGT to get the geotiff file at the server side

 private GenericFileDataWithGT tiff;

 @ComplexInput(identifier = "tiff", minOccurs = 1, maxOccurs = 1, binding = GenericFileDataWithGTBinding.class)
 public void setTiff(GenericFileDataWithGT tiff) {
     this.tiff = tiff;
 }
 @Execute
 public void run() {
    String path = tiff.getBaseFile(true).getAbsolutePath();
    log.debug(tiff.getMimeType());
    log.debug(path);
   // return a GridCoverage2D object, error: the file is invalid. 
    this.result = GeoTiffUtils.read(path); 
 }

I hava tested the following codes using wps-client-lib, but the file received at the server side is invalid, it is larger than the original file and cannot read by gdal. Besides, the received file is end with ..tmp, not .tmp or .tif

ExecuteRequestBuilder builder = new ExecuteRequestBuilder(describeProcessDocument);
File file = new File("J:/demos/zts.tif");
//FileInputStream is = new FileInputStream(file);
byte[] bytes = FileUtils.readFileToByteArray(file);
String s = Base64.encodeBytes(bytes);
//also tested using FileInputStream directly, got the same error
builder.addComplexData("dem", s, null, "base64", "image/tiff");

I'm not sure it's the client side error or server side error. The exception at the server side shown that it was caused by the invalid file.

Thanks very much!


I have tested the similar code (use GenericFileDataWithGTBinding and GenericFileDataWithGT to get the geotiff) using https://github.com/52North/WPS version 3.6.3, and I got the valid file!

houzw avatar Dec 24 '20 02:12 houzw

It seems that the base64 encoded input is not decoded properly. I will investigate this.

bpross-52n avatar Jan 04 '21 11:01 bpross-52n

i am interested in this issue, i have basic knowledge on java . i want to contribute to this project with little guidence plz assign me

sumit851 avatar Mar 11 '23 17:03 sumit851