ArcGIS ClipShip Geoprocessing



Description:

This sample illustrates how to work with an ArcGIS Server Geoprocessing service using the Web ADF GeoprocessingResourceManager and GeoprocessingFunctionality class. The geoprocessing service contains a model (server tool) which has been added to a map document as a tool layer. As a result, the model can use the map document to retrieve layers and render content. In this case, 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, a map resource that renders features on the server and returns a map image, and\or a zip file containing a shapefile with the clipped features. In essence, the geoprocessing service can act as an extract server, packaging feature layers in the map document for distribution.

A Web application is also included with the sample to illustrate how a Web ADF client may integrate the map and geoprocessing service with existing ADF controls and patterns. A custom tool is used to draw the input line and a set of control are available to enter a buffer distance. The application operates asynchronously, so after the request to clip features the client will check the server periodically to see if the job has finished.

Data is included with the sample in the "data" directory.
Products:
Server: C#, VB.NET

Platforms: Windows

Minimum ArcGIS Release: 9.3

How to use:
  1. Design Time:
    1. Publish the services necessary to use the sample. In the sample's data directory, publish the map document USA_Data_ClipTools.mxd as a map service named "USA_Data_ClipTools". Depending on how you publish the document, a geoprocessing service of the same name may also be created. 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 a few properties in the parameters tab. Define 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 install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip ArcGIS_ClipShip_GeoprocessingCSharp.zip or ArcGIS_ClipShip_GeoprocessingVBNet.zip to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
    4. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, ArcGIS_ClipShip_Geoprocessing_<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
    5. Open the IIS Manager from 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.
    7. Expand Default Web Site then right-click the ArcGIS_ClipShip_Geoprocessing_<language> folder and click Properties.
    8. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
    9. Launch Microsoft Visual Studio. Open the solution for the version of the Visual Studio you are using. The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file is ArcGIS_ClipShip_Geoprocessing_CSharp2008.sln and located in the c:\inetpub\wwwroot\ArcGIS_ClipShip_Geoprocessing_CSharp folder.
    10. In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
    11. Save the project.
    12. Click the "Debug" drop-down menu and choose "Start".
  2. Run Time:
    1. Browse to viewer's URL (for example, http://localhost/ArcGIS_ClipShip_Geoprocessing_CSharp).
    2. In the toolbar above the map, click "Add Lines".
    3. Click on the map and create one or more lines.
    4. Select the buffer distance units.
    5. Enter a buffer distance.
    6. Check the Download Results checkbox to return a zip file for download.
    7. Click on the "Buffer And Clip" button. The geoprocessing service will asynchronously process the request. An indicator (animated gif) next to the button will display until the GP job is finished. An initial JavaScript delay is set to 5 seconds (change this in the CheckGeoprocessingJobStatus method in the code behind the page).
    8. When the job is finished, the buffer polygons will be drawn on the map as as either Web ADF feature graphics layer or a map image associated with a map resource. If Download Results was checked, a dialog will popup in the browser to download the zip file containing the clipped features as a shapefile. Note, you can modify the code to provide a link to the download instead of attempting to popup a download dialog, which requires trusted privileges.

Download the C# files
Default.aspx Default page contains a set of tools and control to provide input for a call to a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_CSharp/Default.aspx.cs The code behind the user interface. Contains the code to initiate a request and process the response to\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 VB.NET files
Default.aspx Default page contains a set of tools and control to provide input for a call to a geoprocessing service.
ArcGIS_ClipShip_Geoprocessing_VBNet/Default.aspx.vb The code behind the user interface. Contains the code to initiate a request and process the response to\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 files for all languages