Select to view content in your preferred language

Export image of GP tool layer does not work

3259
2
05-24-2012 06:59 AM
StefanOffermann
Deactivated User
I have a custom geoprocessing tool implemented in C#. The output is a GPRasterDataLayer. The tool is added as a tool layer to a blank ArcMap document. I have populated all parameters, set the scratch workspace to a folder and I have run the tool once. The output layer is added to the map as a sublayer to the tool layer as expected. The map is saved as mxd document and published to arcgis server, with MapServer and GeoprocessingServer capabilites enabled. Both services are created, the map server is the result service for the GP service.

I can execute the task sucessfully via REST interface of arcgis server. The problem is that the result only contains the URL to the gerenated tif file (parameter "out_result" of type GPRasterDataLayer), but the image can not be exported as a map image to be included in a javascript client.

http://some.server.com/ArcGIS/rest/services/MovingWindowFunction/GPServer/Moving%20Window%20Function/jobs/jcb8dd75cc1e341ac94f03c59e298b97b/results/out_result?f=pjson


=>

{
  "paramName" : "out_result",
  "dataType" : "GPRasterDataLayer",
  "value" : {
    "url" : "http://server/arcgisjobs/movingwindowfunction_gpserver/jcb8dd75cc1e341ac94f03c59e298b97b/scratch/Moving Window.tif",
    "format" : "tif"
  }
}


When using a map service as result service, this should not be the case regarding the documentation at:
http://services.arcgisonline.com/ArcGIS/SDK/REST/gpresult.html#mapimage

Map Images as Results
Map images can be a result of a GP job. If a GP service is associated with a result map service, the results of GPFeatureRecordSetLayer and GPRasterDataLayer data types can be drawn by the result map service and hence can be provided to the client as a map image.
In such cases where the result is a map image, the value field for the GP parameter is a JSON structure with a mapImage field.

So the value should be a "mapImage", but instead it is "url" and "format". I think this is a bug.

My next try is to export the image of the result using the export parameter of the GP service with the following URL:

http://some.server.com/ArcGIS/rest/services/MovingWindowFunction/GPServer/Moving%20Window%20Function/jobs/j0684e2ad3c65427a9b469f74d0d824f6/results/out_result/export?dpi=96&transparent=true&format=png8&LANGUAGE=ger&bbox=-8192582.035679961,3318059.019542513,10592582.03567996,9481940.980457487&bboxSR=102100&imageSR=102100&size=1920,630&f=image


...which results in an error:
Error
Specified format is not supported
Code: 400
Invalid URL

Nothing helpful can be found in ArcGIS Server and REST log 😞

What can I do to get the map image from the associated map service of the GP service?

Best regards, Stefan
0 Kudos
2 Replies
StefanOffermann
Deactivated User
I think I have solved my problem:

The name of the result sub layer of the tool layer must have the same name as the output parameter of the GP tool (in my case: "out_result").

If this is done, then I get the correct output:
{
  "paramName" : "out_result", 
  "dataType" : "GPRasterDataLayer", 
  "value" : {
    "mapImage" : {
      "href" : "http://server/arcgisoutput/_ags_map4a0e89d03bf04fad94febbf29e553660.png", 
      "width" : 400, 
      "height" : 400, 
      "extent" : {
        "xmin" : -198, 
        "ymin" : -188.48, 
        "xmax" : 198, 
        "ymax" : 207.52, 
        "spatialReference" : {
          "wkid" : 4326
        }
      }, 
      "scale" : 416060611.02672
    }
  }
}
0 Kudos
StefanOffermann
Deactivated User
The problem still exists 😞

Everything works fine on the server side: The tool is running, the output raster image is created in the jobs directory and now even the image is written in the output directory:

URL:
http://server/ArcGIS/rest/services/MovingWindowFunction/GPServer/Moving%20Window%20Function/jobs/j39af1a9452014046b5eff75461283d0a/results/out_result?f=pjson

Output:
{
  "paramName" : "out_result", 
  "dataType" : "GPRasterDataLayer", 
  "value" : {
    "mapImage" : {
      "href" : "http://server/arcgisoutput/_ags_map4a0b366dc2a6406c8e01f5dabbd537b6.png", 
      "width" : 400, 
      "height" : 400, 
      "extent" : {
        "xmin" : -7.23306324850746, 
        "ymin" : 43.5062588282437, 
        "xmax" : 5.26322179315017, 
        "ymax" : 56.0025438699013, 
        "spatialReference" : {
          "wkid" : 4326
        }
      }, 
      "scale" : 13129323.207061
    }
  }
}


When I try to call the gp service from my javascript client, I use this code:

this.gpTask.getResultImageLayer(jobInfo.jobId, "out_result", imageParams, dojo.hitch(this,function(gpLayer){ ...


This does not work, as I can see in the javascript console of chrome, the following URL is generated to export the image from the gp service:

http://server/ArcGIS/rest/services/MovingWindowFunction/GPServer/Moving%20Window%20Function/jobs/j39af1a9452014046b5eff75461283d0a/results/out_result/export?dpi=96&transparent=true&format=png8&bbox=31124.96346345375,6358724.004726038,618161.340693325,6471850.806588045&bboxSR=102100&imageSR=102100&size=1920,370&f=image


which results in an error (web site of the rest endpoint):
Specified format is not supported
Code: 400
Invalid URL


If I change the URL from "f=image" to "f=pjson", I an see a similar error message:
http://server/ArcGIS/rest/services/MovingWindowFunction/GPServer/Moving%20Window%20Function/jobs/j39af1a9452014046b5eff75461283d0a/results/out_result/export?dpi=96&transparent=true&format=png8&bbox=31124.96346345375,6358724.004726038,618161.340693325,6471850.806588045&bboxSR=102100&imageSR=102100&size=1920,370&f=pjson

{
  "error" :
  {
    "code" : 400,
    "message" : "Unable to complete  operation.",
    "details" : [
      "Invalid URL"
    ]
  }
}


Why is it not possible to use the "export" map parameter of the gp service (with a result map service)?

Am I missing something?

Best regards, Stefan
0 Kudos