ArcGIS Buffer geoprocessing


Purpose
This sample demonstrates how to work with an ArcGIS Server geoprocessing service using the Web Application Developer Framework (ADF) GeoprocessingResourceManager and the GeoprocessingFunctionality class. Before running the sample, create a geoprocessing service from the BufferTools toolbox included with the sample data located as follows:
 
<ArcGIS install location>\ArcGIS\DeveloperKit10.0\Samples\data\GP\RunBuffer
 
The BufferTools toolbox contains the BufferPoints model, which accepts two inputs: an input feature set (points) and a linear unit (the buffer distance). The output is a feature set containing the buffer geometry. The input feature set determines the type of geometry that the model can buffer as well as its spatial reference. In this sample, the layer file—InputPoints.lyr—defines the input geometry as point and the spatial reference as Hotine_Oblique_Mercator_Two_Point_Natural_Origin. The model solves for input and output data in this spatial reference.
 
It is also assumed that an ArcGIS Server map service is available in the same projection as the geoprocessing service. The data for the CaliforniaProjected  map document can be used and is located as follows:
 
<ArcGIS install location>\ArcGIS\DeveloperKit10.0\Samples\data\California
 
This sample contains a set of Web ADF controls, and is designed to work with ArcGIS Server services.
 
To help manage asynchronous requests, the sample uses the PostbackManager control, which is included in the Common_PostbackManager sample.  You must re-build this sample and add a reference to the dll it creates.  The sample is located at:

<ArcGIS install location>\DeveloperKit10.0\Samples\ServerNet\Common_PostbackManager<language>. It is a utility control that provides a simple way to issue asynchronous requests and manipulate requests made by Web Application Developer Framework (ADF) controls.

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/RunBuffer and <Your ArcGIS Developer Kit Install directory>/Samples/data/California/CaliforniaProjected.mxd.
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. Verify that the appropriate services are available (see the code description for more details).
  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>\DeveloperKit10.0\Samples\ServerNET. This folder contains ArcGIS_Buffer_Geoprocessing CSharp and VBNet folders.
  4. Open the folder of the language you're going to use—CSharp or VBNet—and copy the ArcGIS_Buffer_Geoprocessing_<language> folder to c:\inetpub\wwwroot. The <language> variable can 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, expand Default Web Site, right-click the ArcGIS_Buffer_Geoprocessing_<language> folder, and click Properties. The Properties dialog box opens.
  7. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  8. Open the solution for the version of Visual Studio you're using (2008 or 2010). The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file is ArcGIS_Buffer_Geoprocessing_CSharp2008.sln and is located in the c:\inetpub\wwwroot\ArcGIS_Buffer_Geoprocessing_CSharp folder.
  9. In Solution Explorer, right-click Default.aspx and select Set As Start Page.
  10. Open the Default.aspx page in Design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens. One Graphics layer resource is added to store the points entered by the user and the buffer geometry returned from the geoprocessing service. The Graphics resource item is not visible in the TOC.
  11. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS and so on). Any map service in the same projection as the output for the geoprocessing service will work. In this sample, the CaliforniaProjected map service is provided.
  12. Select the GeocodeResourceManager and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens.
  13. Add a GeoprocessingResourceItem associated with a geoprocessing service (ArcGIS Server only). In this sample, use the BufferTools geoprocessing service.
  14. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to step 17.
  15. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer and selecting the Add ArcGIS Identity option. Enter the identity credentials that will be used to access ArcGIS Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is checked, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
  16. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. If you're working with ArcGIS Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
  17. Save the project.
  18. 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_Buffer_Geoprocessing_CSharp).
  2. In the toolbar above the map, click Add Points, and click the map to add graphic points.
  3. Select the buffer distance units and enter a buffer distance.
  4. Click Generate Buffer. The geoprocessing service asynchronously processes the request. The activity indicator (animated gif) below the button displays until the geoprocessing job is finished. An initial JavaScript delay is set to 10 seconds (change this in the JavaScript at the top of the Default.aspx file).
  5. Interact with the application while waiting for a response from the geoprocessing service. You can use other controls in the Web application while the geoprocessing service processes the request. When the request is finished, the buffer polygons are drawn on the map as a Web ADF feature graphics layer.

ArcGIS_Buffer_Geoprocessing_CSharp\Default.aspx Contains the Web user interface (UI) to interact with server-side code.
ArcGIS_Buffer_Geoprocessing_CSharp\Default.aspx.cs Code behind the .aspx file. References Web ADF libraries and functionality. Most of the GeoprocessingFunctionality work is done here.
ArcGIS_Buffer_Geoprocessing_CSharp\App_Code\PointTool.cs Adds graphic points to the map.
ArcGIS_Buffer_Geoprocessing_CSharp\App_Code\Utility.cs Utility class that supports messaging and errors.
Download the C# files
ArcGIS_Buffer_Geoprocessing_VBNet\Default.aspx Contains the Web user interface (UI) to interact with server-side code.
ArcGIS_Buffer_Geoprocessing_VBNet\Default.aspx.vb Code behind the .aspx file. References Web ADF libraries and functionality. Most of the GeoprocessingFunctionality work is done here.
ArcGIS_Buffer_Geoprocessing_VBNet\App_Code\PointTool.vb Adds graphic points to the map.
ArcGIS_Buffer_Geoprocessing_VBNet\App_Code\Utility.vb Utility class that supports messaging and errors.
Download the VB.NET files

Download the files for all languages