GP Tool Optional Featureset Parameter

2546
6
09-14-2012 02:31 AM
MatthewPilgrim
New Contributor III
Hi,
I have a GP tool that has an optional Featureset parameter (rest definition is included at the end) which I don't seem to be able to cope with in the silverlight API.
Using Fiddler I can see that the rest submit page creates the parameter with an empty value.

If I exclude this parameter before calling the tool I get an "Error submiting job" message.

If in c# I do:

 
FSet = new FeatureSet();
  //nothing added to FSet.Features
  Parameters.Add(new GPFeatureRecordSetLayer("BuildingPolygons_Input", FSet));


Then fiddler shows the parameter with the following value:
{"features":[]}

This causes the GP tool to return an "Unable to complete the operation" message.

If I try

 
FSet = null
  Parameters.Add(new GPFeatureRecordSetLayer("BuildingPolygons_Input", FSet));


or

 
Parameters.Add(new GPFeatureRecordSetLayer("BuildingPolygons_Input", ""));


The silverlight API throws the following exception before the call is made to the GP tool:

"Object reference not set to an instance of an object."

   at ESRI.ArcGIS.Client.Tasks.GPRecordSet.ToJson(Boolean normalizeCentralMeridian)
   at ESRI.ArcGIS.Client.Tasks.Geoprocessor.GetParameters(List`1 parameters)
   at ESRI.ArcGIS.Client.Tasks.Geoprocessor.SubmitJobAsync(List`1 parameters)
   at AECOM.ESP.ViewModels.Surface.AnalysisDetailLOSViewModel.Run()


So how do I go about not providing the parameter or providing an empty parameter?  Failing this can anything be done in the GP tool?

Thanks in advance, Matt


Parameter: BuildingPolygons_Input

Data Type: GPFeatureRecordSetLayer
Display Name: BuildingPolygons_Input
Direction: esriGPParameterDirectionInput
Default Value:

Geometry Type: esriGeometryPolygon
Spatial Reference: 2232
Fields:
FID (Type: esriFieldTypeOID, Alias: FID)
Shape (Type: esriFieldTypeGeometry, Alias: Shape)
BaseElev (Type: esriFieldTypeDouble, Alias: BaseElev)
Height (Type: esriFieldTypeDouble, Alias: Height)
TopMSL (Type: esriFieldTypeDouble, Alias: TopMSL)
Name (Type: esriFieldTypeString, Alias: Name)
Shape_Length (Type: esriFieldTypeDouble, Alias: Shape_Length)
Shape_Area (Type: esriFieldTypeDouble, Alias: Shape_Area)
Parameter Type: esriGPParameterTypeOptional
Category:
0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
FSet = new FeatureSet();
  //nothing added to FSet.Features
  Parameters.Add(new GPFeatureRecordSetLayer("BuildingPolygons_Input", FSet));


This code looks good.
But it may happen that your tool doesn't support empty feature set and return the "Unable to complete the operation" message.

Are you able to run your tool directly from your browser (i.e without SL API)?
0 Kudos
MatthewPilgrim
New Contributor III

But it may happen that your tool doesn't support empty feature set and return the "Unable to complete the operation" message.

Are you able to run your tool directly from your browser (i.e without SL API)?


Yes I can use the rest submit page and leave the parameter box empty - this works.  Fiddler shows the parameter has a completly empty value.  But when using the code you quote fiddler shows {"features":[]} and it fails.

Thanks Matt.
0 Kudos
MatthewPilgrim
New Contributor III
Can anyone verify this is an issue or give further suggestions please?

Matt
0 Kudos
MatthewPilgrim
New Contributor III
I have now upgraded to v3 of the API.  The JSON output shown by fiddler has changed from:
{"features":[]}

to simply:
{}

But I still get an error. 

I'm going to raise a bug (if I can figure out how)!

Matt
0 Kudos
JohnUnderwood
New Contributor
Was this issue ever resolved. I have the same issue using AGS 10.0 with Silverlight.  I've tried everything I can think of and nothing works. I'm my case, I need to pass as many as 3 feature sets which may or may not have features in them. I don't want to have to create and maintain a separate script for each possibility but that's the only other solution I can see at this point.
0 Kudos
MatthewPilgrim
New Contributor III
Hi,

I worked with esri support on this one.  Here is their last response:

I was able to reproduce the issue you reported today when publishing in ArcGIS Server 10.0.  I also noticed that it is possible to supply only one parameter (Button B in your sample) and get a successful result when working with a similar service published using ArcGIS Server 10.1.


At this point the project was handed off to someone else so I can't confirm is 10.1 solves the issue.  I do have a test app which I can share if needed.

Matt
0 Kudos