예제 #1
0
        // Gets the users digitized area of interest polygon
        private async void AreaOfInterestButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Clear();

                Polygon aoi = null;
                if (chkFreehand.IsChecked == true)
                {
                    var boundary = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand) as Polyline;

                    if (boundary.Parts.First().Count <= 1)
                    {
                        return;
                    }

                    aoi = new Polygon(boundary.Parts, MyMapView.SpatialReference);
                    aoi = GeometryEngine.Simplify(aoi) as Polygon;
                }
                else
                {
                    aoi = await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon) as Polygon;
                }

                _graphicsOverlay.Graphics.Add(new Graphic(aoi));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
예제 #2
0
        // Calculates a geometric difference between features and user defined geometry
        private async void DifferenceButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _differenceGraphics.Graphics.Clear();

                // wait for user to draw difference polygon
                var poly = await mapView.Editor.RequestShapeAsync(DrawShape.Polygon);

                // Adjust user polygon for backward digitization
                poly = GeometryEngine.Simplify(poly);

                // get intersecting features from the feature layer
                SpatialQueryFilter filter = new SpatialQueryFilter();
                filter.Geometry            = GeometryEngine.Project(poly, _statesLayer.FeatureTable.SpatialReference);
                filter.SpatialRelationship = SpatialRelationship.Intersects;
                filter.MaximumRows         = 52;
                var stateFeatures = await _statesLayer.FeatureTable.QueryAsync(filter);

                // Calc difference between feature geometries and user polygon and add results to graphics layer
                var states = stateFeatures.Select(feature => feature.Geometry);

                var diffGraphics = states
                                   .Select(state => ((bool)useSymmetricDifference.IsChecked)
                        ? GeometryEngine.SymmetricDifference(state, poly)
                        : GeometryEngine.Difference(state, poly))
                                   .Select(geo => new Graphic(geo, _fillSymbol));

                _differenceGraphics.Graphics.AddRange(diffGraphics);
            }
            catch (Exception ex)
            {
                var _ = new MessageDialog("Difference Error: " + ex.Message, "Sample Error").ShowAsync();
            }
        }
        /// <summary>
        /// Enables geometry editing and submits geometry edit back to the server.
        /// </summary>
        private async void EditButton_Click(object sender, RoutedEventArgs e)
        {
            var feature = (Feature)EditButton.Tag;
            var layer   = MyMapView.Map.Layers["Incidents"] as FeatureLayer;
            var table   = (ArcGISFeatureTable)layer.FeatureTable;

            // Hides feature from feature layer while its geometry is being modified.
            layer.SetFeatureVisibility(layer.SelectedFeatureIDs, false);

            string message = null;

            try
            {
                // Enables geometry editing and update its geometry
                // using GeometryEngine to correct ring orientation.
                var geometry = await MyMapView.Editor.EditGeometryAsync(feature.Geometry);

                feature.Geometry = GeometryEngine.Simplify(geometry);
                await table.UpdateAsync(feature);

                if (table.HasEdits)
                {
                    if (table is ServiceFeatureTable)
                    {
                        var serviceTable = (ServiceFeatureTable)table;
                        // Pushes geometry edits back to the server.
                        var result = await serviceTable.ApplyEditsAsync();

                        if (result.UpdateResults == null || result.UpdateResults.Count < 1)
                        {
                            return;
                        }
                        var updateResult = result.UpdateResults[0];
                        if (updateResult.Error != null)
                        {
                            message = updateResult.Error.Message;
                        }
                    }
                }
            }
            catch (TaskCanceledException)
            {
                // Ignore TaskCanceledException - usually happens if the editor gets cancelled or restarted
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            finally
            {
                layer.SetFeatureVisibility(layer.SelectedFeatureIDs, true);
                layer.ClearSelection();
                SetGeometryEditor();
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show(message);
            }
        }
예제 #4
0
        // 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;
            }
        }
        // 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;
            }
        }
예제 #6
0
        public static decimal GetArea(this Geometry geometry)
        {
            try
            {
                var projectArea = GeometryEngine.Area(GeometryEngine.Simplify(geometry as Polygon));

                double  projectAreaHa  = AreaUnits.Hectares.FromSquareMeters(projectArea);
                decimal insideItemArea = Convert.ToDecimal(Math.Round(projectAreaHa, 2, MidpointRounding.AwayFromZero));

                return(insideItemArea);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(0);
        }
예제 #7
0
        public static int GetMeters(this Geometry geometry)
        {
            try
            {
                var projectDistance = GeometryEngine.Length(GeometryEngine.Simplify(geometry as Polyline));

                double  projectDistanceMeter = LinearUnits.Meters.FromMeters(projectDistance);
                decimal insideItemArea       = Convert.ToDecimal(Math.Round(projectDistanceMeter, 2, MidpointRounding.AwayFromZero));

                return(Convert.ToInt32(Math.Truncate(insideItemArea)));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(0);
        }
예제 #8
0
        private async void StartButton_Click(object sender, RoutedEventArgs e)
        {
            outputGraphicsLayer.Graphics.Clear();

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
            StartButton.Visibility           = Windows.UI.Xaml.Visibility.Collapsed;
            ResetButton.Visibility           = Windows.UI.Xaml.Visibility.Visible;

            // wait for user to draw difference polygon
            Polygon inputDifferencePolygonGeometry = await mapView1.Editor.RequestShapeAsync(DrawShape.Polygon) as Polygon;

            // Take account of WrapAround
            Polygon polygon = GeometryEngine.NormalizeCentralMeridian(inputDifferencePolygonGeometry) as Polygon;

            // Get the user input geometry and add it to the map
            drawGraphicsLayer.Graphics.Clear();
            drawGraphicsLayer.Graphics.Add(new Graphic {
                Geometry = inputDifferencePolygonGeometry
            });

            // Adjust user polygon for backward digitization
            var simplifyGeometry = GeometryEngine.Simplify(polygon);

            //Generate the difference geometries
            var inputGeometries1 = inputGraphicsLayer.Graphics.Select(x => x.Geometry).ToList();
            var inputGeometries2 = new List <Geometry> {
                simplifyGeometry
            };
            var differenceOutputGeometries = GeometryEngine.Difference(inputGeometries1, inputGeometries2);

            //Add the difference geometries to the amp
            foreach (var geom in differenceOutputGeometries)
            {
                outputGraphicsLayer.Graphics.Add(new Graphic {
                    Geometry = geom
                });
            }

            ResetButton.IsEnabled = true;
        }
예제 #9
0
        private async void StartButton_Click(object sender, RoutedEventArgs e)
        {
            outputGraphicsLayer.Graphics.Clear();

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
            StartButton.Visibility           = Windows.UI.Xaml.Visibility.Collapsed;
            ResetButton.Visibility           = Windows.UI.Xaml.Visibility.Visible;

            //Get the user's input geometry and add it to the map
            inputDifferencePolygonGeometry = (await mapView1.Editor.RequestShapeAsync(DrawShape.Polygon)) as Polygon;
            drawGraphicsLayer.Graphics.Clear();
            drawGraphicsLayer.Graphics.Add(new Graphic {
                Geometry = inputDifferencePolygonGeometry
            });

            //Simplify the input geometry
            var simplifyGeometry = GeometryEngine.Simplify(inputDifferencePolygonGeometry);

            //Generate the difference geometries
            var inputGeometries1 = inputGraphicsLayer.Graphics.Select(x => x.Geometry).ToList();
            var inputGeometries2 = new List <Geometry> {
                simplifyGeometry
            };
            var differenceOutputGeometries = GeometryEngine.Difference(inputGeometries1, inputGeometries2);

            //Add the difference geometries to the amp
            foreach (var geom in differenceOutputGeometries)
            {
                outputGraphicsLayer.Graphics.Add(new Graphic {
                    Geometry = geom
                });
            }

            ResetButton.IsEnabled = true;
        }
        /// <summary>
        /// Enables geometry editing, submits geometry edit back to the server and refreshes dynamic layer.
        /// </summary>
        private async void EditButton_Click(object sender, RoutedEventArgs e)
        {
            var    layer     = MyMapView.Map.Layers["RecreationalArea"] as ArcGISDynamicMapServiceLayer;
            var    overlay   = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay;
            var    featureID = (long)EditButton.Tag;
            string message   = null;

            try
            {
                // Hides graphic from overlay and dynamic layer while its geometry is being modified.
                overlay.Graphics.Clear();
                // Negative IDs indicate they do not exist on server yet.
                if (featureID > 0)
                {
                    if (layer.LayerDefinitions == null)
                    {
                        layer.LayerDefinitions = new ObservableCollection <LayerDefinition>();
                    }
                    else
                    {
                        layer.LayerDefinitions.Clear();
                    }
                    layer.LayerDefinitions.Add(new LayerDefinition()
                    {
                        LayerID    = layer.VisibleLayers[0],
                        Definition = string.Format("Objectid <> {0}", featureID)
                    });
                }
                if (table == null)
                {
                    // Creates table based on visible layer of dynamic layer
                    // using FeatureServer specifying shape field to enable editing.
                    var id  = layer.VisibleLayers[0];
                    var url = layer.ServiceUri.Replace("MapServer", "FeatureServer");
                    url   = string.Format("{0}/{1}", url, id);
                    table = await ServiceFeatureTable.OpenAsync(new Uri(url), null, MyMapView.SpatialReference);
                }
                // Retrieves feature identified by ID and updates its geometry
                // using GeometryEngine to correct ring orientation.
                var feature = await table.QueryAsync(featureID);

                var geometry = await MyMapView.Editor.EditGeometryAsync(feature.Geometry);

                feature.Geometry = GeometryEngine.Simplify(geometry);
                await table.UpdateAsync(feature);

                if (table.HasEdits)
                {
                    // Pushes geometry edits back to the server.
                    var result = await table.ApplyEditsAsync();

                    if (result.UpdateResults == null || result.UpdateResults.Count < 1)
                    {
                        return;
                    }
                    var updateResult = result.UpdateResults[0];
                    if (updateResult.Error != null)
                    {
                        message = updateResult.Error.Message;
                    }
                }
            }
            catch (TaskCanceledException te)
            {
                // Handles canceling out of Editor.
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            finally
            {
                SetGeometryEditor();
                if (layer.LayerDefinitions != null)
                {
                    layer.LayerDefinitions.Clear();
                    // Refreshes layer to reflect geometry edits.
                    layer.Invalidate();
                }
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show(message);
            }
        }
예제 #11
0
        // Simplify and then query
        private async void SimplifyAndQueryButton_Click(object sender, RoutedEventArgs e)
        {
            var simplifiedPolygon = GeometryEngine.Simplify(_unsimplifiedPolygon);

            await ParcelQuery(simplifiedPolygon);
        }
        private async Task DoIntersection()
        {
            intersectGraphicsLayer.Graphics.Clear();
            ResetButton.IsEnabled = false;


            try
            {
                if (MyMapView.Editor.IsActive)
                {
                    MyMapView.Editor.Cancel.Execute(null);
                }

                // Wait for user to draw a polygon
                Polygon userpoly = await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon) as Polygon;

                Polygon inputGeom = GeometryEngine.NormalizeCentralMeridian(userpoly) as Polygon;

                if (inputGeom != null)
                {
                    //Add the polygon drawn by the user
                    var g = new Graphic
                    {
                        Geometry = inputGeom,
                        Symbol   = new SimpleFillSymbol {
                            Outline = new SimpleLineSymbol {
                                Width = 2, Color = Colors.Gray
                            }, Style = SimpleFillStyle.Null
                        }
                    };
                    intersectGraphicsLayer.Graphics.Add(g);


                    //Optional - Simplify the input geometry
                    inputGeom = GeometryEngine.Simplify(inputGeom) as Polygon;

                    //Do the intersection for each of the graphics in the parcels layer
                    foreach (var parcel in parcelGraphicsLayer.Graphics)
                    {
                        var intersected = GeometryEngine.Intersection(inputGeom, parcel.Geometry);

                        if (intersected != null)
                        {
                            var color = Color.FromArgb((byte)100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255));
                            intersectGraphicsLayer.Graphics.Add(new Graphic
                            {
                                Geometry = intersected,
                                Symbol   = new SimpleFillSymbol
                                {
                                    Color   = color,
                                    Outline = new SimpleLineSymbol {
                                        Color = Colors.Black, Width = 2
                                    }
                                }
                            });
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            ResetButton.IsEnabled = true;
        }
예제 #13
0
        // myMapView 事件
        private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement ie  = (IInputElement)(sender);
            MapPoint      loc = myMapView.ScreenToLocation(e.GetPosition(ie));

            switch (operation)
            {
            case OperateType.DrawPoint:     //画点
                Graphic pt = new Graphic(loc, pointSymbol);
                graphicsLayer.Graphics.Add(pt);
                break;

            case OperateType.DrawPolyline:    //画线
                pointCollection.Add(loc);
                if (pointCollection.Count >= 2)
                {
                    if (pointCollection.Count > 2)
                    {
                        Graphic         g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolylineBuilder lb = new PolylineBuilder(pointCollection);
                        g.Geometry = lb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection);
                        Graphic lg = new Graphic(l, lineSymbol);
                        graphicsLayer.Graphics.Add(lg);
                    }
                }
                break;

            case OperateType.DrawPolygon:    //画多边形
                pointCollection.Add(loc);
                if (pointCollection.Count >= 3)
                {
                    if (pointCollection.Count > 3)
                    {
                        Graphic        g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolygonBuilder pb = new PolygonBuilder(pointCollection);
                        g.Geometry = pb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
                        Graphic pg = new Graphic(p, fillSymbol);
                        graphicsLayer.Graphics.Add(pg);
                    }
                }
                break;

            case OperateType.None:    //缺省状态
                graphicsLayer.ClearSelection();
                IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                //选择图形元素
                if (result.Graphics.Count < 1)
                {
                    curSelGraphic = null;
                    EditVertexMenuItem.IsEnabled   = false;
                    UneditVertexMenuItem.IsEnabled = false;
                    return;
                }
                curSelGraphic                = result.Graphics.First();
                curSelGraphic.IsSelected     = true;
                EditVertexMenuItem.IsEnabled = true;
                break;

            case OperateType.Cal_Clip:     //选择图形
                IdentifyGraphicsOverlayResult gResult = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic = gResult.Graphics.First();
                selGraphic.IsSelected = true; listOfClipGraphics.Add(selGraphic); //记录所选图形
                if (listOfClipGraphics.Count == 2)                                //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Clip(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                      //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Union:     // 联合
                IdentifyGraphicsOverlayResult gResultUnion = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResultUnion.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphicUnion = gResultUnion.Graphics.First();
                selGraphicUnion.IsSelected = true;
                listOfClipGraphics.Add(selGraphicUnion); //记录所选图形
                if (listOfClipGraphics.Count == 2)       //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Union(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                  //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                       //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                         //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Cut:     // 剪切
                IdentifyGraphicsOverlayResult gResult_Cut = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Cut.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Cut = gResult_Cut.Graphics.First();
                selGraphic_Cut.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Cut); //记录所选图形
                if (listOfClipGraphics.Count == 2)      //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polyline)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素后再选择一个线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Polyline   polyLine       = (Esri.ArcGISRuntime.Geometry.Polyline)g2.Geometry;
                    Esri.ArcGISRuntime.Geometry.Geometry[] resultGeometry = GeometryEngine.Cut(g1.Geometry, polyLine); //执行剪切操作
                    if (resultGeometry != null)                                                                        //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);
                        for (int z = 0; z < resultGeometry.Length; z++)
                        {
                            Graphic clipedGraphic = new Graphic(resultGeometry[z], fillSymbol);     //利 用剪切结果构建新的图形
                            graphicsLayer.Graphics.Add(clipedGraphic);
                        }
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Simplify:     // 拓扑纠正
                IdentifyGraphicsOverlayResult gResult_Simplify = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Simplify.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Simplify = gResult_Simplify.Graphics.First();
                selGraphic_Simplify.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Simplify); //记录所选图形
                if (listOfClipGraphics.Count == 1)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Simplify(g1.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                      //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Gene:     // 简化
                IdentifyGraphicsOverlayResult gResult_Gene = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Gene.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Gene = gResult_Gene.Graphics.First();
                selGraphic_Gene.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Gene); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形是点,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Generalize(g1.Geometry, 1000000.0, true); //执行剪切操作
                    if (resultGeometry != null)                                                                                    //处理结果
                    {
                        MessageBox.Show(resultGeometry.ToJson() + "\n" + resultGeometry.GeometryType);
                        graphicsLayer.Graphics.Remove(g1);                               //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Buff:     // 缓冲
                IdentifyGraphicsOverlayResult gResult_Buff = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Buff.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Buff = gResult_Buff.Graphics.First();
                selGraphic_Buff.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Buff); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Buffer(g1.Geometry, 1000000.0);                                                                                                                           //执行剪切操作
                    if (resultGeometry != null)                                                                                                                                                                                                    //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                                                                                                                                         //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.FromArgb(125, 255, 250, 0), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(0, 0, 0), 4.0))); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Jiaodian:     // 交点
                IdentifyGraphicsOverlayResult gResult_Jiaodian = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Jiaodian.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Jiaodian = gResult_Jiaodian.Graphics.First();
                selGraphic_Jiaodian.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Jiaodian); //记录所选图形
                if (listOfClipGraphics.Count == 2)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    IReadOnlyList <Geometry> resultGeometry = GeometryEngine.Intersections(g1.Geometry, g2.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                       //处理结果
                    {
                        Graphic clipedGraphic = new Graphic(resultGeometry[0], pointSymbol);                          //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;
            }
        }