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; }
Charles,Have you checked the code under ArcGIS Runtime SDK for WPF samples (desktop application )?Under - Geometry -> Geometry operations -> Buffer a point Similar to what Mike suggested.Does this help for your requirement?
Though note that the graphics returned by the service don't include the attributes. However the returned graphics are always in the same order as the input graphics so you can easily retrieve the attributes from the input graphics.
That doesn't make sense to me. If I want a buffer of N kms around X features, I want the results to also contain features outside of those X features but within the buffer distance. In other words, the results should have X or more features.
//Create a new Geoprocessor object Geoprocessor gp = new Geoprocessor(_localGPService.UrlGeoprocessingService + "/Buffer"); //Create a new List of type GPParameter to hold the parameters for the service List<GPParameter> parameters = new List<GPParameter>(); //Create a new GP FeaturerecordSetLayer with parameter name GPFeatureRecordSetLayer gpFeatureRecordSetLayer = new GPFeatureRecordSetLayer("Input_Locations"); //Add the GpFeatureRecordSetLayer to the parameter list parameters.Add(gpFeatureRecordSetLayer);
The architecture of the Runtime SDK is different to ArcEngine and Desktop, so you have to adjust your workflows (and GP models/scripts!) to suit the service-oriented architecture. (Also, be aware that not all GP tools are supported in the Runtime local geoprocessor and there are some limitations in terms of the size of the datasets you send to the GP service - you can adjust the output, but the input seems to be fixed at 1000 records from the work I have done.)Having said that, ArcGIS 10.1 uses some kind of Runtime local service to perform background geoprocessing on "standard" GP tools (i.e. no GPK is required), so I think there is merit to your initial question.
Now this is the part I dont know enough about in Runtime: if you have the same notion of layers in Runtime as you do in ArcMap, I'd say its conceivable that those layers could be passed to the "gp service" (ie the geoprocessing task runtime has spun up).So if you know the answer to the "layer" question, and its "yes", then I'd suspect you could pass that layer into the GP parameter within the applications code and it should act upon it.Your note about the runtime local service for background in desktop: True again. Note though: Well, yes they share common components and the same name - they do not equal one another. Background server in Desktop has zero interaction with a Runtime application. Basically I dont want you to confuse that just because you can do something in Desktop+Background you could potentially do the same in Runtime.
Hi Kevin,I wouldn't say layers in Desktop and Runtime are the same from my experience, but I've set up a few local GP services that *only* consume data from the application (both feature service and graphics layers) and I think you are correct about FeatureSets being the key. It took me a while to figure this out when I started using the Runtime SDK, and even though the documentation is more complete now than during the beta and pre-release, it could be made more obvious for folk coming from Desktop/ArcEngine or those with complicated projects that go beyond the GP samples.
Yes, I figured as much when I couldn't see a REST endpoint or anything in Fiddler, but it would be quite cool if this was opened up in the future as I have been frustrated with some GP tools not being available with the Runtime SDK. ArcPy gets better with every release, so some missing tools can be replaced with scripts, but it would be great if ArcInfo-level tools were supported in the Runtime. (But I guess this would contradict the intended purpose of the Runtime and you would be better to use something else from the ESRI stack.)
Let me see if I understand what you're saying.I can use ArcMap to create a GPK with only the set of tools that I need, and I can have the geometry passed through a GP parameter when executing the tool.Is this accurate?
You'll have to run the tool to get a result to turn into a GPK...
Bad request: POST GPServer/BufferModel/execute The 'execute' operation is not supported.
Unable to complete operation.
[0] = "Error executing tool.: ERROR 000800: The value is not a member of parcels."
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>());
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
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);
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).
{ "geometryType" : "esriGeometryPoint", "spatialReference" : {"wkid" : 4326}, "fields":[ {"name":"Id","type":"esriFieldTypeOID","alias":"Id"}, {"name":"Name","type":"esriFieldTypeString","alias":"Name"} ], "features" : [ { "geometry" : {"x" : -104.44, "y" : 34.83}, "attributes" : {"Id" : 43, "Name" : "Feature 1"} }, { "geometry" : {"x" : -100.65, "y" : 33.69}, "attributes" : {"Id" : 67, "Name" : "Feature 2"} } ] }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.