void gp_GetResultDataCompleted(object sender, GPParameterEventArgs e) { _graphicsLayer.Graphics.Clear(); ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); //client.SimpleRenderer simRen = mydictionary["RouteRenderer"] as client.SimpleRenderer; client.GraphicsLayer gLayer = _mapWidget.Map.Layers["ComputedLine"] as client.GraphicsLayer; if (gLayer == null) { gLayer = new client.GraphicsLayer(); gLayer.ID = "ComputedLine"; //gLayer.Renderer = simRen; //client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; //if (aclyrs.Count() > 0) _mapWidget.Map.Layers.Add(gLayer); } GPFeatureRecordSetLayer gpFLayer = e.Parameter as GPFeatureRecordSetLayer; if (gpFLayer.FeatureSet.Features.Count > 0) { foreach (client.Graphic g in gpFLayer.FeatureSet.Features) { g.Symbol = mydictionary["BasicLineSymbol_Green_3"] as client.Symbols.LineSymbol; gLayer.Graphics.Add(g); } } }
void findNearestWSGPTask_GetResultDataCompleted(object sender, GPParameterEventArgs e) { try { GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer; foreach (client.Graphic graphic in gpLayer.FeatureSet.Features) { double distance = Convert.ToDouble(graphic.Attributes["NEAR_DIST"]) * 69.09; _weatherStationDistanceInfo = "Distance to weather station: " + distance.ToString("0.000") + " miles"; //get the wind direction from the nearest weather station... int fid = Convert.ToInt32(graphic.Attributes["NEAR_FID"]); if (_windDirectionLayer != null) { QueryTask windDirectionQueryTask = new QueryTask(_windDirectionLayer.Url); windDirectionQueryTask.ExecuteCompleted += WindDirectionQueryTask_ExecuteCompleted; windDirectionQueryTask.Failed += QueryTask_Failed; ESRI.ArcGIS.Client.Tasks.Query windDirectionQuery = new ESRI.ArcGIS.Client.Tasks.Query(); windDirectionQuery.OutFields.AddRange(new string[] { "*" }); windDirectionQuery.Where = "OBJECTID =" + fid; windDirectionQueryTask.ExecuteAsync(windDirectionQuery); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); MessageBox.Show("Error processing ERG Task Results!", "Error"); return; } }
private bool _FindTargetFeature(GPFeatureRecordSetLayer orders, Order order, out GPFeature orderFeature) { orderFeature = null; bool found = false; foreach (GPFeature feature in orders.Features) { string idStr = null; if (feature.Attributes.TryGet <string>(NAAttribute.NAME, out idStr)) { Guid id = new Guid(idStr); if (id == order.Id) { orderFeature = feature; found = true; break; } } } return(found); }
public async void Clip() { //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_Features", 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!!!"; } }
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(); } }
private void GeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs args) { GPParameter gpParameter = args.Results.OutParameters[0]; if (gpParameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; ProfileImage.Source = new BitmapImage(new Uri(gpLayer.FeatureSet.Features[0].Attributes["profileURL"].ToString(), UriKind.Absolute)); ProfileView.Visibility = Visibility.Visible; } }
private void _ShiftSequence(GPFeatureRecordSetLayer orders, int targetSeq) { foreach (GPFeature feature in orders.Features) { int sequence; if (feature.Attributes.TryGet <int>(NAAttribute.SEQUENCE, out sequence) && sequence >= targetSeq) { feature.Attributes.Set(NAAttribute.SEQUENCE, sequence + 1); } } }
void GeoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs e) { if (e.Parameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer; int count = 0; foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphic.Symbol = bufferSymbols[count++]; graphicsLayer.Graphics.Add(graphic); } } }
private void GeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e) { foreach (GPParameter gpParameter in e.Results.OutParameters) { if (gpParameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphic.Symbol = LayoutRoot.Resources["PathLineSymbol"] as Symbol; _graphicsLayer.Graphics.Add(graphic); } } } }
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; } }
// 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; } }
private bool _HasSequence(GPFeatureRecordSetLayer orders, int targetSeq) { bool found = false; foreach (GPFeature feature in orders.Features) { int sequence; if (feature.Attributes.TryGet <int>(NAAttribute.SEQUENCE, out sequence) && sequence == targetSeq) { found = true; break; } } return(found); }
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(); } }
private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args) { MyMap.Cursor = System.Windows.Input.Cursors.Hand; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (GPParameter gpParameter in args.Results.OutParameters) { if (gpParameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer layer = gpParameter as GPFeatureRecordSetLayer; foreach (Graphic graphic in layer.FeatureSet.Features) { graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; graphicsLayer.Graphics.Add(graphic); } } } }
void gp_GetResultDataCompleted(object sender, GPParameterEventArgs e) { try { ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/SatelliteEphemerisGenerationAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); GPFeatureRecordSetLayer gpFLayer = e.Parameter as GPFeatureRecordSetLayer; if (gpFLayer.FeatureSet.Features.Count > 0) { foreach (client.Graphic g in gpFLayer.FeatureSet.Features) { if (e.UserState.ToString() == "Footprints") { g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol; _graphicsLayerPoly.Graphics.Add(g); } else if (e.UserState.ToString() == "Lines") { g.Symbol = mydictionary["BasicLineSymbol_Green_3"] as client.Symbols.SimpleLineSymbol; _graphicsLayerLine.Graphics.Add(g); } else if (e.UserState.ToString() == "Points") { g.Symbol = mydictionary["BluePin"] as client.Symbols.MarkerSymbol; _graphicsLayerPoint.Graphics.Add(g); } } } if (e.UserState.ToString() == "Footprints") { gp.GetResultDataAsync(_jobid, "EphemerisLines", "Lines"); } else if (e.UserState.ToString() == "Lines") { gp.GetResultDataAsync(_jobid, "EphemerisPoints", "Points"); } } catch (Exception ex) { MessageBox.Show("Error in GetResultDataCompleted, UserState: " + e.UserState.ToString()); MessageBox.Show("Error in GetResultDataCompleted, Exception: " + ex.Message); } }
/// <summary> /// Generate GPFeatureRecordSetLayer of specified barrier type. /// </summary> /// <param name="barriers">Collection of Typed Barriers to include into layer.</param> /// <param name="type">Type of barriers to convert in.</param> /// <param name="solverSR">Reference to GP spatial.</param> /// <returns>GPFeatureRecordSetLayer of barriers of specified type.</returns> private GPFeatureRecordSetLayer _GenerateLayer(IEnumerable <Barrier> barriers, BarrierGeometryType type, GPSpatialReference solverSR) { Debug.Assert(barriers != null); GPFeatureRecordSetLayer layer = null; GPFeature[] features = _ConvertBarriers(barriers, type); if (features.Length > 0) { layer = new GPFeatureRecordSetLayer(); layer.SpatialReference = solverSR; layer.Features = features; switch (type) { case BarrierGeometryType.Point: layer.GeometryType = NAGeometryType.esriGeometryPoint; break; case BarrierGeometryType.Polygon: layer.GeometryType = NAGeometryType.esriGeometryPolygon; break; case BarrierGeometryType.Polyline: layer.GeometryType = NAGeometryType.esriGeometryPolyline; break; case BarrierGeometryType.None: // Not supported type. Debug.Assert(false); break; default: Debug.Assert(false); break; } } return(layer); }
private void GeoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e) { Geoprocessor geoprocessorTask = sender as Geoprocessor; geoprocessorTask.GetResultDataCompleted += (s1, ev1) => { GraphicsLayer graphicsLayer = MyMap.Layers["MyResultGraphicsLayer"] as GraphicsLayer; if (ev1.Parameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = ev1.Parameter as GPFeatureRecordSetLayer; if (gpLayer.FeatureSet.Features.Count == 0) { geoprocessorTask.GetResultImageLayerCompleted += (s2, ev2) => { GPResultImageLayer gpImageLayer = ev2.GPResultImageLayer; gpImageLayer.Opacity = 0.5; MyMap.Layers.Add(gpImageLayer); ProcessingTextBlock.Text = "Greater than 500 features returned. Results drawn using map service."; _processingTimer.Stop(); }; geoprocessorTask.GetResultImageLayerAsync(e.JobInfo.JobId, "Clipped_Counties"); return; } foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphic.Symbol = LayoutRoot.Resources["ClipFeaturesFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphic); } } ProcessingTextBlock.Visibility = Visibility.Collapsed; _processingTimer.Stop(); }; geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "Clipped_Counties"); }
private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (GPParameter parameter in args.Results.OutParameters) { if (parameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = parameter as GPFeatureRecordSetLayer; List <FillSymbol> bufferSymbols = new List <FillSymbol>( new FillSymbol[] { LayoutRoot.Resources["FillSymbol1"] as FillSymbol, LayoutRoot.Resources["FillSymbol2"] as FillSymbol, LayoutRoot.Resources["FillSymbol3"] as FillSymbol }); 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)); graphicsLayer.Graphics.Add(graphic); count++; } } } }
/// <summary> /// マップビュータップ時の処理 /// </summary> private async void mainMapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e) { //解析手順のメッセージを非表示 analyzeTextBox.Visibility = System.Windows.Visibility.Collapsed; //プログレスバーを表示 analyzeProgressBar.Visibility = System.Windows.Visibility.Visible; //マップビュータップ時のイベントハンドラを解除 mainMapView.MapViewTapped -= mainMapView_MapViewTapped; //カーソルを矢印に変更 mainMapView.Cursor = Cursors.Arrow; //クリックした位置からグラフィックを作成 Graphic clickPoint = new Graphic(e.Location) { Symbol = layoutRoot.Resources["greenMarkerSymbol"] as SimpleMarkerSymbol, ZIndex = 2 }; //到達圏解析結果表示用のグラフィックスレイヤにクリック位置のグラフィックを追加 serviceAreaResultLayer.Graphics.Add(clickPoint); try { //到達圏解析用パラメーターの作成 GPInputParameter parameter = new GPInputParameter(); parameter.GPParameters.Add(new GPFeatureRecordSetLayer("facilities", e.Location)); //解析の中心点 parameter.GPParameters.Add(new GPString("break_values", "10")); //到達圏の範囲(10分) parameter.GPParameters.Add(new GPString("env:outSR", "102100")); //結果の空間参照(Web メルカトル) parameter.GPParameters.Add(new GPString("travel_mode", "Walking")); //"徒歩"で到達できる範囲を解析 //到達圏の解析を開始 GPJobInfo result = await serviceAreaGp.SubmitJobAsync(parameter); //到達圏の解析結果が"成功"、"失敗"、"時間切れ"、"キャンセル"のいずれかになるまで //2秒ごとに ArcGIS Online にステータスを確認 while (result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.Failed && result.JobStatus != GPJobStatus.TimedOut && result.JobStatus != GPJobStatus.Cancelled) { result = await serviceAreaGp.CheckJobStatusAsync(result.JobID); await Task.Delay(2000); } //到達圏解析の結果が成功した場合は結果を表示 if (result.JobStatus == GPJobStatus.Succeeded) { //到達圏解析の結果を取得 GPParameter resultData = await serviceAreaGp.GetResultDataAsync(result.JobID, "Service_Areas"); //到達圏解析結果レイヤのグラフィックを結果グラフィックとして取得 GPFeatureRecordSetLayer gpLayer = resultData as GPFeatureRecordSetLayer; serviceAreaGraphic = gpLayer.FeatureSet.Features[0] as Graphic; //グラフィックにシンボルを設定 serviceAreaGraphic.Symbol = layoutRoot.Resources["greenFillSymbol"] as SimpleFillSymbol; //結果グラフィックが解析の中心点のグラフィックより下に表示されるように表示順序を設定 serviceAreaGraphic.ZIndex = 1; //到達圏解析結果表示用のグラフィックスレイヤにグラフィックを追加 serviceAreaResultLayer.Graphics.Add(serviceAreaGraphic); } } //エラーが発生した場合の処理 catch (Exception ex) { MessageBox.Show(string.Format("到達圏解析:{0}", ex.Message)); //到達圏解析の結果をクリア ClearAnalysisResult(); } finally { //プログレスバーを非表示 analyzeProgressBar.Visibility = System.Windows.Visibility.Collapsed; //到達圏解析ボタンを表示 analyzePanel.Visibility = System.Windows.Visibility.Visible; } }
// Get the users input line on the map and fire off a GP Job to clip features private async void StartButton_Click(object sender, RoutedEventArgs e) { try { uiPanel.IsEnabled = false; inputLayer.Graphics.Clear(); resultLayer.Graphics.Clear(); foreach (var lyr in mapView.Map.Layers.OfType <GPResultImageLayer>()) { mapView.Map.Layers.Remove(lyr); } //get the user's input line var inputLine = await mapView.Editor.RequestShapeAsync(DrawShape.Polyline) as Polyline; progress.Visibility = Visibility.Visible; inputLayer.Graphics.Add(new Graphic() { Geometry = inputLine }); var parameter = new GPInputParameter(); parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Features", inputLine)); parameter.GPParameters.Add(new GPLinearUnit("Linear_unit", LinearUnits.Miles, Int32.Parse(txtMiles.Text))); var result = await SubmitAndPollStatusAsync(parameter); if (result.JobStatus == GPJobStatus.Succeeded) { txtStatus.Text = "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) { var resultImageLayer = await _gpTask.GetResultImageLayerAsync(result.JobID, "Clipped_Counties"); GPResultImageLayer gpImageLayer = resultImageLayer; gpImageLayer.Opacity = 0.5; mapView.Map.Layers.Add(gpImageLayer); txtStatus.Text = "Greater than 500 features returned. Results drawn using map service."; return; } resultLayer.Graphics.AddRange(gpLayer.FeatureSet.Features); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } finally { uiPanel.IsEnabled = true; progress.Visibility = Visibility.Collapsed; } }
private void populateLayerPanel(List <GraphicsLayer> inputLayers) { layerPanel.Children.Clear(); if (inputLayers.Count > 0) { cb = new ComboBox() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, Width = 125, Height = 24, Foreground = new SolidColorBrush(Colors.Black) }; populateLayerList(inputLayers); cb.SetValue(Grid.ColumnProperty, 1); cb.SelectionChanged += (a, b) => { GraphicsLayer selLayer = cb.SelectedItem as GraphicsLayer; if (selLayer != null) { InputLayerID = selLayer.ID; FeatureSet features = new FeatureSet(); FeatureSet selectedFeatures = new FeatureSet(); foreach (Graphic g in selLayer.Graphics) { if (g.Geometry != null) { if (features.SpatialReference == null) { features.SpatialReference = g.Geometry.SpatialReference; } Graphic newG = new Graphic(); newG.Geometry = g.Geometry; features.Features.Add(newG); if (g.Selected) { selectedFeatures.Features.Add(newG); } } } if (selectedFeatures.Features.Count > 0) { Value = new GPFeatureRecordSetLayer(Config.Name, selectedFeatures); } else { Value = new GPFeatureRecordSetLayer(Config.Name, features); } } else { Value = null; } RaiseCanExecuteChanged(); }; layerPanel.Children.Add(cb); RaiseCanExecuteChanged(); } else { TextBlock tb = new TextBlock() { Text = string.Format(Resources.Strings.NoLayersAvailable, getGeometryType()) }; ToolTipService.SetToolTip(tb, string.Format(Resources.Strings.AddLayersToMap, getGeometryType())); layerPanel.Children.Add(tb); RaiseCanExecuteChanged(); } }
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(); } }
// 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) { error = "Clip operation failed: " + ex.Message; } // If operation did not succeed, notify user if (error != null) { MessageBox.Show(error); } // Hide busy UI BusyVisibility = StatusVisibility = Visibility.Collapsed; StatusText = ""; m_firstPointAdded = false; getInputLineAndClip(); }
private void addToMap(GPFeatureRecordSetLayer result, ParameterConfig config) { if (result == null) { return; } SpatialReference sr = Map.SpatialReference.Clone(); ESRI.ArcGIS.Mapping.Core.GeometryType geomType = Core.GeometryType.Unknown; FeatureLayerParameterConfig flConfig = config as FeatureLayerParameterConfig; foreach (Graphic item in result.FeatureSet.Features) { if (item.Geometry != null) { item.Geometry.SpatialReference = sr; if (geomType == Core.GeometryType.Unknown) { if (item.Geometry is MapPoint) { geomType = Core.GeometryType.Point; } else if (item.Geometry is MultiPoint) { geomType = Core.GeometryType.MultiPoint; } else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon) { geomType = Core.GeometryType.Polygon; } else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline) { geomType = Core.GeometryType.Polyline; } } if (flConfig != null && flConfig.DoubleFields != null && flConfig.DoubleFields.Length > 0) { foreach (string name in flConfig.DoubleFields) { if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null && (!(item.Attributes[name] is double))) { double d; if (double.TryParse(item.Attributes[name].ToString(), System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out d)) { item.Attributes[name] = d; } } } } if (flConfig != null && flConfig.SingleFields != null && flConfig.SingleFields.Length > 0) { foreach (string name in flConfig.SingleFields) { if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null && (!(item.Attributes[name] is Single))) { Single s; if (Single.TryParse(item.Attributes[name].ToString(), out s)) { item.Attributes[name] = s; } } } } } } GraphicsLayer layer = GraphicsLayer.FromGraphics(result.FeatureSet.Features, new SimpleRenderer()); if (flConfig != null) { if (flConfig.GeometryType == geomType) { layer.Renderer = flConfig.Layer.Renderer; } else { layer.Renderer = FeatureLayerParameterConfig.GetSimpleRenderer(geomType); } setLayerProps(config, layer); if (flConfig.Layer != null) { Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(flConfig.Layer)); Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(flConfig.Layer)); Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(flConfig.Layer)); // Set whether pop-ups are enabled and whether to show them on click or on hover LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(flConfig.Layer)); Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(flConfig.Layer)); } } GraphicsLayerTypeFixer.CorrectDataTypes(layer.Graphics, layer); Map.Layers.Add(layer); layerParamNameIDLookup.Add(config.Name, layer.ID); }
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { IsBusy = true; // Cancel any outstanding Tasks _gpTask.CancelAsync(); // Get the GraphicsLayer GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); e.MapPoint.SpatialReference = MyMap.SpatialReference; // Add a graphic at the click point Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); // Create the graphic to submit. Graphic g = new Graphic() { Geometry = _mercator.ToGeographic(e.MapPoint) }; // Create a new list of GP Parameters List <GPParameter> gpParams = new List <GPParameter>(); // 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" } }; //var fs = new FeatureSet(new List<Graphic> { g }); // Add the graphic to the FeatureSet featureSet.Features.Add(g); // Set the graphic's attribute featureSet.Features[0].Attributes["VALUE"] = valueText.Text; // Add the GP Paramr gpParams.Add(new GPFeatureRecordSetLayer("InputFeatures", featureSet)); gpParams.Add(new GPLinearUnit("Distance", esriUnits.esriKilometers, 500)); // Register an inline handler for ExecuteCompleted event _gpTask.ExecuteCompleted += (s, e1) => { // Clear the graphics layer (will remove the input Pushpin) graphicsLayer.Graphics.Clear(); // Get the results GPExecuteResults results = e1.Results; GPFeatureRecordSetLayer rs = results.OutParameters[0] as GPFeatureRecordSetLayer; // Get the result feature Graphic graphicBuff = rs.FeatureSet.Features[0]; // Set the symbol graphicBuff.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; // Add to the layer graphicsLayer.Graphics.Add(graphicBuff); // Stop the progress bar IsBusy = false; }; // Register an inline handler for the failed event (just in case) _gpTask.Failed += (s2, e2) => { MessageBox.Show(e2.Error.Message); IsBusy = false; }; // Execute the Buffer asynchronously _gpTask.ExecuteAsync(gpParams); }
private void populateLayerPanel(List<GraphicsLayer> inputLayers) { layerPanel.Children.Clear(); if (inputLayers.Count > 0) { cb = new ComboBox() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, Width = 125, Height = 24, Foreground = new SolidColorBrush(Colors.Black) }; populateLayerList(inputLayers); cb.SetValue(Grid.ColumnProperty, 1); cb.SelectionChanged += (a, b) => { GraphicsLayer selLayer = cb.SelectedItem as GraphicsLayer; if (selLayer != null) { InputLayerID = selLayer.ID; FeatureSet features = new FeatureSet(); FeatureSet selectedFeatures = new FeatureSet(); foreach (Graphic g in selLayer.Graphics) { if (g.Geometry != null) { if (features.SpatialReference == null) features.SpatialReference = g.Geometry.SpatialReference; Graphic newG = new Graphic(); newG.Geometry = g.Geometry; features.Features.Add(newG); if (g.Selected) selectedFeatures.Features.Add(newG); } } if (selectedFeatures.Features.Count > 0) Value = new GPFeatureRecordSetLayer(Config.Name, selectedFeatures); else Value = new GPFeatureRecordSetLayer(Config.Name, features); } else Value = null; RaiseCanExecuteChanged(); }; layerPanel.Children.Add(cb); RaiseCanExecuteChanged(); } else { TextBlock tb = new TextBlock() { Text = string.Format(Resources.Strings.NoLayersAvailable, getGeometryType()) }; ToolTipService.SetToolTip(tb, string.Format(Resources.Strings.AddLayersToMap, getGeometryType())); layerPanel.Children.Add(tb); RaiseCanExecuteChanged(); } }
private void addToMap(GPFeatureRecordSetLayer result, ParameterConfig config) { if (result == null) return; SpatialReference sr = Map.SpatialReference.Clone(); ESRI.ArcGIS.Mapping.Core.GeometryType geomType = Core.GeometryType.Unknown; FeatureLayerParameterConfig flConfig = config as FeatureLayerParameterConfig; foreach (Graphic item in result.FeatureSet.Features) { if (item.Geometry != null) { item.Geometry.SpatialReference = sr; if (geomType == Core.GeometryType.Unknown) { if (item.Geometry is MapPoint) geomType = Core.GeometryType.Point; else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon) geomType = Core.GeometryType.Polygon; else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline) geomType = Core.GeometryType.Polyline; } if (flConfig != null && flConfig.DoubleFields != null && flConfig.DoubleFields.Length > 0) { foreach (string name in flConfig.DoubleFields) { if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null && (!(item.Attributes[name] is double))) { double d; if (double.TryParse(item.Attributes[name].ToString(), System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out d)) item.Attributes[name] = d; } } } if (flConfig != null && flConfig.SingleFields != null && flConfig.SingleFields.Length > 0) { foreach (string name in flConfig.SingleFields) { if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null && (!(item.Attributes[name] is Single))) { Single s; if (Single.TryParse(item.Attributes[name].ToString(), out s)) item.Attributes[name] = s; } } } } } GraphicsLayer layer = GraphicsLayer.FromGraphics(result.FeatureSet.Features, new SimpleRenderer()); if (flConfig != null) { if (flConfig.GeometryType == geomType) layer.Renderer = flConfig.Layer.Renderer; else layer.Renderer = FeatureLayerParameterConfig.GetSimpleRenderer(geomType); setLayerProps(config, layer); if (flConfig.Layer != null) { Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(flConfig.Layer)); Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(flConfig.Layer)); Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(flConfig.Layer)); // Set whether pop-ups are enabled and whether to show them on click or on hover LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(flConfig.Layer)); Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(flConfig.Layer)); } } GraphicsLayerTypeFixer.CorrectDataTypes(layer.Graphics, layer); Map.Layers.Add(layer); layerParamNameIDLookup.Add(config.Name, layer.ID); }
public static string ParameterToString(GPParameterType type, GPParameter param, CultureInfo culture) { if (param == null) { return(string.Empty); } switch (type) { case GPParameterType.Boolean: GPBoolean boo = param as GPBoolean; if (boo != null) { return(boo.Value.ToString()); } else { return(string.Empty); } case GPParameterType.Date: GPDate date = param as GPDate; if (date != null && date.Value != null) { return(date.Value.Ticks.ToString()); } else { return(string.Empty); } case GPParameterType.Double: GPDouble dub = param as GPDouble; if (dub != null && !double.IsNaN(dub.Value)) { return(dub.Value.ToString(culture)); } else { return(string.Empty); } case GPParameterType.Long: GPLong lon = param as GPLong; if (lon != null) { return(lon.Value.ToString()); } else { return(string.Empty); } case GPParameterType.String: GPString stir = param as GPString; if (stir != null && stir.Value != null) { return(stir.Value); } else { return(string.Empty); } case GPParameterType.FeatureLayer: GPFeatureRecordSetLayer feat = param as GPFeatureRecordSetLayer; if (feat != null && feat.Url != null) { return(feat.Url); } else { return(string.Empty); } case GPParameterType.RecordSet: GPRecordSet rsl = param as GPRecordSet; if (rsl != null && rsl.Url != null) { return(rsl.Url); } else { return(string.Empty); } case GPParameterType.DataFile: GPDataFile dat = param as GPDataFile; if (dat != null && dat.Url != null) { return(dat.Url); } else { return(string.Empty); } } return(string.Empty); }
// End Buttons #endregion #region ERG Chemical GP Tool Logic //Execute task is completed void ERGGeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e) { foreach (GPParameter gpParameter in e.Results.OutParameters) { if (gpParameter is GPFeatureRecordSetLayer) { if (gpParameter.Name == "output_areas") { _ergZoneGraphicsLayer.Graphics.Clear(); ESRI.ArcGIS.Client.Geometry.Polygon sharedPolygon = null; //add the erg zone polygons on the map GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; foreach (client.Graphic graphic in gpLayer.FeatureSet.Features) { string zone = graphic.Attributes["ERGZone"].ToString(); switch (zone) { case "Initial Isolation Zone": graphic.Symbol = _mydictionary["sfsZone2"] as client.Symbols.SimpleFillSymbol; break; case "Protective Action Zone": graphic.Symbol = _mydictionary["sfsZone1"] as client.Symbols.SimpleFillSymbol; break; case "Combined Zone": graphic.Symbol = _mydictionary["sfsZone3"] as client.Symbols.SimpleFillSymbol; sharedPolygon = (ESRI.ArcGIS.Client.Geometry.Polygon)graphic.Geometry; break; } _ergZoneGraphicsLayer.Graphics.Add(graphic); } //zoom to the result if (chkZoomToMap.IsChecked == true) { _mapWidget.Map.Extent = sharedPolygon.Extent.Expand(1.2); } } else { //add the erg zone polygons on the map GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; foreach (client.Graphic graphic in gpLayer.FeatureSet.Features) { string lineType = graphic.Attributes["LineType"].ToString(); switch (lineType) { case "Arc": graphic.Symbol = _mydictionary["ArcLineSymbol"] as client.Symbols.SimpleLineSymbol; break; case "Radial": graphic.Symbol = _mydictionary["RadialSymbol"] as client.Symbols.SimpleLineSymbol; break; } _ergZoneGraphicsLayer.Graphics.Add(graphic); } } } } }
// *********************************************************************************** // * ..ERGChemcial GP Tool Job Completed Successfully... Get the Result // *********************************************************************************** void ergGPTask_GetResultDataCompleted(object sender, GPParameterEventArgs e) { try { if (e.Parameter.Name == "output_areas") { _ergZoneGraphicsLayer.Graphics.Clear(); ESRI.ArcGIS.Client.Geometry.Polygon sharedPolygon = null; //add the erg zone polygons on the map GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer; foreach (client.Graphic graphic in gpLayer.FeatureSet.Features) { string zone = graphic.Attributes["ERGZone"].ToString(); switch (zone) { case "Initial Isolation Zone": graphic.Symbol = _mydictionary["sfsZone2"] as client.Symbols.SimpleFillSymbol; break; case "Protective Action Zone": graphic.Symbol = _mydictionary["sfsZone1"] as client.Symbols.SimpleFillSymbol; break; case "Combined Zone": graphic.Symbol = _mydictionary["sfsZone3"] as client.Symbols.SimpleFillSymbol; sharedPolygon = (ESRI.ArcGIS.Client.Geometry.Polygon)graphic.Geometry; break; } _ergZoneGraphicsLayer.Graphics.Add(graphic); } //zoom to the result if (chkZoomToMap.IsChecked == true) { _mapWidget.Map.Extent = sharedPolygon.Extent.Expand(1.2); } selectFeaturesOnTheMap(sharedPolygon); Geoprocessor geoprocessorTask = sender as Geoprocessor; geoprocessorTask.GetResultDataAsync(_gpJobId, "output_lines"); } else { //add the erg zone polygons on the map GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer; foreach (client.Graphic graphic in gpLayer.FeatureSet.Features) { string lineType = graphic.Attributes["LineType"].ToString(); switch (lineType) { case "Arc": graphic.Symbol = _mydictionary["ArcLineSymbol"] as client.Symbols.SimpleLineSymbol; break; case "Radial": graphic.Symbol = _mydictionary["RadialSymbol"] as client.Symbols.SimpleLineSymbol; break; } _ergZoneGraphicsLayer.Graphics.Add(graphic); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); MessageBox.Show("Error processing ERG Task Results!", "Error"); return; } }