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


C# Geoprocessor.ExecuteAsync方法代码示例

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


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

示例1: FeatureLayerChangeVersion

        public FeatureLayerChangeVersion()
        {
            InitializeComponent();

            featureLayer = (MyMap.Layers["ServiceConnections"] as FeatureLayer);

            Geoprocessor gp_ListVersions = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/GDBVersions/GPServer/ListVersions");

            gp_ListVersions.Failed += (s, a) =>
            {
                MessageBox.Show("Geoprocessing service failed: " + a.Error);
            };

            gp_ListVersions.ExecuteCompleted += (c, d) =>
            {
                VersionsCombo.DataContext = (d.Results.OutParameters[0] as GPRecordSet).FeatureSet;

                foreach (Graphic g in (d.Results.OutParameters[0] as GPRecordSet).FeatureSet.Features)
                {
                    if ((g.Attributes["name"] as string) == featureLayer.GdbVersion)
                    {
                        VersionsCombo.SelectedValue = g;
                        break;
                    }
                }
            };

            List<GPParameter> gpparams = new List<GPParameter>();
            gpparams.Add(new GPRecordSet("Versions", new FeatureSet()));
            gp_ListVersions.ExecuteAsync(gpparams);
        }
开发者ID:Esri,项目名称:arcgis-samples-winphone,代码行数:31,代码来源:FeatureLayerChangeVersion.xaml.cs

示例2: ClipRaster

        public static void ClipRaster(string inRaster, string inClipFeature, string outTempRaster)
        {
            Clip clipTool = new Clip();

            //set clip parameters
            clipTool.in_raster = inRaster;
            clipTool.out_raster = outTempRaster;

            //clip extent
            clipTool.in_template_dataset = inClipFeature;

            Geoprocessor gp = new Geoprocessor();
            gp.OverwriteOutput = true;
            gp.AddOutputsToMap = false;

            try
            {

               IGeoProcessorResult result = (IGeoProcessorResult)gp.ExecuteAsync(clipTool);

               while(result.Status != esriJobStatus.esriJobSucceeded)
               {
                   //Console.WriteLine(result.Status.ToString());
                   System.Threading.Thread.Sleep(100);
               }

            }
            catch (Exception ex)
            {
                object level = 0;
                Console.WriteLine(gp.GetMessages(ref level));
                Console.WriteLine(" Failed to clip raster using ESRI clip tool " + ex.Message);
            }
        }
开发者ID:alamsal,项目名称:GDAL_UTILS_Csharp,代码行数:34,代码来源:ClipRasterBoundaryEsri.cs

示例3: MyMapView_MapViewTapped

		private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
		{
			// Convert screen point to map point
			var mapPoint = MyMapView.ScreenToLocation(e.Position);
			var layer = MyMapView.Map.Layers["InputLayer"] as GraphicsLayer;
			layer.Graphics.Clear();
			layer.Graphics.Add(new Graphic() { Geometry = mapPoint });

			string error = null;
			Geoprocessor task = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons"));

			var parameter = new GPInputParameter();

			parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", mapPoint));
			parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));

			try
			{
				var result = await task.ExecuteAsync(parameter);
				var r = MyMapView.Map.Layers["ResultLayer"] as GraphicsLayer;
				r.Graphics.Clear();
				foreach (GPParameter gpParameter in result.OutParameters)
				{
					if (gpParameter is GPFeatureRecordSetLayer)
					{
						GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
						List<Esri.ArcGISRuntime.Symbology.Symbol> bufferSymbols = new List<Esri.ArcGISRuntime.Symbology.Symbol>(
							  new Esri.ArcGISRuntime.Symbology.Symbol[] { LayoutRoot.Resources["FillSymbol1"] as Esri.ArcGISRuntime.Symbology.Symbol, 
								  LayoutRoot.Resources["FillSymbol2"] as Esri.ArcGISRuntime.Symbology.Symbol, 
								  LayoutRoot.Resources["FillSymbol3"] as Esri.ArcGISRuntime.Symbology.Symbol });

						int count = 0;
						foreach (Graphic graphic in gpLayer.FeatureSet.Features)
						{
							graphic.Symbol = bufferSymbols[count];
							graphic.Attributes.Add("Info", String.Format("{0} minute buffer ", 3 - count));
							r.Graphics.Add(graphic);
							count++;
						}
					}
				}
			}
			catch (Exception ex)
			{
				error = "Geoprocessor service failed: " + ex.Message;
			}
			if (error != null)
				await new MessageDialog(error).ShowAsync();
		}
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:49,代码来源:DriveTimes.xaml.cs

示例4: FeatureLayerChangeVersion

        public FeatureLayerChangeVersion()
        {
            InitializeComponent();
              Geoprocessor gp_ListVersions = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/GDBVersions/GPServer/ListVersions");

              gp_ListVersions.Failed += (s, a) =>
              {
            MessageBox.Show("Geoprocessing service failed: " + a.Error);
              };

              gp_ListVersions.ExecuteCompleted += (c, d) =>
              {
            VersionsCombo.DataContext = (d.Results.OutParameters[0] as GPRecordSet).FeatureSet;
            VersionsCombo.SelectedIndex = 0;
              };

              List<GPParameter> gpparams = new List<GPParameter>();
              gpparams.Add(new GPRecordSet("Versions", new FeatureSet()));
              gp_ListVersions.ExecuteAsync(gpparams);
        }
开发者ID:konglingjie,项目名称:arcgis-samples-silverlight,代码行数:20,代码来源:FeatureLayerChangeVersion.xaml.cs

示例5: MyMap_MouseClick

        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Graphic graphic = new Graphic()
            {
                Symbol =  LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                Geometry = e.MapPoint
            };
            _graphicsLayer.Graphics.Add(graphic);

            Geoprocessor geoprocessorTask = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle");
            geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
            geoprocessorTask.Failed += GeoprocessorTask_Failed;
            geoprocessorTask.OutputSpatialReference = MyMap.SpatialReference;

            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPFeatureRecordSetLayer("Input_Point", _mercator.ToGeographic(e.MapPoint)));
            parameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

            geoprocessorTask.ExecuteAsync(parameters);
        }
开发者ID:konglingjie,项目名称:arcgis-samples-silverlight,代码行数:20,代码来源:MessageInABottle.xaml.cs

示例6: MyMapView_Tapped

       private async void MyMapView_Tapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
       {
           try
           {
               Progress.Visibility = Visibility.Visible;

               
               _inputOverlay.Graphics.Clear();
               _inputOverlay.Graphics.Add(new Graphic() { Geometry = e.Location });

               Geoprocessor geoprocessorTask = new Geoprocessor(new Uri(MessageInABottleServiceUrl));

               var parameter = new GPInputParameter() { OutSpatialReference = MyMapView.SpatialReference };
			   var ptNorm = GeometryEngine.NormalizeCentralMeridian(e.Location);
               var ptGeographic = GeometryEngine.Project(ptNorm, SpatialReferences.Wgs84) as MapPoint;

               parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Point", ptGeographic));
               parameter.GPParameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

               var result = await geoprocessorTask.ExecuteAsync(parameter);

               _resultsOverlay.Graphics.Clear();

               foreach (GPParameter gpParameter in result.OutParameters)
               {
                   if (gpParameter is GPFeatureRecordSetLayer)
                   {
                       GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                       _resultsOverlay.Graphics.AddRange(gpLayer.FeatureSet.Features.OfType<Graphic>());
                   }
               }
           }
           catch (Exception ex)
           {
               var _x = new MessageDialog("Geoprocessor service failed: " + ex.Message, "Sample Error").ShowAsync();
           }
           finally
           {
               Progress.Visibility = Visibility.Collapsed;
           }
       }
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:41,代码来源:MessageInABottle.xaml.cs

示例7: mapView_MapViewTapped

        // Begin geoprocessing with a user tap on the map
        private async void mapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
        {
            try
            {
                Progress.Visibility = Visibility.Visible;

                InputLayer.Graphics.Clear();
                InputLayer.Graphics.Add(new Graphic() { Geometry = e.Location });

                Geoprocessor geoprocessorTask = new Geoprocessor(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle"));

                var parameter = new GPInputParameter() { OutSpatialReference = mapView.SpatialReference };
                var ptNorm = GeometryEngine.NormalizeCentralMeridianOfGeometry(e.Location);
                var ptGeographic = GeometryEngine.Project(ptNorm, SpatialReferences.Wgs84) as MapPoint;

                parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Point", ptGeographic));
                parameter.GPParameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

                var result = await geoprocessorTask.ExecuteAsync(parameter);

                ResultLayer.Graphics.Clear();
                foreach (GPParameter gpParameter in result.OutParameters)
                {
                    if (gpParameter is GPFeatureRecordSetLayer)
                    {
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        ResultLayer.Graphics.AddRange(gpLayer.FeatureSet.Features);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Geoprocessor service failed: " + ex.Message, "Sample Error");
            }
            finally
            {
                Progress.Visibility = Visibility.Collapsed;
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:41,代码来源:MessageInABottle.xaml.cs

示例8: mapView1_Tapped

	   private async void mapView1_Tapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
		{            
			var mapPoint = e.Location;
			var l = mapView1.Map.Layers["InputLayer"] as GraphicsLayer;
			l.Graphics.Clear();
			l.Graphics.Add(new Graphic() { Geometry = mapPoint });
			string error = null;
			Geoprocessor geoprocessorTask = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle"));

			var parameter = new GPInputParameter()
			{
				OutSpatialReference = mapView1.SpatialReference
			};
			var toGeographic = GeometryEngine.Project(mapPoint, new SpatialReference(4326)) as MapPoint;

			parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Point", toGeographic));
			parameter.GPParameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

			try
			{
				var result = await geoprocessorTask.ExecuteAsync(parameter);
				var r = mapView1.Map.Layers["ResultLayer"] as GraphicsLayer;
				r.Graphics.Clear();
				foreach (GPParameter gpParameter in result.OutParameters)
				{
					if (gpParameter is GPFeatureRecordSetLayer)
					{
						GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
						r.Graphics.AddRange(gpLayer.FeatureSet.Features.OfType<Graphic>());
					}
				}
			}
			catch (Exception ex)
			{
				error = "Geoprocessor service failed: " + ex.Message;
			}
			if (error != null)
				await new MessageDialog(error).ShowAsync();
		}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:39,代码来源:MessageInABottle.xaml.cs

示例9: SummarizePopulationButton_Click

        // Accept user boundary line and run the Geoprocessing Task to summarize population
        private async void SummarizePopulationButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                txtResult.Visibility = System.Windows.Visibility.Collapsed;
                AreaLayer.Graphics.Clear();

                var boundary = await mapView.Editor.RequestShapeAsync(DrawShape.Freehand) as Polyline;
                var polygon = new Polygon(boundary, mapView.SpatialReference);
                polygon = GeometryEngine.Simplify(polygon) as Polygon;
                AreaLayer.Graphics.Add(new Graphic() { Geometry = polygon });

                progress.Visibility = Visibility.Visible;

                Geoprocessor geoprocessorTask = new Geoprocessor(
                    new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary"));

                var parameter = new GPInputParameter() { OutSpatialReference = mapView.SpatialReference };
                parameter.GPParameters.Add(new GPFeatureRecordSetLayer("inputPoly", polygon));

                var result = await geoprocessorTask.ExecuteAsync(parameter);

                GPRecordSet rs = result.OutParameters.OfType<GPRecordSet>().FirstOrDefault();
                if (rs != null && rs.FeatureSet.Features != null)
                {
                    int population = Convert.ToInt32(rs.FeatureSet.Features[0].Attributes["SUM"]);
                    txtResult.Visibility = System.Windows.Visibility.Visible;
                    txtResult.Text = string.Format("Area Population: {0:N0}", population);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Geoprocessor service failed: " + ex.Message, "Sample Error");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:40,代码来源:PopulationForArea.xaml.cs

示例10: SummarizePopulationButton_Click

		// Accept user boundary line and run the Geoprocessing Task to summarize population
		private async void SummarizePopulationButton_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				txtResult.Visibility = Visibility.Collapsed;
				_areaOverlay.Graphics.Clear();

				var boundary = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand) as Polyline;
				var polygon = new Polygon(boundary.Parts, MyMapView.SpatialReference);
				polygon = GeometryEngine.Simplify(polygon) as Polygon;
				_areaOverlay.Graphics.Add(new Graphic() { Geometry = polygon });

				progress.Visibility = Visibility.Visible;

				Geoprocessor geoprocessorTask = new Geoprocessor(new Uri(PopulationSummaryServiceUrl));

				var parameter = new GPInputParameter() { OutSpatialReference = MyMapView.SpatialReference };
				parameter.GPParameters.Add(new GPFeatureRecordSetLayer("inputPoly", polygon));

				var result = await geoprocessorTask.ExecuteAsync(parameter);

				GPRecordSet rs = result.OutParameters.OfType<GPRecordSet>().FirstOrDefault();
				if (rs != null && rs.FeatureSet.Features != null)
				{
					int population = Convert.ToInt32(rs.FeatureSet.Features[0].Attributes["SUM"]);
					txtResult.Visibility = Visibility.Visible;
					txtResult.Text = string.Format("Area Population: {0:N0}", population);
				}
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
			finally
			{
				progress.Visibility = Visibility.Collapsed;
			}
		}
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:39,代码来源:PopulationForArea.xaml.cs

示例11: 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 gpTask = new Geoprocessor(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed"));

			var parameter = new GPInputParameter() { OutSpatialReference = SpatialReferences.WebMercator };
			parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Observation_Point", inputPoint));
			parameter.GPParameters.Add(new GPLinearUnit("Viewshed_Distance ", LinearUnits.Miles, Convert.ToDouble(MilesTextBox.Text)));

			var result = await gpTask.ExecuteAsync(parameter);

			if (result == null || result.OutParameters == null || !(result.OutParameters[0] is GPFeatureRecordSetLayer))
				throw new Exception("No viewshed graphics returned for this start point.");

			var viewshedResult = result.OutParameters[0] as GPFeatureRecordSetLayer;
			viewshedLayer.Graphics.AddRange(viewshedResult.FeatureSet.Features.OfType<Graphic>());

			//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:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:38,代码来源:Viewshed.xaml.cs

示例12: mapView1_Tap

        // On tap, get an input line and perform a buffer and clip operation
       private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
        {
            if (BusyVisibility == Visibility.Visible)
            {
                MessageBox.Show("Please wait until the current operation is complete.");
                return;
            }

            // Show busy UI
            BusyVisibility = Visibility.Visible;

            // Clear previous results
            TapPoints.Clear();
            Currents.Clear();

          

            // Create graphic and add to tap points
            var g = new Graphic() { Geometry = e.Location };
            TapPoints.Add(g);

            string error = null;

            // Initialize the Geoprocessing task with the drive time calculation service endpoint
            Geoprocessor task = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Specialty/ESRI_Currents_World/GPServer/MessageInABottle"));

            // Initialize input parameters
            var parameter = new GPInputParameter()
                {
                    OutSpatialReference = SpatialReferences.WebMercator
                };

            var projectedMapPoint = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);
            parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Point", projectedMapPoint));
            parameter.GPParameters.Add(new GPDouble("Days", Days));

            try
            {
                // Run the operation
                var result = await task.ExecuteAsync(parameter);

                // Check that layers were returned from the operation
                var outputLayers = result.OutParameters.OfType<GPFeatureRecordSetLayer>();
                if (outputLayers.Count() > 0)
                {
                    // Get the first layer returned - this will be the drive time areas
                    var outputLayer = outputLayers.First();
                    if (outputLayer.FeatureSet != null && outputLayer.FeatureSet.Features != null)
                    {
                        // Instead of adding ocean current features one-by-one, update the collection all at once to
                        // allow the map to render the new features in one rendering pass.
                        Currents = new ObservableCollection<Graphic>(outputLayer.FeatureSet.Features);
                    }
                    else
                    {
                        error = "No results returned";
                    }
                }
                else
                {
                    error = "No results returned";
                }
            }
            catch (Exception ex)
            {
                error = "Calculation failed: " + ex.Message;
            }

            // If operation did not succeed, notify user
            if (error != null)
                MessageBox.Show(error);

            // Hide busy UI
            BusyVisibility = Visibility.Collapsed;
        }
开发者ID:rlwarford,项目名称:arcgis-runtime-samples-dotnet,代码行数:77,代码来源:OceanCurrents.xaml.cs

示例13: MyDrawObject_DrawComplete

        private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e)
        {
            MyDrawObject.IsEnabled = false;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                Geometry = e.Geometry as MapPoint
            };
            graphicsLayer.Graphics.Add(graphic);

            Geoprocessor geoprocessorTask = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Specialty/ESRI_Currents_World/GPServer/MessageInABottle");
            geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
            geoprocessorTask.Failed += GeoprocessorTask_Failed;

            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPFeatureRecordSetLayer("Input_Point", e.Geometry as MapPoint));
            parameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

            geoprocessorTask.ExecuteAsync(parameters);
        }
开发者ID:Esri,项目名称:arcgis-samples-winphone,代码行数:25,代码来源:MessageInABottle.xaml.cs

示例14: btnLookupWindDirection_Click

        // ***********************************************************************************
        // * ...Find the nearest Weather Station 
        // ***********************************************************************************
        private void btnLookupWindDirection_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_spillLocationGraphicsLayer.Graphics.Count > 0)
                {
                    List<GPParameter> parameters = new List<GPParameter>();

                    client.Projection.WebMercator wm = new client.Projection.WebMercator();
                    ESRI.ArcGIS.Client.Geometry.Geometry geoPoint = wm.ToGeographic(_spillLocationGraphicsLayer.Graphics[0].Geometry);

                    parameters.Add(new GPFeatureRecordSetLayer("Feature_Set", geoPoint));

                    Geoprocessor findNearestWSGPTask = new Geoprocessor(_findNearestWSURL);
                    findNearestWSGPTask.OutputSpatialReference = _mapWidget.Map.SpatialReference;

                    findNearestWSGPTask.ExecuteCompleted += findNearestWSGPTask_ExecuteCompleted;
                    findNearestWSGPTask.Failed += GeoprocessorTask_Failed;
                    findNearestWSGPTask.ExecuteAsync(parameters);
                }
                else
                {
                    MessageBox.Show("Please add the incident location on the map first!", "Warning");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                MessageBox.Show("Could not get wind direction!", "Error");
                return;
            }
        }
开发者ID:ruisebastiao,项目名称:solutions-widgets-wpf,代码行数:35,代码来源:ERGChemicalMapToolbar.xaml.cs

示例15: btnSolve_Click

        // ***********************************************************************************
        // * ...Execute Placard of ERG Chemical GP Tool 
        // ***********************************************************************************
        private void btnSolve_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_spillLocationGraphicsLayer.Graphics.Count > 0)
                {
                    Geoprocessor geoprocessorTask = new Geoprocessor();
                    if (cmbChemicalOrPlacardType.SelectedValue == null)
                    {
                        MessageBox.Show("Check your material or placard type!", "Error");
                        return;
                    }

                    var materialType = cmbChemicalOrPlacardType.SelectedValue.ToString();
                    var spillTime = cmbSpillTime.SelectedValue.ToString();
                    var spillSize = cmbSpillSize.SelectedValue.ToString();
                    var windDir = Convert.ToInt32(windDirection.Value);
                    List<GPParameter> parameters = new List<GPParameter>();

                    parameters.Add(new GPFeatureRecordSetLayer("in_features", new FeatureSet(_spillLocationGraphicsLayer.Graphics)));

                    if (cmbChemicalorPlacard.SelectedValue.ToString() == "Chemical")
                    {
                        geoprocessorTask.Url = _chemicalURL;
                        parameters.Add(new GPString("material_type", materialType));
                        geoprocessorTask.JobCompleted += ergChemicalGeoprocessorTask_JobCompleted;
                    }
                    else
                    {
                        geoprocessorTask.Url = _placardURL;
                        geoprocessorTask.JobCompleted += ergPlacardGeoprocessorTask_JobCompleted;
                        parameters.Add(new GPString("placard_id", materialType));
                    }

                    geoprocessorTask.OutputSpatialReference = _mapWidget.Map.SpatialReference;
                    geoprocessorTask.ProcessSpatialReference = _mapWidget.Map.SpatialReference;

                    if (_windDirectionQuestionResult == MessageBoxResult.No)
                        parameters.Add(new GPLong("wind_bearing", windDir));
                    else
                        parameters.Add(new GPLong("wind_bearing", _windDirectionTo));

                    parameters.Add(new GPString("time_of_day", spillTime));
                    parameters.Add(new GPString("spill_size", spillSize));


                    if (_gpExecutionType == "esriExecutionTypeSynchronous")
                    {
                        geoprocessorTask.ExecuteCompleted += ERGGeoprocessorTask_ExecuteCompleted;
                        geoprocessorTask.Failed += GeoprocessorTask_Failed;
                        geoprocessorTask.ExecuteAsync(parameters);
                    }
                    else
                        geoprocessorTask.SubmitJobAsync(parameters);
                }
                else
                    MessageBox.Show("Please add spill location on the map", "Error");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }
        }
开发者ID:ruisebastiao,项目名称:solutions-widgets-wpf,代码行数:67,代码来源:ERGChemicalMapToolbar.xaml.cs


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