Description
Represents a GP Task resource exposed by the ArcGIS Server REST API. A GP Task resource represents a single task in a GP service published using the ArcGIS Server and it supports one of the following operations:
- "execute" - performed on a GP Task resource when the execution type is synchronous.
- "submitJob" - performed on an asynchronous GP Task resource.
Class hierarchy
esri.tasks.Geoprocessor
Constructor
Properties
| outputSpatialReference |
SpatialReference
|
The spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the input geometries. If processSpatialReferencew is specified and outputSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. |
| processSpatialReference |
SpatialReference
|
The spatial reference that the model will use to perform geometry operations. If processSpatialReference is specified and outputSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. |
| updateDelay |
Number
|
The time interval in milliseconds between each job status request sent to an asynchronous GP task. |
| url |
String
|
ArcGIS Server Rest API endpoint to the resource that receives the geoprocessing request. |
Methods
| cancelJobStatusUpdates(jobId) |
none
|
Cancels the periodic job status updates initiated automatically when submitJob() is invoked for the job identified by jobId. You can still obtain the status of this job by calling the checkStatus() method at your own discretion. |
| checkJobStatus(jobId, callback?, errback?) |
none
|
Sends a request to the GP Task for the current state of the job identified by jobId. Upon receiving the response, the onStatusUpdate event is fired and the optional callback function is invoked. |
| execute(inputParameters, callback?, errback?) |
dojo.Deferred
|
Sends a request to the server to execute a synchronous GP task. On completion, the onExecuteComplete event is fired and the optional callback function is invoked. |
| getResultData(jobId, parameterName, callback?, errback?) |
dojo.Deferred
|
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName. On completion, the getresultdatacomplete event will be fired and the optional callback function will be invoked. |
| getResultImage(jobId, parameterName, imageParameters, callback?, errback?) |
dojo.Deferred
|
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName as an image. |
| getResultImageLayer(jobId, parameterName, imageParameters, callback?, errback?) |
none
|
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName as an ArcGISDynamicMapServiceLayer. |
| setOutputSpatialReference(spatialReference) |
none
|
Sets the the well-known ID of the spatial reference of the output geometries. |
| setProcessSpatialReference(spatialReference) |
none
|
Sets the well-known ID of the spatial reference that the model uses to perform geometry operations. |
| setUpdateDelay(delay) |
none
|
Sets the time interval in milliseconds between each job status request sent to an asynchronous GP task. |
| submitJob(inputParameters, callback?, statusCallback?, errback?) |
none
|
Submits a job to the server for asynchronous processing by the GP task. Once the job is submitted and until it is completed, the onStatusUpdate event is fired and the optional statusCallback() function is invoked at regular intervals, the duration of which is specified by the updateDelay property. Upon completion of the job, the onJobComplete event is fired and the optional callback function is invoked.
The task execution results can be retrieved using getResultData(), getResultImage() or getResultImageLayer() methods. |
Events
Constructor Detail
esri.tasks.Geoprocessor(url)
Creates a new Geoprocessor object that represents the GP Task identifed by a URL.
Parameters:
|
<String>
url |
Required |
URL to the ArcGIS Server REST resource that represents a geoprocessing service. An example is
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network. For more information on constructing a URL, see The Services Directory and the REST API.
|
Properties Detail
The spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the input geometries. If
processSpatialReferencew is specified and
outputSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference. See
Projected Coordinate Systems and
Geographic Coordinate Systems for the list of supported spatial references.
The spatial reference that the model will use to perform geometry operations. If
processSpatialReference is specified and
outputSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference. See
Projected Coordinate Systems and
Geographic Coordinate Systems for the list of supported spatial references.
The time interval in milliseconds between each job status request sent to an asynchronous GP task.
Default value: 1000
ArcGIS Server Rest API endpoint to the resource that receives the geoprocessing request.
Methods Detail
cancelJobStatusUpdates(jobId)
Cancels the periodic job status updates initiated automatically when submitJob() is invoked for the job identified by jobId. You can still obtain the status of this job by calling the checkStatus() method at your own discretion. (As of v1.1)
Return value: none
Input Parameters:
|
<String> jobId |
Required |
A string that uniquely identifies the job for which the job updates are cancelled. |
checkJobStatus(jobId, callback?, errback?)
Sends a request to the GP Task for the current state of the job identified by jobId. Upon receiving the response, the onStatusUpdate event is fired and the optional callback function is invoked.
Return value: none
Input Parameters:
|
<String> jobId |
Required |
A string that uniquely identifies a job on the server. It is created when a job is submitted for execution and later used to check its status and retrieve the results. |
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onStatusUpdate event. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
execute(inputParameters, callback?, errback?)
Sends a request to the server to execute a synchronous GP task. On completion, the onExecuteComplete event is fired and the optional callback function is invoked.
The return object of dojo.Deferred was added at v1.4.
Input Parameters:
|
<Object> inputParameters |
Required |
The inputParameters argument specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters:
Input_Points (GPFeatureRecordSetLayer)
Distance (GPDouble)
|
The parameters argument for the above inputs is a data object of the form:
{
Input_Points: <FeatureSet>,
Distance: <Number>
}
|
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onExecuteComplete event. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
getResultData(jobId, parameterName, callback?, errback?)
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName. On completion, the getresultdatacomplete event will be fired and the optional callback function will be invoked.
The return object of dojo.Deferred was added at v1.4.
Input Parameters:
|
<String> jobId |
Required |
The jobId returned from JobInfo. |
|
<String> parameterName |
Required |
The name of the result parameter as defined in Services Directory. |
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onGetResultDataComplete event. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
getResultImage(jobId, parameterName, imageParameters, callback?, errback?)
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName as an image.
The return object of dojo.Deferred was added at v1.4.
Input Parameters:
|
<String> jobId |
Required |
The jobId returned from JobInfo. |
|
<String> parameterName |
Required |
The name of the result parameter as defined in Services Directory. |
|
<ImageParameters> imageParameters |
Required |
Specifies the properties of the result image. |
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onGetResultImageComplete event. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
getResultImageLayer(jobId, parameterName, imageParameters, callback?, errback?)
Sends a request to the GP Task to get the task result identified by jobId and resultParameterName as an ArcGISDynamicMapServiceLayer.
Return value: none
Input Parameters:
|
<String> jobId |
Required |
The jobId returned from JobInfo. |
|
<String> parameterName |
Required |
The name of the result parameter as defined in Services Directory. |
|
<ImageParameters> imageParameters |
Required |
Contains various options that can be specified when generating a dynamic map image. |
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onGetResultImageLayerComplete event. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
setOutputSpatialReference(spatialReference)
Sets the the well-known ID of the spatial reference of the output geometries.
Return value: none
Input Parameters:
|
<SpatialReference> spatialReference |
Required |
The well-known ID of a spatial reference.
{"wkid" : 4326}
|
setProcessSpatialReference(spatialReference)
Sets the well-known ID of the spatial reference that the model uses to perform geometry operations.
Return value: none
Input Parameters:
|
<SpatialReference> spatialReference |
Required |
The well-known ID of a spatial reference.
{"wkid" : 4326}
|
Sets the time interval in milliseconds between each job status request sent to an asynchronous GP task.
Return value: none
Input Parameters:
|
<Number> delay |
Required |
The value in milliseconds. One second equals 1000 milliseconds. |
submitJob(inputParameters, callback?, statusCallback?, errback?)
Submits a job to the server for asynchronous processing by the GP task. Once the job is submitted and until it is completed, the onStatusUpdate event is fired and the optional statusCallback() function is invoked at regular intervals, the duration of which is specified by the updateDelay property. Upon completion of the job, the onJobComplete event is fired and the optional callback function is invoked.
The task execution results can be retrieved using getResultData(), getResultImage() or getResultImageLayer() methods.
Return value: none
Input Parameters:
|
<Object> inputParameters |
Required |
The inputParameters argument specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters:
Input_Points (GPFeatureRecordSetLayer)
Distance (GPDouble)
|
The parameters argument for the above inputs is a data object of the form:
{
Input_Points: <FeatureSet>,
Distance: <Number>
}
|
|
<Function> callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onJobComplete event. |
|
<Function> statusCallback |
Optional |
Checks the current status of the job. The returned JobInfo message includes the status along with the GPMessage. |
|
<Function> errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
Events Detail
Fires when an error occurs when executing the task. (As of v1.3)
Arguments:
onExecuteComplete(results, messages)
Fires when a synchronous GP task is completed.
Arguments:
onGetInputComplete(input)
Not implemented for beta.
Arguments:
onGetResultDataComplete(result)
Fires when the result of an asynchronous GP task execution is available.
Arguments:
|
<ParameterValue> result
|
Contains the result parameters and the task execution messages.
|
onGetResultImageComplete(mapImage)
Fires when a map image is generated by invoking the getResultImage() method.
Arguments:
|
<MapImage> mapImage
|
Contains the properties of a dynamically generated map image.
|
onGetResultImageLayerComplete(ArcGISDynamicMapServiceLayer)
Fires when getResultImageLayer() has completed.
Arguments:
|
<Layer> ArcGISDynamicMapServiceLayer
|
The layer that can be added to the map.
|
Fires when an asynchronous GP task using submitJob is complete.
Arguments:
Fires when a job status update is available.
Arguments: