public static ICollection<Field> GetFields(Graphic graphic) { var fields = new List<Field>(); foreach (var attribute in graphic.Attributes) { var field = new Field() { FieldName = attribute.Key, Alias = attribute.Key }; if (attribute.Key.ToLower() == "shape") { field.Type = Field.FieldType.Geometry; } else if (attribute.Key.ToLower() == "fid") { field.Type = Field.FieldType.OID; } else if (attribute.Key.ToLower() == "objectid") { field.Type = Field.FieldType.OID; } else if (attribute.Value is int) { field.Type = Field.FieldType.Integer; } else if (attribute.Value is double) { field.Type = Field.FieldType.Double; } else if (attribute.Value is float) { field.Type = Field.FieldType.Single; } else if (attribute.Value is DateTime) { field.Type = Field.FieldType.Date; } else { field.Type = Field.FieldType.String; } fields.Add(field); } return fields; }
var inputFeatures = new GPFeatureRecordSetLayer("InputFeatures"); inputFeatures.FeatureSet.Fields = new List<Field> { new Field() { FieldName = "PROP_ID" } };
Unable to complete operation. Error executing tool.: ERROR 000210: Cannot create output C:\Users\gfaraj\AppData\Local\Temp\arcgisruntime_8188\geotools\jobs\_\j13c432afc4014a6a9eed8b1b446e0a6b\scratch\scratch.gdb\OutputFeature Failed to execute (Buffer). Failed to execute (BufferModel). Failed to execute (BufferModel). Failed to execute (BufferModel).
/* * Build the GP Parameters... */ // We want to specify input attributes - create a new FeatureSet. FeatureSet featureSet = new FeatureSet(); // Create the Fields and add one called "VALUE". featureSet.Fields = new List<Field> { new Field() { FieldName = "VALUE", Type = Field.FieldType.String, Alias = "VALUE" } }; // Create the graphic to submit. Graphic g = new Graphic() { Geometry = e.MapPoint }; // Add the graphic to the FeatureSet featureSet.Features.Add(g); // Set the graphic's attribute featureSet.Features[0].Attributes["VALUE"] = "Hello"; // Create a new list of GPParameters List<GPParameter> parameters = new List<GPParameter>(); // Add a new GPFeatureRecordSetLayer to the parameter list, passing in the FeatureSet created above. parameters.Add(new GPFeatureRecordSetLayer("Input_Features",featureSet));
var featureSet = new FeatureSet(); var layer = GetSelectedInputLayer(); featureSet.Fields = new List<Field> { new Field() { FieldName = "PROP_ID", Type = Field.FieldType.Double, Alias = "PROP_ID" } }; foreach (var graphic in layer.SelectedGraphics) { featureSet.Features.Add(graphic); } parameters.Add(new GPFeatureRecordSetLayer("InputFeatures", featureSet)); parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMeters, Convert.ToDouble(distanceText.Text)));
This may not be related but we had some problems with local GP tasks intermittently failing on some machines, often returning "Error: 000210 : Cannot create output..." (amongst others). This was related to anti-virus and group policy security settings in our corporate environment. (Everything worked fine in my dev environment, but the same code/data failed elsewhere.)
Are you running 1.0 or 10.1.1? The upgrade solved a few quirky issues we were having, so might be worth a try.
Also, if you have access to ArcGIS Server, try publishing a GP service and calling that from your Runtime app. (In my case the full AGS GP service worked, when the local GPK failed.)
... the tool runs fine if I don't specify the Fields collection. But then the output doesn't contain the fields of the input features; it contains the fields of the schema set in the GPK; which is the problem I'm trying to resolve.!
/* * Build the GP Parameters... */ // We want to specify input attributes - create a new FeatureSet. FeatureSet featureSet = new FeatureSet(); // Create the Fields and add one called "VALUE". featureSet.Fields = new List<Field> { new Field() { FieldName = "VALUE", Type = Field.FieldType.String, Alias = "VALUE" } }; // Create the graphic to submit. Graphic g = new Graphic() { Geometry = _mercator.ToGeographic(e.MapPoint) }; // Add the graphic to the FeatureSet featureSet.Features.Add(g); // Set the graphic's attribute featureSet.Features[0].Attributes["VALUE"] = "Hello"; // Create a new list of GPParameters List<GPParameter> parameters = new List<GPParameter>(); // Add a new GPFeatureRecordSetLayer to the parameter list, passing in the FeatureSet created above. parameters.Add(new GPFeatureRecordSetLayer("Input_Features",featureSet)); // Handler for the completed event _gpTask.ExecuteCompleted += (s, e1) => { //OutputCopyFeatures GPExecuteResults results = e1.Results; GPFeatureRecordSetLayer rs = results.OutParameters[0] as GPFeatureRecordSetLayer; // Check the attributes... output feature should have attribute Field "VALUE" with value "Hello". };
var featureSet = new FeatureSet(); var layer = GetSelectedInputLayer(); featureSet.Fields = new List<Field>((layer as FeatureLayer).LayerInfo.Fields); foreach (var graphic in layer.SelectedGraphics) { featureSet.Features.Add(graphic); } parameters.Add(new GPFeatureRecordSetLayer("InputFeatures", featureSet)); parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMeters, Convert.ToDouble(distanceText.Text)));
public static ICollection<Field> GetFields(Graphic graphic) { var fields = new List<Field>(); foreach (var attribute in graphic.Attributes.Keys) { fields.Add(new Field() { FieldName = attribute, Type = Field.FieldType.Unknown, Alias = attribute }); } return fields; } public static ICollection<Field> GetFields(Layer layer) { if (layer is FeatureLayer) { var featureLayer = layer as FeatureLayer; if (featureLayer.LayerInfo != null) { return featureLayer.LayerInfo.Fields; } else if (featureLayer.Graphics.Count > 0) { return GetFields(featureLayer.Graphics[0]); } } else if (layer is GraphicsLayer) { var graphicsLayer = layer as GraphicsLayer; if (graphicsLayer.Graphics.Count > 0) { return GetFields(graphicsLayer.Graphics[0]); } } return new List<Field>(); }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.