Select to view content in your preferred language

Local Geoprocessing without packages

7452
47
Jump to solution
11-09-2012 11:26 AM
Labels (1)
GeorgeFaraj
Frequent Contributor
I'm opening feature layers from map packages and now I need to run tools such as Union, Buffer, Intersect, etc. dynamically on those layers, then add the results as a new layer in the map. What is the best way to do this locally without using pre-modeled packages?
47 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

The task within the service takes the same name as the model name - from your screenshot it looks like you should be using "BufferModel" in your code?

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Well, that was a quick reply! 🙂

I actually noticed that and edited the error message above. This is the error I'm getting now:

Bad request: POST GPServer/BufferModel/execute The 'execute' operation is not supported.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
The type of method call you make: ExecuteAsync or SubmitJobAsync needs to correspond the the GPServiceType you start the Local GP Service as (GpServiceType.Execute, etc) - see http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client.Local~ESRI.ArcG... for more info.

It's an architectural detail of the way the RuntimeLocalServer manages the LocalGPService, but it's a choice you need to make. Typically the Execute (synchronous) type of service should only be used for very quick models/taks.

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Thanks. I had forgotten to pass Execute in the service's constructor. Now I'm getting another error. Any idea how to figure out what's wrong now?

Unable to complete operation.



EDIT: Found more details about the error inside the failed event args:

[0] = "Error executing tool.: ERROR 000800: The value is not a member of parcels."


'parcels' is the name of my FeatureLayer. It's also the name of the layer I used as a sample input when I ran the tool in ArcMap.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
You've got a couple of options:

#1. Iterate over the GPMessages

e.g.

geoprocessor.ExecuteCompleted += (s1, e1) =>
                        {
                            GPExecuteResults results = e1.Results;

                            foreach (GPMessage message in results.Messages)
                            {
                                // Do Something e.g. Console.WriteLine(message.Description);
                            }
                        };

geoprocessor.ExecuteAsync(new List<GPParameter>());


#2. Take a look at the actual RuntimeLocalServer log files - sometimes there may be additional info in there.
Use the LocalServerUtility (accessed from the Start Menu) to enable logging for your central developer Runtime install then rerun your code. This will generate a log file - you can use the LocalServerUtility to view these logfiles, or at least the location of them anyway - they're just textfiles written to your temp folder.

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
The ExecuteCompleted handler doesn't get called, only the Failed handler does. I edited my reply above with more info, but here it is too:

Found more details about the error inside the failed event args:

[0] = "Error executing tool.: ERROR 000800: The value is not a member of parcels."


'parcels' is the name of my FeatureLayer. It's also the name of the layer I used as a sample input when I ran the tool in ArcMap.

EDIT:

My LocalServer log:

2013-01-22 10:49:35,418  INFO rid=22  'server' AdminWebService - POST admin/createService
2013-01-22 10:49:35,420  INFO rid=22  'server' GPServer-buffertest1 - Creating.
2013-01-22 10:49:35,420  INFO rid=22  'server' GPServer-buffertest1 - Create
2013-01-22 10:49:35,420  INFO rid=22  'server' ServerObjectHostProcess-buffertest1_host - Creating.
2013-01-22 10:49:35,420  INFO rid=22  'server' ServerObjectHostProcess-buffertest1_host - Launching.
2013-01-22 10:49:35,428  INFO rid=22  'server' ServerObjectHostProcess-buffertest1_host - Launched process 12220
2013-01-22 10:49:35,506  INFO rid=    'worker-12220' STAServerObjectHost - Creating.
2013-01-22 10:49:35,511  INFO rid=22  'worker-12220' STAServerObjectHost - Received Request.
2013-01-22 10:50:09,628  INFO rid=22  'worker-12220' STAServerObjectHost - Received Request.
2013-01-22 10:50:09,632  INFO rid=22  'server' GPServer-buffertest1 - Created
2013-01-22 10:50:09,633  INFO rid=22  'server' WebServer - Added request handler for HTTP resource: /CVGcCl/arcgis/rest/services/buffertest1
2013-01-22 10:50:09,633  INFO rid=22  'server' WebServer - Loaded static web service for resource (/CVGcCl/arcgis/rest/services/buffertest1)
2013-01-22 10:50:09,637  INFO rid=23  'server' GPServer-buffertest1 - GET GPServer?f=json&tstmp=634944486096376811
2013-01-22 10:50:09,650  INFO rid=23  'server' GPServer-buffertest1 - Request handled.
2013-01-22 10:50:09,658  INFO rid=24  'server' GPServer-buffertest1 - GET GPServer/BufferModel?f=json&tstmp=634944486096576831
2013-01-22 10:50:09,659  INFO rid=24  'server' GPServer-buffertest1 - Request handled.
2013-01-22 10:50:09,761  INFO rid=25  'server' GPServer-buffertest1 - POST GPServer/BufferModel/execute
2013-01-22 10:50:09,764  INFO rid=25  'worker-12220' STAServerObjectHost - Received Request.
2013-01-22 10:50:13,087  INFO rid=25  'server' GPServer-buffertest1 - Request handled.
2013-01-22 10:50:23,088  INFO rid=    '' WebServer - Lost connection on port 50000



EDIT2: I should post my code:

var gp = new Geoprocessor(GetGeoprocessingService().UrlGeoprocessingService + "/BufferModel");

var parameters = new List<GPParameter>();

var gpFeatureRecordSetLayer = new GPFeatureRecordSetLayer("InputLocation");

foreach (var graphic in (MyMap.Layers["parcels"] as FeatureLayer).SelectedGraphics)
{
 gpFeatureRecordSetLayer.FeatureSet.Features.Add(graphic);
}

parameters.Add(gpFeatureRecordSetLayer);
gp.ExecuteCompleted += (senderObject, gpExecuteCompleteEventArgs) =>
{
};
gp.Failed += (senderObject, taskFailedEventArgs) =>
{
};
gp.ExecuteAsync(parameters);
0 Kudos
GeorgeFaraj
Frequent Contributor
I fixed my input parameters, they were not set correctly. I got it to complete, but got no results back. Apparently this is because I had no output parameter set up. I went back to ArcMap and set the output of the Buffer tool to be a Model Parameter. I am now getting this error:

Error executing tool.: ERROR 000210: Cannot create output C:\Users\gfaraj\AppData\Local\Temp\arcgisruntime_7576\buffertest1\jobs\_\j8adb6feeb81f41cab48b4ec3f22a011d\scratch\scratch.gdb\BufferResult
Failed to execute (Buffer).
Failed to execute (BufferModel).
Failed to execute (BufferModel).
Failed to execute (BufferModel).


Any ideas?
0 Kudos
GeorgeFaraj
Frequent Contributor
Nevermind, I got it working. I was passing my input parameter with the wrong name. Thanks to everyone who helped!
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Glad to hear you got it working.

There's a sample in the WPF Sample App which could help in future - GPTaskInfo, it spins up a new LocalGPService based on your GPK and lists the parameters, etc. Looks like this: http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/GPTaskInfo/02q20000004w000000/

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Question: Is there a way for the resulting feature set to contain the attributes of the input feature set parameters? I'm getting back the parameters that were in the schema I used in ArcMap, and not the attributes of the actual features I'm passing to the geoprocessor.
0 Kudos