Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
houzw opened this issue Dec 24, 2020 · 2 comments
Open

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

houzw opened this issue Dec 24, 2020 · 2 comments
Assignees

Comments

@houzw
Copy link

houzw commented Dec 24, 2020

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!

@bpross-52n
Copy link
Member

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

@bpross-52n bpross-52n self-assigned this Jan 4, 2021
@sumit851
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants