Select to view content in your preferred language

Creating a FeatureSet from drawn graphics for input to a GP service

3854
7
12-08-2010 08:40 AM
DaveLewis
Deactivated User
Is it possible to create a FeatureSet object from user drawn graphics?  If so, what would be needed to pass this object a parameter to a GP service?  Is it sufficient to simply build the FeatureSet by simply cycling through each graphic and adding the geometry, as shown below.

var features:Array = [];
for each (var graphic:Graphic in graphics)
{
    features.push({ geometry: graphic.geometry });
}
var featSet:FeatureSet = New FeatureSet();
featSet.features = features;
Tags (2)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
Dave,

   A featureset is an array of graphics essentially. Not just the geometry.

var featureSet:FeatureSet = new FeatureSet([ graphic1, graphic2 ]);
0 Kudos
DaveLewis
Deactivated User
Robert,

Thank you for your response.  I tried your suggestion, but unfortunately I am receiving the same error when I pass in the featureset as a parameter to the GP service.

Unexpected fault:
[FaultEvent fault=[RPC Fault faultString="Unable
to complete operation." faultCode="400"
faultDetail="Invalid value for parameter
'Input_Features'"] messageID=null type="fault"
bubbles=false cancelable=true eventPhase=2]
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dave,

   That is a pretty generic GP error that could mean many things... I would begin by verifying what your GP services is expecting as it's input. Also verify that the name of the input parameter you are using is the exact one that the service is calling for.
0 Kudos
DaveLewis
Deactivated User
Robert,

Thanks again.  The GP script is processing now, however, my shape results do not contain any geometric information (length, area, etc.).  As an FYI, my GP service takes the input feature set and converts it to KML by using the "Layer To KML" task.  The KML is being written properly and the graphics exist, but the shape fields are NULL.  Any thoughts???

Dave
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dave,

   GP Services are pretty hard to debug. I would try checking the spatial reference of the featureset you are passing in is what the GP Tool is expecting.
0 Kudos
DaveLewis
Deactivated User
Robert,

I have checked the SR and everything appears to match up.  I can run the associated model directly in ArcMap without any problems.  The shape information (length, area, etc.) is written properly to the KML.  However, this information appears as "NULL" when executing the model as a GP service from a web app.  Weird, eh???

--Dave
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dave,

   Sorry I don't have any other suggestions.
0 Kudos