GPMultiValue and GPRasterDataLayer

5510
5
Jump to solution
12-12-2014 03:11 AM
AdamNicinski
New Contributor

Dear All,

   I would like to ask you how I can pass a valid GPMultiValue with GPRasterDataLayer inside to the Local GP Service in ArcGIS Runtime 10.2.4.

My REST parameters are below:

mosaic1.png

When I run my sample app, geoprocessing service starts. After I submit my jobs, it fails. There is nothing I can read from the job info. The job output is below.

mosaic2.png

Below you find my Java code for defining input parameters.

List<GPParameter> parameters = new ArrayList<>();
  inputRasters = new GPMultiValue<GPParameter>("input_rasters");

  GPLong bands = new GPLong("nmb_bands");
  bands.setValue(3);


  GPRasterDataLayer ras1 = new GPRasterDataLayer();
  ras1.setRasterDataUrl("http://127.0.0.1/zdjecia/lot1.tif");
  ras1.setFormat("tif");

  GPRasterDataLayer ras2 = new GPRasterDataLayer();
  ras2.setRasterDataUrl("http://127.0.0.1/zdjecia/lot2.tif");
  ras2.setFormat("tif");

  GPRasterDataLayer ras3 = new GPRasterDataLayer();
  ras3.setRasterDataUrl("http://127.0.0.1/zdjecia/lot3.tif");
  ras3.setFormat("tif");

  GPRasterDataLayer ras4 = new GPRasterDataLayer();
  ras4.setRasterDataUrl("http://127.0.0.1/zdjecia/lot4.tif");
  ras4.setFormat("tif");


  inputRasters.addValue(bands);
  inputRasters.addValue(ras1);
  inputRasters.addValue(ras2);
  inputRasters.addValue(ras3);
  inputRasters.addValue(ras4);

  parameters.add(inputRasters);

  parameters.add(bands);

  String gpUrl = MosiacService.getUrlGeoprocessingService() + "/MosaicToRaster";
  MosaicGP = new Geoprocessor(gpUrl);



MosaicGP.submitJobAndGetResultsAsync(parameters, null,new String[]{"mosaic_out"}, new GPCallback());




According to the documentation, if GPRasterDataLayer is an input, I should pass a JSON like this:

 {
 "paramName" : "<paramName>",
 "dataType" : "<GPRasterDataLayer | GPFeatureRecordSetLayer>",
 "value" : 
  { 
  "mapImage" : 
  {
  "href" : "<href>",
  "width" : <width>,
  "height" : <height>,
  "extent" : {<envelope>},
  "scale" : <scale>
   } 
  }
 }

But there are only methods to add URL and Format to GPRasterDataLayer.  BTW, adding input rasters using URL is not a convenient way for me. Is it a way to add rasters using local paths? As far as I know the uploads are not currently supported by ArcGIS Runtime GP, so there is no option to pass itemId as an input.

Best Regards,

Adam

0 Kudos
1 Solution

Accepted Solutions
EricBader
Occasional Contributor III

Was you GP model successful in Desktop? I assume it was, for you to be able to create a gpk, yes?

View solution in original post

0 Kudos
5 Replies
EricBader
Occasional Contributor III

Was you GP model successful in Desktop? I assume it was, for you to be able to create a gpk, yes?

0 Kudos
AdamNicinski
New Contributor

Hi Eric,

   I created a model, composed of Mosaic to New Raster tool, which is supported by ArcGIS Runtime, in ArcGIS for Desktop. I have ran it successfully - the new mosaic was created. During the published of the resulting gpk, I chose the type of input_rasters as an user-defined value, not a default choice list. When I try to give my own input rasters, as described above, the gp service returns odd messages. Could you send me a link to any ArcGIS Runtime for Java sample application that uses GPMulitvalue with GPRasterDataLayer parameter? I can not find anything on the Internet.

Best regards,

Adam

0 Kudos
nita14
by
Occasional Contributor III

Hi All,

It seems that I found the issue. Unfortunately, It must be a bug in Runtime 10.2.4. After having enabled logging in LocalServer Utility, It turned out that ArcGIS Runtime sent a wrong-encoded request to the REST endpoint. There are many extra  " and \ signs, which make the request invalid.

Here is the wrong request made by Runtime:

submitJob?input_rasters=["{\"format\":\"tif\",\"url\":\"http://localhost/lot1.tif\"}","{\"format\":\"tif\",\"url\":\"http://localhost/lot2.tif\"}","{\"format\":\"tif\",\"url\":\"http://localhost/lot3.tif\"}","{\"format\":\"tif\",\"url\":\"http://localhost/lot4.tif\"}"]&returnZ=false&returnM=false&f=json

|The good request is below (tested in REST API endpoint):

submitJob?input_rasters=[{ "url" : "http://localhost/lot1.tif", "format" : "tif" },{ "url" : "http://localhost/lot2.tif", "format" : "tif" },{ "url" : "http://localhost/lot3.tif", "format" : "tif" }]&returnZ=false&returnM=false&f=json

Moreover, I would like to point out a few things:

1) Rest API, apparently, supports local path to the GPRasterDataLayer parameter in the following format

{ "url" : "C:/Tools/ChangeDetection/zm1wgs.tif", "format" : "tif" }.

However, ArcGIS Runtime SDK 10.2.4 does NOT. When using "file:///" prefix, Runtime creates this json:

{ "url" : "file:/C:/Tools/ChangeDetection/zm1wgs.tif", "format" : "tif" } 

which is in fact incorrect path.

2) "Mosaic To New Raster' tool is not supported when creating GPK from ArcGIS Desktop 10.3.1 (with MPK patch installed). Runtime shows the error: ERROR 000816: The tool is not valid. This must be a bug as well. When creating the same GPK from ArcGIS 10.2.2, the tool works as expected.

3) The input GPRasterDataLayer geoprocessing parameters can be defined as below. It works just fine

GPRasterDataLayer rasterAfter = new GPRasterDataLayer("rasterAfter");  
rasterAfter.setRasterDataUrl("http://localhost/zm1wgs.tif");  
rasterAfter.setFormat("tif");

I hope, you find these comments useful,

Regards,

Adam

Użyj zaawansowanego edytora

EricBader
Occasional Contributor III

Hi Adam,

Thank you for these clues. Give us a chance to investigate and we'll see what's up. I assume you do not have access to Esri's Technical Support? If you do, by chance, no harm in logging this officially.

Thanks again.

0 Kudos
nita14
by
Occasional Contributor III

Hi Eric,

I don't have access to Esri's Technical Support as I am an EDN user only. As I suppose, there won't be any new release of ArcGIS Runtime, so I look forward to see the bug fixes in the Quartz final release. The sooner is the better!

Thanks,

Adam