Class: GeoprocessorE-mail This Topic Printable Version Give Us Feedback

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:

Class hierarchy

esri.tasks.Geoprocessor

Constructor

Constructor Description
esri.tasks.Geoprocessor(url) Creates a new Geoprocessor object that represents the GP Task identifed by a URL.

Properties

Property Type Description
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

Method Return Value Description
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

Event Description
onError(error) Fires when an error occurs when executing the task.
onExecuteComplete(results, messages) Fires when a synchronous GP task is completed.
onGetInputComplete(input) Not implemented for beta.
onGetResultDataComplete(result) Fires when the result of an asynchronous GP task execution is available.
onGetResultImageComplete(mapImage) Fires when a map image is generated by invoking the getResultImage() method.
onGetResultImageLayerComplete(ArcGISDynamicMapServiceLayer) Fires when getResultImageLayer() has completed.
onJobComplete(status) Fires when an asynchronous GP task using submitJob is complete.
onStatusUpdate(status) Fires when a job status update is available.
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

<SpatialReference> outputSpatialReference

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.

<SpatialReference> processSpatialReference

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.

<Number> updateDelay

The time interval in milliseconds between each job status request sent to an asynchronous GP task.
Default value: 1000
See also:
setUpdateDelay  

<String> url

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)
See also:
onStatusUpdate   onError   cancelJobStatus  

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.
Return value: dojo.Deferred
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)
See also:
onExecuteComplete   onError  

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.
Return value: dojo.Deferred
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)
See also:
onGetResultDataComplete   onError  

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.
Return value: dojo.Deferred
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)
See also:
onGetResultImageComplete   onError  

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} 
See also:
outputSpatialReference  

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} 
See also:
processSpatialReference  

setUpdateDelay(delay)

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.
See also:
updateDelay  

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)
See also:
onJobComplete   onError   cancelJobStatus  

Events Detail

onError(error)

Fires when an error occurs when executing the task. (As of v1.3)
Arguments:
<Error> error ArcGIS Server error message returned in a JavaScript error object.

onExecuteComplete(results, messages)

Fires when a synchronous GP task is completed.
Arguments:
<ParameterValue[]> results An array of ParameterValue objects that gives access to the result parameters and the task execution messages.
<GPMessage> messages An array of GPMessage that has the type and description.
See also:
execute  

onGetInputComplete(input)

Not implemented for beta.
Arguments:
<ParameterValue> input Not implemented for beta.
See also:
getInput  

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.
See also:
getResultData  

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.
See also:
getResultImage  

onGetResultImageLayerComplete(ArcGISDynamicMapServiceLayer)

Fires when getResultImageLayer() has completed.
Arguments:
<Layer> ArcGISDynamicMapServiceLayer The layer that can be added to the map.
See also:
getResultImageLayer  

onJobComplete(status)

Fires when an asynchronous GP task using submitJob is complete.
Arguments:
<JobInfo> status The returned JobInfo message that includes the status along with the GPMessage.
See also:
submitJob  

onStatusUpdate(status)

Fires when a job status update is available.
Arguments:
<JobInfo> status The returned JobInfo message that includes the status along with the GPMessage.
See also:
checkJobStatus