Offline geoprocessing

If your app requires offline geoprocessing, you can use the LocalGeoprocessingService instance, by using the path to the local geoprocessing package. To create an offline geoprocessing package, you first need to create one with ArcGIS Desktop or Pro using the steps outlined here:

https://desktop.arcgis.com/en/desktop/latest/analyze/sharing-workflows/a-quick-tour-of-creating-a-geoprocessing-package.htm

The first thing to note is that LocalGeoprocessingService is located in Esri.ArcGISRuntime.LocalServices. Running an offline geoprocessing service is very similar to how you would use an online geoprocessing service. However, instead of just accessing the service using an online URL, you will need to start up the local geoprocessing task on your machine, like this:

this.localGPService = new LocalGeoprocessingService(this.clipGPKPath, 
    GeoprocessingServiceType.SubmitJob);
this.localGPService.StartAsync();

Note that we've instantiated LocalGeoprocessingService with the path to the geoprocessing package (*.gpk) and we tell it that this is an asynchronous task because we're using SubmitJob. Then, we start the service. This is a very similar in concept to the LocalMapService class we created in Chapter 3, Maps and Layers. In effect, LocalGeoprocessingService and LocalMapService provide us with a local ArcGIS Server on a PC. Note that LocalGeoprocessingService is not available in the Windows Store or Windows Phone versions of the ArcGIS Runtime SDK for .NET.

When we start this service, it will create a REST endpoint just like the ones you've been using with online tasks. The big difference is that the REST endpoint isn't generated until you start the task with StartAsync. If you look at the sample code that came with this book, you'll note in the sample chapter called Chapter10b that the instantiation of the geoprocessor has been moved to the Clip method, so that when the user clicks on the Start button, the geoprocessor is instantiated and passed in the URL of the task, which comes from the UrlGeoprocessingService property of LocalGeoprocessingService:

public async void Clip()
{
    this.gpUrl = this.localGPService.UrlGeoprocessingService;

    this.gpTask = new Geoprocessor(new Uri(this.gpUrl + 
        "/ClipFeatures"));

    // removed for brevity
}

If you place a break point on the line that starts with this.gpTask, you will note that the line before it generated a URL for you and it will be similar to this URL: http://127.0.0.1:50000/k7sT0w/arcgis/rest/services/clip-features/GPServer/ClipFeatures (yours will be different).

While the app is running, you can open your favorite browser and inspect this URL (without /ClipFeatures in the end). You'll find a page like this:

Offline geoprocessing

Notice anything different? Well, there are a few differences. First, with this task, Input_Features is called Input. Also, Linear_unit is now called Linear_Unit. Other than those minor differences, the service is the same as the online version of the task. Also, as soon as you close the app, this service will no longer be available because LocalGeoprocessingService will be stopped.

Execution types

The local geoprocessing server has the same kinds of execution mode as ArcGIS Server. However, you set when to instantiate the LocalGeoprocessingService instance using GeomprocessingServiceType.Execute, GeomprocessingServiceType.SubmitJob, or GeomprocessingServiceType.SubmitJobMapServerResult. The first two instances have been discussed. The SubmitJobMapServerResult instance is the same as SubmitJob, except that an additional local map service is instantiated. The SubmitJobMapServerResult instance is useful if LocalGeoprocessingService is returning a large number of features, which allows you to control the symbology however you want. This also improves performance.

Maximum number of records

When you use an online or offline geoprocessing task, it will by default only return 1,000 features. The reason for this is to improve performance. With most apps, this setting is a good number to use. However, if your app will return more than this, you can have your ArcGIS Server administrator change this setting when the service is created or modified after it has been created, by changing the setting in the service called Maximum Number of Records Returned by Server. See the following website for how to do this:

http://server.arcgis.com/en/server/latest/publish-services/windows/geoprocessing-service-settings-parameters.htm

With the LocalGeoprocessingService instance, you'll need to set a property called MaxRecords.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.93.0