Skip to content

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

Open

Description

@houzw

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!

Activity

  1. bpross-52n commented on Jan 4, 2021

    @bpross-52n
    Member

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

  2. self-assigned this
    on Jan 4, 2021
  3. sumit851 commented on Mar 11, 2023

    @sumit851

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions