ArcGIS ClipShip geoprocessing


Purpose
This sample demonstrates how to work with an ArcGIS for Server geoprocessing service using the Web Application Developer Framework (ADF) GeoprocessingResourceManager and the GeoprocessingFunctionality class. The geoprocessing service contains a model (server tool) that has been added to a map document as a tool layer. The model uses the map document to retrieve layers and render content. In this sample, the server tool accepts geometry input (a line) and a distance to construct a buffer. The buffer is used to clip features from a layer in the map document (counties) and return individual features to be rendered by the client, from a map resource that renders features on the server and returns a map image, and\or from a ZIP file containing a shapefile with the clipped features. The geoprocessing service performs as an extract server, packaging feature layers in the map document for distribution.
A Web application is included with the sample to show how a Web ADF client can integrate the map and the geoprocessing service with existing ADF controls and patterns. A custom tool is used to draw the input line, and a set of controls is available to add a buffer distance. The application operates asynchronously. After the request to clip features, the client checks the server periodically to see if the job has finished.
To help manage asynchronous requests, the sample uses the PostbackManager control, which is included in the Common_PostbackManager sample.  You must build this sample and add a reference to the .dll it creates. The sample is located as follows:
  • <ArcGIS Developer Kit install location>\Samples\ServerNET\Web_Applications\Common_PostbackManager<language>
It is a utility control that provides a simple way to issue asynchronous requests and manipulate requests made by Web ADF controls. Data is included with the sample in the data directory.
Note: Local (DCOM) connections are only supported for ArcGIS for Server versions prior to 10.1.  

How to use

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/GP/RunClip/USA_data_ClipTools and <Your ArcGIS Developer Kit Install directory>/Samples/data/USA/USA.gdb.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. In the sample's data directory, publish the USA_Data_ClipTools.mxd map document as a map service named USA_Data_ClipTools. Depending on how you publish the document, a geoprocessing service of the same name can be created at the same time. If not, explicitly publish the ClipTools toolbox as a geoprocessing service named USA_Data_ClipTools. In ArcCatalog or ArcGIS Server Manager, configure the service by changing the following properties on the Parameters tab: specify that the tools are stored in a map; specify the path to the USA_Data_ClipTools.mxd; and set the result map service to USA_Data_ClipTools (the service created earlier).
  2. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  3. In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ServerNET. This folder contains ArcGIS_ClipShip_Geoprocessing CSharp and VBNet folders.
  4. Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the ArcGIS_ClipShip_Geoprocessing_<language> folder to c:\inetpub\wwwroot. The <language> variable can be CSharp or VBNet.
  5. Open the IIS Manager from the Control Panel, Administrative Tools, Internet Information Services (IIS) Manager, or Internet Information Services.
  6. In the console tree view on the left, navigate to Local Computer, Web Sites, Default Web Site. Expand Default Web Site, right-click the ArcGIS_ClipShip_Geoprocessing_<language> folder, and click Properties. The Properties dialog box appears.
  7. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  8. Start Visual Studio 2010 and open the solution located in the c:\inetpub\wwwroot\ArcGIS_ClipShip_Geoprocessing_CSharp folder.
  9. In the Solution Explorer, right-click Default.aspx, and select Set As Start Page.
  10. Save the project.
  11. Click the Debug drop-down menu and click Start.

At run time
  1. Browse to the viewer uniform resource locator (URL), for example, http://localhost/ArcGIS_ClipShip_Geoprocessing_CSharp.
  2. In the toolbar above the map, click Add Lines, click the map, and create one or more lines.
  3. Select the buffer distance units and add a buffer distance.
  4. Select the Download Results check box to return a ZIP file for download.
  5. Click the Buffer And Clip button. The geoprocessing service asynchronously processes the request. An indicator (an animated graphics interchange format [GIF] image) next to the button displays until the geoprocessing request is finished. An initial JavaScript delay is set to five (5) seconds. You can change this in the CheckGeoprocessingJobStatus method in the code behind the page.
  6. When finished, the buffer polygons are drawn on the map as a Web ADF feature graphics layer or a map image associated with a map resource. If Download Results was selected, a dialog box appears in the browser that allows you to download the ZIP file containing the clipped features as a shapefile. Alternatively, you can modify the code to provide a link to the download instead, which requires trusted privileges.

ArcGIS_ClipShip_Geoprocessing_CSharp\Default.aspx Default page contains a set of tools and controls to provide input for a call to a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_CSharp\Default.aspx.cs Code behind the user interface (UI). Contains the code to initiate a request and process the response to and from a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_CSharp\App_Code\PolylineTool.cs Contains tool code used to add an ADF graphics polyline to the map for use in the call to the geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_CSharp\App_Code\Utility.cs Class library containing helper code.
Download the C# files
ArcGIS_ClipShip_Geoprocessing_VBNet\Default.aspx Default page contains a set of tools and controls to provide input for a call to a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_VBNet\Default.aspx.vb Code behind the user interface (UI). Contains the code to initiate a request and process the response to and from a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_VBNet\App_Code\PolylineTool.vb Contains tool code used to add an ADF graphics polyline to the map for use in the call to the geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_VBNet\App_Code\Utility.vb Class library containing helper code.
Download the VB.NET files

Download the files for all languages