Select to view content in your preferred language

Running GP Task of Local GP Package

2557
2
11-10-2011 12:59 PM
Labels (1)
BKuiper
Frequent Contributor
I'm trying to run a GP Task from a GP Package but keeping this error when i specify the input parameters:

Expected to find comma, colon or start of array; state : Empty; buffer : <html>
  <head>
    <title>ArcGISRuntime Server<


Any idea what is going wrong? is there any good code example online using ArcGIS Runtime ?

I'm trying to execute a Buffer call on a LocalFeatureLayer.

Here is a piece of my code:

                        List<GPParameter> parameters = new List<GPParameter>();

                        var uri = new Uri(this.featureLayer.Url).ToString();

                        GPFeatureRecordSetLayer param1 = new GPFeatureRecordSetLayer("parkBoundary_shp", uri);

                        parameters.Add(param1);

                        ////parameters.Add(param1);

                        gp = new Geoprocessor(task.Url);
                        gp.StatusUpdated += this.gp_StatusUpdated;
                        gp.JobCompleted += this.gp_JobCompleted;
                        gp.Failed += this.gp_Failed;
                        gp.SubmitJobAsync(parameters);


Any help is greatly appreciated! thanks!
0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

The overload which accepts a Uri is expecting the Uri of a file which contains a JSON representation of the actual features themselves.

To achieve what I believe you're trying to do - you can just loop through the Graphics in the FeatureLayer and add those to a new GPFeatureRecordSetLayer e.g.

List<GPParameter> parameters = new List<GPParameter>();
GPFeatureRecordSetLayer gpFeatureRecordSetLayer = new GPFeatureRecordSetLayer("InputFeatures");
       foreach (var g in _featureLayer.Graphics)
       {
           gpFeatureRecordSetLayer.FeatureSet.Features.Add(g);
       }
       parameters.Add(gpFeatureRecordSetLayer);


Or alternatively (and recommended) would be to execute a query against the FeatureLayer with the QueryTask in order to retrieve the required subset of features. The QueryTask returns a FeatureSet which contains Graphic features - so again you can easily add this to the GPFeatureRecordSetLayer parameter.

We've been working on additional samples since Beta 1 but you will find some Geoprocessing samples already in the locally installed sample application (e.g. C:\Program Files (x86)\ArcGIS SDKs\WPF10.1\SDK\Samples). At Beta 1 we shipped the whole project source code for the samples app - we've now changed this to launch as a compiled app straight from the start menu so it will be much easier to access in the forthcoming Beta 2.

Cheers

Mike
0 Kudos
BKuiper
Frequent Contributor
Got it working!

Thanks for helping us out Mike. Nice to see Esri is so closely involved with the customers.
0 Kudos