This page describes an older version, please see latest API at http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/tasks/Geoprocessor.html.
Packagecom.esri.ags.tasks
Classpublic class Geoprocessor
InheritanceGeoprocessor Inheritance BaseTask Inheritance flash.events.EventDispatcher

Represents a geoprocessing task resource exposed by the ArcGIS Server REST API (available in ArcGIS Server 9.3 and above). A geoprocessing task resource represents a single task in a geoprocessing service published using the ArcGIS Server and it supports one of the following two main operations: In addition, for a jobId:

Set the URL to the ArcGIS Server REST resource that represents a Geoprocessor service, for example, http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons. For more information on constructing a URL, see Using the ArcGIS Services Directory. Note that when publishing the GP service you should decide whether you want your task synchronous or asynchronous. Asynchronous is the default, but synchronous is more common when used with the web APIs. Use asynchronous when your task takes time and the browser request might time out.

View the examples

See also

Concepts - Geoprocessing tasks
Live Sample - adding Geoprocessor with MXML.
Live Sample - adding Geoprocessor with ActionScript.
Live Sample - execute Geoprocessor, use result for a Query.


Public Properties
 PropertyDefined By
 InheritedautoNormalize : Boolean
If true, normalizes the geometries across the central meridian.
BaseTask
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same task.
BaseTask
 InheriteddisableClientCaching : Boolean
If true, adds a timestamp parameter ("_ts") to the REST request to prevent the request from being loaded from the browser's cache.
BaseTask
  executeLastResult : ExecuteResult
[Synchronous] The result returned from last call to the execute function.
Geoprocessor
  executeLastResultFirstFeatureSet : FeatureSet
[Synchronous] The first feature set of the last execute result if the first result parameter value is an instance of FeatureSet.
Geoprocessor
  getInputLastResult : ParameterValue
[Asynchronous] The result from the last getInput call.
Geoprocessor
  getResultDataLastResult : ParameterValue
[Asynchronous] The result from the last getResultData call.
Geoprocessor
  getResultImageLastResult : ParameterValue
[Asynchronous] The result from the last getResultImage call.
Geoprocessor
 Inheritedmethod : String
URL request method to use.
BaseTask
  outSpatialReference : SpatialReference
The well-known ID of the spatial reference of the output geometries.
Geoprocessor
  processSpatialReference : SpatialReference
The well-known ID of the spatial reference that the model will use to perform geometry operations.
Geoprocessor
 InheritedproxyURL : String
The URL to proxy the request through.
BaseTask
 InheritedrequestTimeout : int
The request timeout in seconds.
BaseTask
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
BaseTask
  submitJobLastResult : JobInfo
[Asynchronous] The result returned from the last call to submitJob function.
Geoprocessor
 Inheritedtoken : String
Token for accessing a secure task.
BaseTask
  updateDelay : Number
[Asynchronous] The time interval in milliseconds between each job status request sent to an asynchronous geoprocessing task.
Geoprocessor
 Inheritedurl : String
URL of the task.
BaseTask
  useAMF : Boolean = true
Use AMF for execute() and getResultData().
Geoprocessor
Public Methods
 MethodDefined By
  
Geoprocessor(url:String = null)
Creates a new Geoprocessor object that represents the geoprocessing task.
Geoprocessor
  
cancelJobStatusUpdates(jobId:String):void
[Asynchronous] Cancels the periodic job status updates initiated automatically when submitJob() is invoked for the job identified by jobId.
Geoprocessor
  
checkJobStatus(jobId:String, responder:IResponder = null):AsyncToken
[Asynchronous] Sends a request to the geoprocessing task for the current state of the job identified by jobId.
Geoprocessor
  
execute(inputParameters:Object, responder:IResponder = null):AsyncToken
[Synchronous] Sends a request to the server to execute a synchronous geoprocessing task.
Geoprocessor
  
getInput(jobId:String, parameterName:String, responder:IResponder = null):AsyncToken
[Asynchronous] Requests the original input sent to the server (in case you forgot).
Geoprocessor
  
getResultData(jobId:String, parameterName:String, responder:IResponder = null):AsyncToken
[Asynchronous] Sends a request to the Geoprocessor task to get the task result identified by jobId and resultParameterName.
Geoprocessor
  
getResultImage(jobId:String, parameterName:String, imageParameters:ImageParameters, responder:IResponder = null):AsyncToken
[Asynchronous] Sends a request to the geoprocessing task to get the task result identified by jobId and resultParameterName as an image.
Geoprocessor
  
getResultImageLayer(jobId:String, parameterName:String, imageParameters:ImageParameters = null):GPResultImageLayer
[Asynchronous] Creates and configures a GPResultImageLayer instance ready to be added to a Map.
Geoprocessor
  
submitJob(inputParameters:Object, responder:IResponder = null, statusResponder:IResponder = null):AsyncToken
[Asynchronous] Submits a job request to the server to execute an asynchronous geoprocessing task.
Geoprocessor
Protected Methods
 MethodDefined By
 Inherited
sendURLVariables(urlSuffix:String, urlVariables:URLVariables, responder:IResponder, operation:Function):AsyncToken
Sends an HTTP request.
BaseTask
Events
 Event Summary Defined By
  Dispatched when an execute operation successfully completes.Geoprocessor
  Dispatched when a Geoprocessor request fails.Geoprocessor
  Dispatched when a getInput operation successfully completes.Geoprocessor
  Dispatched when a getResultData operation successfully completes.Geoprocessor
  Dispatched when a getResultImage operation successfully completes.Geoprocessor
  Dispatched when a submitJob operation successfully completes.Geoprocessor
  Dispatched when a checkStatus operation successfully completes.Geoprocessor
Property Detail
executeLastResultproperty
executeLastResult:ExecuteResult

[Synchronous] The result returned from last call to the execute function.

This property can be used as the source for data binding.


Implementation
    public function get executeLastResult():ExecuteResult
    public function set executeLastResult(value:ExecuteResult):void
executeLastResultFirstFeatureSetproperty 
executeLastResultFirstFeatureSet:FeatureSet

[Synchronous] The first feature set of the last execute result if the first result parameter value is an instance of FeatureSet.

This property can be used as the source for data binding.


Implementation
    public function get executeLastResultFirstFeatureSet():FeatureSet
    public function set executeLastResultFirstFeatureSet(value:FeatureSet):void
getInputLastResultproperty 
getInputLastResult:ParameterValue

[Asynchronous] The result from the last getInput call.

This property can be used as the source for data binding.


Implementation
    public function get getInputLastResult():ParameterValue
    public function set getInputLastResult(value:ParameterValue):void
getResultDataLastResultproperty 
getResultDataLastResult:ParameterValue

[Asynchronous] The result from the last getResultData call.

This property can be used as the source for data binding.


Implementation
    public function get getResultDataLastResult():ParameterValue
    public function set getResultDataLastResult(value:ParameterValue):void
getResultImageLastResultproperty 
getResultImageLastResult:ParameterValue

[Asynchronous] The result from the last getResultImage call.

This property can be used as the source for data binding.


Implementation
    public function get getResultImageLastResult():ParameterValue
    public function set getResultImageLastResult(value:ParameterValue):void
outSpatialReferenceproperty 
outSpatialReference:SpatialReference

The well-known ID of the spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the input geometries. If processSpatialReference is specified and outSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference.

Note: this property was known as outputSpatialReference in version 1.x.

This property can be used as the source for data binding.


Implementation
    public function get outSpatialReference():SpatialReference
    public function set outSpatialReference(value:SpatialReference):void
processSpatialReferenceproperty 
processSpatialReference:SpatialReference

The well-known ID of the spatial reference that the model will use to perform geometry operations. If processSpatialReference is specified and outSpatialReference is not specified, the output geometries are in the spatial reference of the process spatial reference.

This property can be used as the source for data binding.


Implementation
    public function get processSpatialReference():SpatialReference
    public function set processSpatialReference(value:SpatialReference):void
submitJobLastResultproperty 
submitJobLastResult:JobInfo

[Asynchronous] The result returned from the last call to submitJob function.

This property can be used as the source for data binding.


Implementation
    public function get submitJobLastResult():JobInfo
    public function set submitJobLastResult(value:JobInfo):void
updateDelayproperty 
updateDelay:Number

[Asynchronous] The time interval in milliseconds between each job status request sent to an asynchronous geoprocessing task.

The default value is 4000 milliseconds.

This property can be used as the source for data binding.


Implementation
    public function get updateDelay():Number
    public function set updateDelay(value:Number):void
useAMFproperty 
public var useAMF:Boolean = true

Since : ArcGIS API for Flex 2.0

Use AMF for execute() and getResultData(). Requires the server to be ArcGIS Server 10.0 or above, set to false if using earlier server versions. When useAMF is true, the BaseTask properties concurrency, requestTimeout and showBusyCursor are ignored.

Constructor Detail
Geoprocessor()Constructor
public function Geoprocessor(url:String = null)

Creates a new Geoprocessor object that represents the geoprocessing task.

Parameters
url:String (default = null) — The URL of the geoprocessing task.
Method Detail
cancelJobStatusUpdates()method
public function cancelJobStatusUpdates(jobId:String):void

[Asynchronous] 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.

Parameters

jobId:String — 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.

checkJobStatus()method 
public function checkJobStatus(jobId:String, responder:IResponder = null):AsyncToken

[Asynchronous] Sends a request to the geoprocessing task for the current state of the job identified by jobId. Upon receiving the response, the statusUpdate event is fired and the optional callback function is invoked. Normally, you wouldn't need this method as the job status is checked automatically (unless you've used cancelJobStatusUpdates to cancel the automatic job status updates).

Parameters

jobId:String — 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.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
execute()method 
public function execute(inputParameters:Object, responder:IResponder = null):AsyncToken

[Synchronous] Sends a request to the server to execute a synchronous geoprocessing task. On completion, the executeComplete event is fired and the optional callback function is invoked.

Parameters

inputParameters:Object — 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 geoprocessing task resource.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken

See also

getInput()method 
public function getInput(jobId:String, parameterName:String, responder:IResponder = null):AsyncToken

[Asynchronous] Requests the original input sent to the server (in case you forgot). On completion, the getInputComplete event is fired and the optional callback function is invoked.

Parameters

jobId:String — 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.
 
parameterName:String — The responder to call for status.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
getResultData()method 
public function getResultData(jobId:String, parameterName:String, responder:IResponder = null):AsyncToken

[Asynchronous] Sends a request to the Geoprocessor task to get the task result identified by jobId and resultParameterName. On completion, the getResultDataComplete event is fired and the optional callback function is invoked.

Parameters

jobId:String — 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.
 
parameterName:String — The responder to call for status.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
getResultImage()method 
public function getResultImage(jobId:String, parameterName:String, imageParameters:ImageParameters, responder:IResponder = null):AsyncToken

[Asynchronous] Sends a request to the geoprocessing task to get the task result identified by jobId and resultParameterName as an image. This gives you a static image instead of a map layer. The image cannot be added to the map.

Parameters

jobId:String — 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.
 
parameterName:String — The name of the result parameter as defined in ArcGIS Services Directory.
 
imageParameters:ImageParameters — Specifies the properties of the result image.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
getResultImageLayer()method 
public function getResultImageLayer(jobId:String, parameterName:String, imageParameters:ImageParameters = null):GPResultImageLayer

[Asynchronous] Creates and configures a GPResultImageLayer instance ready to be added to a Map.

Parameters

jobId:String — 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.
 
parameterName:String — The name of the result parameter as defined in ArcGIS Services Directory.
 
imageParameters:ImageParameters (default = null) — Contains various options that can be specified when generating a dynamic map image.

Returns
GPResultImageLayer — A new GPResultImageLayer.
submitJob()method 
public function submitJob(inputParameters:Object, responder:IResponder = null, statusResponder:IResponder = null):AsyncToken

[Asynchronous] Submits a job request to the server to execute an asynchronous geoprocessing task. On completion, the jobComplete event is fired and optional callback functions are invoked.

Parameters

inputParameters:Object — 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 geoprocessing task resource.
 
responder:IResponder (default = null) — The responder to call on result or fault.
 
statusResponder:IResponder (default = null) — The responder to call on status updates.

Returns
AsyncToken

See also

Event Detail
executeComplete Event
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.EXECUTE_COMPLETE

Dispatched when an execute operation successfully completes. This only applies to tasks submitted with the execute method (not the submitJob method).

Defines the value of the type property of an executeComplete event object.
fault Event  
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

Dispatched when a Geoprocessor request fails. Applies to all methods.

getInputComplete Event  
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.GET_INPUT_COMPLETE

Dispatched when a getInput operation successfully completes.

Defines the value of the type property of a getInputComplete event object.
getResultDataComplete Event  
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.GET_RESULT_DATA_COMPLETE

Dispatched when a getResultData operation successfully completes.

Defines the value of the type property of a getResultDataComplete event object.
getResultImageComplete Event  
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.GET_RESULT_IMAGE_COMPLETE

Dispatched when a getResultImage operation successfully completes.

Defines the value of the type property of a getResultImageComplete event object.
jobComplete Event  
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.JOB_COMPLETE

Dispatched when a submitJob operation successfully completes.

Defines the value of the type property of a jobComplete event object.
statusUpdate Event  
Event Object Type: com.esri.ags.events.GeoprocessorEvent
GeoprocessorEvent.type property = com.esri.ags.events.GeoprocessorEvent.STATUS_UPDATE

Dispatched when a checkStatus operation successfully completes. This only applies to tasks submitted with the submitJob method (not the execute method).

Defines the value of the type property of a statusUpdate event object.
Examples
ActionScript for a synchronous task using execute() that takes an input point and two parameters:
 var mapPoint:Geometry = new MapPoint(-20, -10);
 
 var featureSet:FeatureSet = new FeatureSet();
 featureSet.features = [ { geometry: mapPoint } ];
 
 var params:Object = new Object();
 params.Input_Point = featureSet;
 params.Days = 10;
 
 var gp:Geoprocessor = new Geoprocessor();
 gp.url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle";
 gp.execute(params);
 gp.addEventListener(GeoprocessorEvent.EXECUTE_COMPLETE, executeCompleteHandler);
 gp.addEventListener(FaultEvent.FAULT, faultHandler);