Geoprocessing service Execute method
Executes a synchronous geoprocessing tool.
Execute(string ToolName, GPValue[] Values, GPResultOptions Options, PropertySet EnvironmentValues)
Parameter |
Description |
---|---|
ToolName |
The name of a server tool in a geoprocessing service. |
Values |
An array of GPValue instances, one for each input to the tool. |
Options |
A GPResultOptions instance defining how the result values are returned. Can be null. If specified, results are modified using these options during tool execution. |
EnvironmentValues |
A PropertySet of name value pairs which can be used to modify tool execution. Can be null. Environment values can be general or specific to the operations within the tool. |
Return Value
A GPResult object.
Remarks
The Execute method allows the caller to execute a tool synchronously where the caller passes in an array of GPValue objects corresponding to the input parameters. Parameter values must be passed in the correct order (the order corresponding to the order of ParameterInfo objects in the Tool). The results of execution are returned as a GPResult that contains an array of GPValue objects (the order corresponding to the order of ParameterInfo objects in the Tool) and the job messages.
The Options parameter is used to indicate various options for returning result values. If the options is null, the default options are used. The Options parameter, a GPResultOptions object, references a number of properties, including DensifyFeatures, TransportType, SpatialReference, Format, and FormatProperties.
- DensifyFeatures: If densify features is false, then the features in the feature record set are not modified. If densify features is true, then curves in the feature record set are converted to line segments with vertices. Some client applications cannot handle curves. These applications would use the results options in Execute and GetJobResult to densify the curves. The default value is false.
- TransportType: If transport type is 'Url' then the data types that contain a GDSData object will return the GDSData object with the URL to the file. If transport type is 'Embedded' then the GDSData object will contain a byte stream of the return file. The default value is URL.
- SpatialReference: If the spatial reference is set, returned record sets and raster data will be projected to the given spatial reference.
- Format: If the format is 'KML', the geodataset results will be returned as KML files. The value object will be a GPDataFile. The file will be a URL or an embedded byte stream depending on the transport type property.
- FormatProperties: Format properties contains properties that can be modified for the given format. The format properties are optional. For KML the format properties are:
Keyword |
Type |
Default Value |
---|---|---|
Composite |
bool |
false |
VectorsToRasters |
bool |
true |
ImageSize |
long |
1024 |
PaletteSize |
long |
256 |
IconSize |
long |
32 |
Scale |
double |
1.0 |
DPI |
double |
96 |
IgnoreScaleFactor |
bool |
false |
IgnoreVisibility |
bool |
false |
FeatureLimit |
double |
10+6 |
Environment values can be general or specific to the operations (tools) within the server tool. General environment values apply to all operations. Specific environment values only affect specific operations. By default, the server tool does not provide information on the operations it contains, only the input and output types. The service publisher must provide information on the operations within the tool for consumers to know which environment values are valid. For more information, see A quick tour of geoprocessing environments in the ArcGIS Help.
Examples
C#
string endpoint = "http://sampleserver1.arcgisonline.com/ArcGIS/services/Elevation/ESRI_Elevation_World/GPServer";
GPServerProxy gpserver = new GPServerProxy(endpoint);
GPToolInfo viewshedToolInfo = gpserver.GetToolInfo("Viewshed");
GPValue[] gpValues = new GPValue[2];
//create the point for the viewshed tool from the default schema
GPParameterInfo gpPI = viewshedToolInfo.ParameterInfo[0];
//Use the default schema
GPFeatureRecordSetLayer inPoint = (GPFeatureRecordSetLayer)gpPI.Value;
RecordSet inPointRS = inPoint.RecordSet;
Record[] records = new Record[1];
Record rec = new Record();
rec.Values = new object[3];
//id field
rec.Values[0] = 0;
//shape field
PointN p = new PointN();
p.X = -13100000.0;
p.Y = 4200000.0;
rec.Values[1] = p;
//offset field
rec.Values[2] = 70;
//add the record to the set of records.
records[0] = rec;
inPointRS.Records = records;
//create the linear unit value
GPLinearUnit gpLU = new GPLinearUnit();
gpLU.Value = 10;
gpLU.Units = esriUnits.esriKilometers;
gpValues[0] = inPoint;
gpValues[1] = gpLU;
//############# Execute with no Options #############
GPResult gpResult = gpserver.Execute("Viewshed", gpValues, null, null);
GPFeatureRecordSetLayer viewshedPoly = (GPFeatureRecordSetLayer)gpResult.Values[0];
//############# Execute with Result Options #############
//Setup Result Options
GPResultOptions resultOptions = new GPResultOptions();
//Result Spatial Reference
ProjectedCoordinateSystem PCS = new ProjectedCoordinateSystem();
PCS.WKID = 102113;
PCS.WKIDSpecified = true;
resultOptions.SpatialReference = (SpatialReference)PCS;
//Result Format
resultOptions.Format = "kml";
//Transport Type
resultOptions.TransportType = esriGDSTransportType.esriGDSTransportTypeUrl;
resultOptions.TransportTypeSpecified = true;
//Execute with GPResult Options
GPResult gpResult2 = gpserver.Execute("Viewshed", gpValues, resultOptions, null);
GPDataFile kmlViewshedPoly = (GPDataFile)gpResult2.Values[0];
System.Console.WriteLine(kmlViewshedPoly.Data.URL);