当前位置: 首页>>代码示例>>C#>>正文


C# Geoprocessor.GetResultDataAsync方法代码示例

本文整理汇总了C#中Geoprocessor.GetResultDataAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.GetResultDataAsync方法的具体用法?C# Geoprocessor.GetResultDataAsync怎么用?C# Geoprocessor.GetResultDataAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geoprocessor的用法示例。


在下文中一共展示了Geoprocessor.GetResultDataAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartGP_Click

        private async void StartGP_Click(object sender, RoutedEventArgs e)
        {
            StartGP.IsEnabled = false;
            ClearGraphics();
            ClearButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            ProcessingTextBlock.Visibility = Visibility.Collapsed;

            var inputPolyline = await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline);

            var inputGraphic = new Graphic { Geometry = inputPolyline };
            GraphicsLayer inputLayer = mapView1.Map.Layers["InputLayer"] as GraphicsLayer;
            inputLayer.Graphics.Add(inputGraphic);

            MyProgressRing.Visibility = Visibility.Visible;
            MyProgressRing.IsActive = true;

            string message = null;

            Geoprocessor task = new Geoprocessor(new Uri(ServiceUri));
            var inputParameter = new GPInputParameter();
            inputParameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPolyline));
            inputParameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, Int32.Parse(DistanceTextBox.Text)));
            try
            {
                //Submit the job and await the results
                var gpJobInfo = await task.SubmitJobAsync(inputParameter);

                //Poll the server every 5 seconds for the status of the job.
                //Cancelled, Cancelling, Deleted, Deleting, Executing, Failed, New, Submitted, Succeeded, TimedOut, Waiting
                while (gpJobInfo.JobStatus != GPJobStatus.Cancelled &&
                    gpJobInfo.JobStatus != GPJobStatus.Deleted &&
                     gpJobInfo.JobStatus != GPJobStatus.Failed &&
                     gpJobInfo.JobStatus != GPJobStatus.Succeeded &&
                     gpJobInfo.JobStatus != GPJobStatus.TimedOut)
                {
                    gpJobInfo = await task.CheckJobStatusAsync(gpJobInfo.JobID);
                    await Task.Delay(5000);

                }

                //Now that the job is completed, check whether the service returned the results as Features or as a GPResultImageLayer.
                //This can happen if the number of features to return exceeds the limit set on the service
                if (gpJobInfo.JobStatus == GPJobStatus.Succeeded)
                {
                    var resultData = await task.GetResultDataAsync(gpJobInfo.JobID, "Clipped_Counties");
                    if (resultData is GPFeatureRecordSetLayer)
                    {
                        GPFeatureRecordSetLayer gpLayer = resultData as GPFeatureRecordSetLayer;
                        if (gpLayer.FeatureSet.Features.Count == 0)
                        {
                            var resultImageLayer = await task.GetResultImageLayerAsync(gpJobInfo.JobID, "Clipped_Counties");
                            GPResultImageLayer gpImageLayer = resultImageLayer;
                            gpImageLayer.Opacity = 0.5;
                            mapView1.Map.Layers.Add(gpImageLayer);
                            ProcessingTextBlock.Visibility = Visibility.Visible;
                            ProcessingTextBlock.Text = "Greater than 500 features returned.  Results drawn using map service.";
                            return;
                        }
                        GraphicsLayer resultLayer = mapView1.Map.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
                        foreach (Graphic g in gpLayer.FeatureSet.Features)
                        {
                            resultLayer.Graphics.Add(g);
                        }
                    }
                }
                MyProgressRing.Visibility = Visibility.Collapsed;
                MyProgressRing.IsActive = false;

                ClearButton.Visibility = Visibility.Visible;
                StartGP.IsEnabled = true;

            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            if (message != null)
                await new MessageDialog(message, "GP Failed").ShowAsync();


        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:82,代码来源:ClipFeatures.xaml.cs

示例2: StartButton_Click

		private async void StartButton_Click(object sender, RoutedEventArgs e)
		{
			StartButton.IsEnabled = false;
			ClearResultsButton.Visibility = Visibility.Collapsed;

			//get the user's input point
			var inputPoint = await MyMapView.Editor.RequestPointAsync();

			//update UI elements
			MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
			MyProgressRing.IsActive = true;

			viewshedLayer.Graphics.Clear();

			inputLayer.Graphics.Clear();
			inputLayer.Graphics.Add(new Graphic() { Geometry = inputPoint });

			Geoprocessor task = new Geoprocessor(new Uri("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel"));

			var parameter = new GPInputParameter()
			{
				OutSpatialReference = new SpatialReference(102100)
			};
			parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputPoint));
			parameter.GPParameters.Add(new GPString("Height", HeightTextBox.Text));
			parameter.GPParameters.Add(new GPLinearUnit("Distance", LinearUnits.Miles, Convert.ToDouble(MilesTextBox.Text)));


			var result = await task.SubmitJobAsync(parameter);

			//Poll the server for results every 2 seconds.
			while (result.JobStatus != GPJobStatus.Cancelled && result.JobStatus != GPJobStatus.Deleted &&
				 result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.TimedOut)
			{
				result = await task.CheckJobStatusAsync(result.JobID);

				//show the status
				StatusTextBlock.Text = string.Join(Environment.NewLine, result.Messages.Select(x => x.Description));


				await Task.Delay(2000);
			}
			if (result.JobStatus == GPJobStatus.Succeeded)
			{
				//get the results as a ArcGISDynamicMapServiceLayer
				StatusTextBlock.Text = "Finished processing. Retrieving results...";                
				var viewshedResult = await task.GetResultDataAsync(result.JobID, "View") as GPFeatureRecordSetLayer;
				var rangeResult = await task.GetResultDataAsync(result.JobID, "Range") as GPFeatureRecordSetLayer;

				if (viewshedResult != null && viewshedResult.FeatureSet != null && viewshedResult.FeatureSet.Features != null)
				{
					foreach (var feature in viewshedResult.FeatureSet.Features)
					{
						viewshedLayer.Graphics.Add((Graphic)feature);
					}
				}

				//Reset the UI
				StatusTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
				StartButton.IsEnabled = true;
				ClearResultsButton.Visibility = Visibility.Visible;
				MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
				MyProgressRing.IsActive = false;
			}
		}
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:65,代码来源:Viewshed.xaml.cs

示例3: MyMap_MouseClick

        void MyMap_MouseClick(object sender, Map.MouseEventArgs e)
        {
            /*
             * Add a graphic at the user input location
             */
            MyMap.MouseClick -= MyMap_MouseClick;

            if (inputGraphicsLayer == null)
            {
                inputGraphicsLayer = new GraphicsLayer();
                MyMap.Layers.Add(inputGraphicsLayer);
            }

            // Add a Graphic at the click point
            Graphic graphic = new Graphic()
            {
                Symbol = MainGrid.Resources["IncidentMarkerSymbol"] as Symbol,
                Geometry = e.MapPoint
            };
            inputGraphicsLayer.Graphics.Add(graphic);

            /*
             * Reproject the mouseclick into the GP coordinate system
             */
            // Declare the ProjectCompleted Handler
            EventHandler<GraphicsEventArgs> ProjectCompletedHandler = null;

            // Handle the event
            ProjectCompletedHandler = (sender2, graphicsEventArgs) =>
            {
                // Unregister the handler
                geometryTask.ProjectCompleted -= ProjectCompletedHandler;

                // Cancel any existing Jobs
                geoprocessorTask.CancelAsync();

                // Handle the JobCompleted
                geoprocessorTask.JobCompleted += (sender3, jobInfoEventArgs) =>
                {
                    // Check whether it succeeded
                    if (jobInfoEventArgs.JobInfo.JobStatus != esriJobStatus.esriJobSucceeded)
                    {
                        //Do Something
                    };

                    /*
                     * Create two new Geoprocessor Tasks to fetch the result data (thereby allowing them to run concurrently)
                     * Each will use the same event handler and we'll choose based on the Parameter Name.
                     * Alternatively could use the overload which takes an object (userToken).
                     */
                    Geoprocessor gpTaskSysvalves_Layer =
                        new Geoprocessor(traceNetworkLocalGpService.Tasks[0].Url);

                    gpTaskSysvalves_Layer.GetResultDataCompleted
                        += geoprocessorTask_GetResultDataCompleted;

                    gpTaskSysvalves_Layer.GetResultDataAsync(
                        jobInfoEventArgs.JobInfo.JobId, "Sysvalves_Layer");

                    Geoprocessor gpTaskDistribMains_Layer =
                        new Geoprocessor(traceNetworkLocalGpService.Tasks[0].Url);

                    gpTaskDistribMains_Layer.GetResultDataCompleted
                        += geoprocessorTask_GetResultDataCompleted;

                    gpTaskDistribMains_Layer.GetResultDataAsync(
                        jobInfoEventArgs.JobInfo.JobId, "DistribMains_Layer");
                };

                // Create the GP Parameter List
                List<GPParameter> parameters = new List<GPParameter>();
                parameters.Add(new GPFeatureRecordSetLayer("Flags", graphicsEventArgs.Results[0].Geometry));
                geoprocessorTask.SubmitJobAsync(parameters);
            };
            // Register the handler for the ProjectCompleted event.
            geometryTask.ProjectCompleted += ProjectCompletedHandler;

            // Project the input point into the coordinate system of the data
            geometryTask.ProjectAsync(new List<Graphic>()
            {
                new Graphic()
                {
                    Geometry = e.MapPoint
                }
            },
            waterNetworkLocalMapService.SpatialReference);
        }
开发者ID:GlenDhu,项目名称:tips-and-tricks-wpf,代码行数:87,代码来源:MainWindow.xaml.cs

示例4: getInputLineAndClip

        // Waits for the user to draw a line, then performs the buffer and clip operation
        private async void getInputLineAndClip()
        {
            if (m_firstPointAdded)
                return;

            // Get line from user
            var clipLine = await Editor.RequestShapeAsync(DrawShape.Polyline,
                new SimpleLineSymbol() { Color = Colors.Red, Width = 2, Style = SimpleLineStyle.Dash });
            ClipLines.Add(new Graphic() { Geometry = clipLine });

            // Show busy UI
            BusyVisibility = Visibility.Visible;
            StatusText = "Executing...";

            string error = null;

            // Initialize the Geoprocessing task with the buffer and clip service endpoint
            Geoprocessor task = new Geoprocessor(new Uri("http://serverapps10.esri.com/ArcGIS/rest/services/SamplesNET/" +
                "USA_Data_ClipTools/GPServer/ClipCounties"));

            // Initialize input parameters
            var parameter = new GPInputParameter()
            {
                OutSpatialReference = SpatialReferences.WebMercator
            };
            parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", clipLine)); // input geometry
            parameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, BufferDistance)); // buffer distance
            try
            {
                // Submit the job and await the results
                var result = await task.SubmitJobAsync(parameter);

                // Poll the server every two seconds for the status of the job.
                while (result.JobStatus != GPJobStatus.Cancelled
                    && result.JobStatus != GPJobStatus.Deleted
                    && result.JobStatus != GPJobStatus.Failed
                    && result.JobStatus != GPJobStatus.Succeeded
                    && result.JobStatus != GPJobStatus.TimedOut)
                {
                    result = await task.CheckJobStatusAsync(result.JobID);

                    // show the status
                    var descriptions = result.Messages.Select(msg => msg.Description);
                    var status = string.Join(Environment.NewLine, descriptions);
                    if (!string.IsNullOrEmpty(status))
                        StatusText = status;

                    await Task.Delay(2000);
                }

                if (result.JobStatus == GPJobStatus.Succeeded)
                {
                    // Get the results
                    var resultData = await task.GetResultDataAsync(result.JobID, "Clipped_Counties");
                    if (resultData is GPFeatureRecordSetLayer)
                    {
                        GPFeatureRecordSetLayer resultsLayer = resultData as GPFeatureRecordSetLayer;
                        if (resultsLayer.FeatureSet != null
                            && resultsLayer.FeatureSet.Features != null
                            && resultsLayer.FeatureSet.Features.Count != 0)
                        {
                            // Results were returned as graphics.  Add them to the ClippedCounties collection
                            ClippedCounties = new ObservableCollection<Graphic>(resultsLayer.FeatureSet.Features);
                        }
                        else // Try to get results as a GPResultImageLayer
                        {
                            StatusText = "Clip operation complete. Retrieving results...";

                            m_clippedCountiesLayer = await task.GetResultImageLayerAsync(result.JobID, "Clipped_Counties");

                            // If successful, add the layer to the layers collection
                            if (m_clippedCountiesLayer != null)
                            {
                                m_clippedCountiesLayer.Opacity = 0.5;

                                // Insert the layer below the input layer
                                Layers.Insert(Layers.IndexOf(m_clipLinesLayer), m_clippedCountiesLayer);

                                // Wait until the result layer is initialized
                                await m_clippedCountiesLayer.InitializeAsync();
                            }
                            else
                            {
                                error = "No results found";
                            }
                        }
                    }
                    else
                    {
                        error = "Clip operation failed";
                    }
                }
                else
                {
                    error = "Clip operation failed";
                }
            }
            catch (Exception ex)
            {
//.........这里部分代码省略.........
开发者ID:rlwarford,项目名称:arcgis-runtime-samples-dotnet,代码行数:101,代码来源:Clip.xaml.cs

示例5: gp_JobCompleted

 void gp_JobCompleted(object sender, Client.Tasks.JobInfoEventArgs e)
 {
     if (e.JobInfo.JobStatus == esriJobStatus.esriJobFailed)
     {
         IsExecuting = false;
         ExecutingText = ESRI.ArcGIS.Mapping.GP.Resources.Strings.JobFailed;
         asyncErrors.AddRange(e.JobInfo.Messages.Where(p => p.MessageType == GPMessageType.Error).Select(p => new Exception(p.Description)));
         fireAsyncCompleteEvent();
     }
     else
     {
         ExecutingText = ESRI.ArcGIS.Mapping.GP.Resources.Strings.GettingResults;
         asyncResultsExpected = Configuration.OutputParameters.Count;
         JobID = e.JobInfo.JobId;
         foreach (ParameterSupport.ParameterConfig param in Configuration.OutputParameters)
         {
             if (!resultRequestedParams.Contains(param.Name))
             {
                 if (param.Type == GPParameterType.MapServiceLayer)
                 {
                     asyncResultsExpected--;
                     asyncResults.Add(null);
                     if (asyncResultsExpected == 0)
                         fireAsyncCompleteEvent();
                 }
                 else
                 {
                     Geoprocessor gp = new Geoprocessor(ServiceEndpoint.AbsoluteUri);
                     gp.Failed += gp_FailedAsync;
                     gp.GetResultDataCompleted += gp2_GetResultDataCompleted;
                     // Initialize proxy
                     gp.ProxyURL = Configuration.UseProxy ? Configuration.ProxyUrl : null;
                     gp.GetResultDataAsync(e.JobInfo.JobId, param.Name);
                 }
             }
         }
     }
 }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:38,代码来源:GPWidget.cs

示例6: Clip

        public async void Clip()
        {
            // get the local GP server's URL
            this.gpUrl = this.localGPService.UrlGeoprocessingService;

            // start the GP 
            this.gpTask = new Geoprocessor(new Uri(this.gpUrl + "/ClipFeatures"));

            //get the user's input line
            var inputLine = await this.mapView.Editor.RequestShapeAsync(DrawShape.Polyline) as Polyline;

            // clear the graphics layers
            this.resultGraphicsLayer.Graphics.Clear();
            this.inputGraphicsLayer.Graphics.Clear();

            // add new graphic to layer
            this.inputGraphicsLayer.Graphics.Add(new Graphic { Geometry = inputLine, Symbol = this.simpleInputLineSymbol });

            // add the parameters
            var parameter = new GPInputParameter();
            parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input", inputLine));
            parameter.GPParameters.Add(new GPLinearUnit("Linear_Unit", LinearUnits.Miles, this.Distance));

            // poll the task
            var result = await SubmitAndPollStatusAsync(parameter);

            // add successful results to the map
            if (result.JobStatus == GPJobStatus.Succeeded)
            {
                this.Status = "Finished processing. Retrieving results...";

                var resultData = await gpTask.GetResultDataAsync(result.JobID, "Clipped_Counties");
                if (resultData is GPFeatureRecordSetLayer)
                {
                    GPFeatureRecordSetLayer gpLayer = resultData as GPFeatureRecordSetLayer;
                    if (gpLayer.FeatureSet.Features.Count == 0)
                    {
                        // the the map service results
                        var resultImageLayer = await gpTask.GetResultImageLayerAsync(result.JobID, "Clipped_Counties");

                        // make the result image layer opaque
                        GPResultImageLayer gpImageLayer = resultImageLayer;
                        gpImageLayer.Opacity = 0.5;
                        this.mapView.Map.Layers.Add(gpImageLayer);
                        this.Status = "Greater than 500 features returned.  Results drawn using map service.";
                        return;
                    }

                    // get the result features and add them to the GraphicsLayer
                    var features = gpLayer.FeatureSet.Features;
                    foreach (Feature feature in features)
                    {
                        this.resultGraphicsLayer.Graphics.Add(feature as Graphic);
                    }
                  
                }
                this.Status = "Success!!!";
            }

        }
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:60,代码来源:ClipViewModel.cs


注:本文中的Geoprocessor.GetResultDataAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。