Esempio n. 1
0
        public async void FillOtherStreetData()
        {
            if (StreetLayer != null && StreetLayer is FeatureLayer)
            {
                try
                {
                    QueryParameters _query = new QueryParameters();
                    _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'";

                    var features = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    var ranges = features.Select(feature => new RangeData(feature.Attributes["FROMLEFTTHEORETICRANGE"]?.ToString(), feature.Attributes["TOLEFTTHEORETICRANGE"]?.ToString(), feature.Attributes["FROMRIGHTTHEORETICRANGE"]?.ToString(), feature.Attributes["TORIGHTTHEORETICRANGE"]?.ToString())).GroupBy(s => new { s.leftLower, s.leftUpper, s.rightLower, s.rightUpper }).Select(g => g.First());

                    RangeList = ranges.OrderBy(s => Int32.Parse(s.leftLower)).ToList();


                    var newGeometry = GeometryEngine.Union(features.Select(ft => ft.Geometry));

                    _query.WhereClause         = "REGISTEREDNAME is not null and REGISTEREDNAME <> '" + SelectedPrimaryStreet.name + "'";
                    _query.Geometry            = newGeometry;
                    _query.SpatialRelationship = SpatialRelationship.Intersects;

                    var intersectsFeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    var streets = intersectsFeatures.Select(feature => new StreetData(feature.Attributes["REGISTEREDNAME"]?.ToString(), feature.Attributes["STREETTYPE"]?.ToString(), feature.Attributes["QUADRANT"]?.ToString())).GroupBy(s => new { s.name, s.type, s.quad }).Select(g => g.First());

                    IntersectingStreetList = streets.OrderBy(s => s.name).ToList();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 2
0
        private void ZoomToAllLayers()
        {
            if (mapView.Map == null)
            {
                return;
            }

            // Calculate the full extent of all layers, then zoom to it.
            Envelope extent = null;

            foreach (var layer in mapView.Map?.OperationalLayers.OfType <EncLayer>().Where(l => l.FullExtent != null))
            {
                if (extent == null)
                {
                    extent = layer.FullExtent;
                }
                else
                {
                    extent = GeometryEngine.Union(extent, layer.FullExtent).Extent;
                }
            }

            if (extent != null)
            {
                mapView.SetViewpointGeometryAsync(extent);
            }
        }
Esempio n. 3
0
        // Unions feature geometries with a user defined polygon.
        private async void UnionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _resultGraphics.Graphics.Clear();

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

                // 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);

                // Union the geometries and add to graphics layer
                var states     = stateFeatures.Select(feature => feature.Geometry);
                var unionPolys = states.ToList();
                unionPolys.Add(poly);

                var unionPoly    = GeometryEngine.Union(unionPolys);
                var unionGraphic = new Graphic(unionPoly, _fillSymbol);

                _resultGraphics.Graphics.Add(unionGraphic);
            }
            catch (Exception ex)
            {
                var _ = new MessageDialog("Union Error: " + ex.Message, "Sample Error").ShowAsync();
            }
        }
Esempio n. 4
0
        private async void myTestBtn3_Click(object sender, RoutedEventArgs e)
        {
            FeatureLayer       a = (FeatureLayer)myMapView.Map.OperationalLayers[0];
            FeatureQueryResult r = await a.GetSelectedFeaturesAsync();

            IEnumerator <Feature> resultFeatures = r.GetEnumerator();
            List <Feature>        features       = new List <Feature>();

            while (resultFeatures.MoveNext())
            {
                features.Add(resultFeatures.Current);
            }
            myTest.Text = features.Count + " 个";
            Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Union(features[0].Geometry, features[1].Geometry);
            myTest.Text = resultGeometry.IsEmpty + "";
            // 渲染
            SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol()
            {
                Style = SimpleLineSymbolStyle.Solid,
                Width = 4,
                Color = System.Drawing.Color.Green
            };
            Graphic graphic = new Graphic(resultGeometry, simpleLineSymbol);

            graphicsOverlay.Graphics.Add(graphic);
        }
Esempio n. 5
0
        /// <summary>
        /// Aktualisiert diesen Layer und den <see cref="AreaOfInterest"/>.
        /// </summary>
        internal async Task UpdateAsync()
        {
            Overlay.Graphics.Clear();

            var geometries        = new List <Geometry>();
            var featureCollection = await _service.Query(_url);

            foreach (var feature in featureCollection.Features)
            {
                var roadGeometry = feature.Geometry;
                switch (roadGeometry.Type)
                {
                case @"MultiLineString":
                    var roadGraphic = CreateRoadGraphic(feature, SpatialReferences.Wgs84, _mapSpatialReference);
                    Overlay.Graphics.Add(roadGraphic);
                    geometries.Add(roadGraphic.Geometry);
                    break;
                }
            }

            // Ausdehnung neu berechnen
            var union = GeometryEngine.Union(geometries);

            AreaOfInterest = union.Extent;
        }
        // Find matching places, create graphics and add them to the UI
        private async void FindButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Visibility    = Visibility.Visible;
                listResults.Visibility = Visibility.Collapsed;
                _addressOverlay.Graphics.Clear();

                // Get current viewpoints extent from the MapView
                var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
                var viewpointExtent  = currentViewpoint.TargetGeometry.Extent;

                var param = new OnlineLocatorFindParameters(SearchTextBox.Text)
                {
                    SearchExtent        = viewpointExtent,
                    Location            = viewpointExtent.GetCenter(),
                    MaxLocations        = 5,
                    OutSpatialReference = MyMapView.SpatialReference,
                    OutFields           = new string[] { "Place_addr" }
                };

                var candidateResults = await _locatorTask.FindAsync(param, CancellationToken.None);

                if (candidateResults == null || candidateResults.Count == 0)
                {
                    throw new Exception("No candidates found in the current map extent.");
                }

                foreach (var candidate in candidateResults)
                {
                    AddGraphicFromLocatorCandidate(candidate);
                }

                var extent = GeometryEngine.Union(_addressOverlay.Graphics.Select(g => g.Geometry)).Extent.Expand(1.1);
                await MyMapView.SetViewAsync(extent);

                listResults.Visibility = Visibility.Visible;
            }
            catch (AggregateException ex)
            {
                var innermostExceptions = ex.Flatten().InnerExceptions;
                if (innermostExceptions != null && innermostExceptions.Count > 0)
                {
                    var _x = new MessageDialog(string.Join(" > ", innermostExceptions.Select(i => i.Message).ToArray()), "Sample Error").ShowAsync();
                }
                else
                {
                    var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
                }
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
        // Batch Geocode
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Visibility = Visibility.Visible;
                _graphicsOverlay.Graphics.Clear();
                MyMapView.Overlays.Items.Clear();


                string records = string.Join(",", SourceAddresses.Where(s => !string.IsNullOrWhiteSpace(s.Address))
                                             .Select((s, idx) => string.Format("{{ \"attributes\": {{ \"OBJECTID\": {0}, \"SingleLine\": \"{1}\" }} }}", idx, s.Address))
                                             .ToArray());
                string addresses = string.Format("{{ \"records\": [ {0} ] }}", records);

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters["f"]         = "json";
                parameters["outSR"]     = MyMapView.SpatialReference.Wkid.ToString();
                parameters["addresses"] = addresses;

                ArcGISHttpClient httpClient = new ArcGISHttpClient();
                var response = await httpClient.GetOrPostAsync(GEOCODE_SERVICE_URL, parameters);

                var jsonResults = await response.EnsureSuccessStatusCode().Content.ReadAsStringAsync();

                var mStream = new MemoryStream(Encoding.UTF8.GetBytes(jsonResults));

                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeocodeResults));
                var results = serializer.ReadObject(mStream) as GeocodeResults;

                foreach (var candidate in results.locations)
                {
                    var      location = candidate.location;
                    MapPoint point    = new MapPoint(Convert.ToDouble(location.x), Convert.ToDouble(location.y), MyMapView.SpatialReference);
                    _graphicsOverlay.Graphics.Add(new Graphic(point));

                    // Create a new templated overlay for the geocoded address
                    var overlay = new ContentControl()
                    {
                        HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top
                    };
                    overlay.Template    = layoutGrid.Resources["MapTipTemplate"] as ControlTemplate;
                    overlay.DataContext = candidate.attributes;
                    MapView.SetViewOverlayAnchor(overlay, point);
                    MyMapView.Overlays.Items.Add(overlay);
                }

                await MyMapView.SetViewAsync(GeometryEngine.Union(_graphicsOverlay.Graphics.Select(g => g.Geometry)).Extent.Expand(1.5));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
                AddressFlyout.Hide();
            }
        }
Esempio n. 8
0
        private async void GeocodeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Visibility    = Visibility.Visible;
                listResults.Visibility = Visibility.Collapsed;
                _addressOverlay.Graphics.Clear();

                if (_locatorServiceInfo == null)
                {
                    _locatorServiceInfo = await _locatorTask.GetInfoAsync();
                }

                var candidateResults = await _locatorTask.GeocodeAsync(
                    GetInputAddressFromUI(), new List <string> {
                    "Addr_type", "Score", "X", "Y"
                }, MyMapView.SpatialReference, CancellationToken.None);

                if (candidateResults == null || candidateResults.Count == 0)
                {
                    throw new Exception("No candidates found.");
                }

                foreach (var candidate in candidateResults)
                {
                    AddGraphicFromLocatorCandidate(candidate);
                }

                var visibleGraphics = _addressOverlay.Graphics.Where(g => g.IsVisible);
                listResults.ItemsSource = visibleGraphics;
                listResults.Visibility  = Visibility.Visible;

                var extent = GeometryEngine.Union(visibleGraphics.Select(g => g.Geometry)).Extent.Expand(1.2);
                await MyMapView.SetViewAsync(extent);
            }
            catch (AggregateException ex)
            {
                var innermostExceptions = ex.Flatten().InnerExceptions;
                if (innermostExceptions != null && innermostExceptions.Count > 0)
                {
                    MessageBox.Show(string.Join(" > ", innermostExceptions.Select(i => i.Message).ToArray()));
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 9
0
        // Batch Geocode
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Visibility = Visibility.Visible;
                graphicsLayer.Graphics.Clear();
                mapView.Overlays.Clear();

                JavaScriptSerializer serializer = new JavaScriptSerializer();

                string records = string.Join(",", SourceAddresses.Where(s => !string.IsNullOrWhiteSpace(s.Address))
                                             .Select((s, idx) => string.Format("{{ \"attributes\": {{ \"OBJECTID\": {0}, \"SingleLine\": \"{1}\" }} }}", idx, s.Address))
                                             .ToArray());
                string addresses = string.Format("{{ \"records\": [ {0} ] }}", records);

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters["f"]         = "json";
                parameters["outSR"]     = mapView.SpatialReference.Wkid.ToString();
                parameters["addresses"] = addresses;

                ArcGISHttpClient httpClient = new ArcGISHttpClient();
                var response = await httpClient.GetOrPostAsync(GEOCODE_SERVICE_URL, parameters);

                var jsonResults = await response.EnsureSuccessStatusCode().Content.ReadAsStringAsync();

                var results = serializer.Deserialize <Dictionary <string, object> >(jsonResults);

                var candidates = results["locations"] as ArrayList;
                foreach (var candidate in candidates.OfType <Dictionary <string, object> >())
                {
                    var      location = candidate["location"] as Dictionary <string, object>;
                    MapPoint point    = new MapPoint(Convert.ToDouble(location["x"]), Convert.ToDouble(location["y"]), mapView.SpatialReference);
                    graphicsLayer.Graphics.Add(new Graphic(point));

                    // Create a new templated overlay for the geocoded address
                    var overlay = new ContentControl()
                    {
                        HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top
                    };
                    overlay.Template    = layoutGrid.Resources["MapTipTemplate"] as ControlTemplate;
                    overlay.DataContext = candidate["attributes"] as Dictionary <string, object>;
                    MapView.SetMapOverlayAnchor(overlay, point);
                    mapView.Overlays.Add(overlay);
                }

                await mapView.SetViewAsync(GeometryEngine.Union(graphicsLayer.Graphics.Select(g => g.Geometry)).Extent.Expand(1.5));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Sample Error");
            }
            finally
            {
                progress.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 10
0
 public void ShowStreetOnMap()
 {
     try
     {
         Logging.LogMethodCall(ClassName);
         MainView.Show(GeometryEngine.Union(SelectedStreet.Value), false);
     }
     catch (Exception ex)
     {
         ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error showing coordinates on map", ex);
     }
 }
        // Handle selection events in the spatial operations picker.
        private void OperationModel_ValueChanged(object sender, EventArgs e)
        {
            // Get the data model that contains the spatial operation choices.
            PickerDataModel operationsModel = (PickerDataModel)_operationPicker.Model;

            // If an operation hasn't been selected, return.
            if (operationsModel.SelectedItem == "")
            {
                return;
            }

            // Remove any currently displayed result.
            _polygonsOverlay.Graphics.Remove(_resultGraphic);

            // Polygon geometry from the input graphics.
            Geometry polygonOne = _graphicOne.Geometry;
            Geometry polygonTwo = _graphicTwo.Geometry;

            // Result polygon for spatial operations.
            Geometry resultPolygon = null;

            // Run the selected spatial operation on the polygon graphics and get the result geometry.
            switch (operationsModel.SelectedItem)
            {
            case "Union":
                resultPolygon = GeometryEngine.Union(polygonOne, polygonTwo);
                break;

            case "Difference":
                resultPolygon = GeometryEngine.Difference(polygonOne, polygonTwo);
                break;

            case "Symmetric difference":
                resultPolygon = GeometryEngine.SymmetricDifference(polygonOne, polygonTwo);
                break;

            case "Intersection":
                resultPolygon = GeometryEngine.Intersection(polygonOne, polygonTwo);
                break;
            }

            // Create a black outline symbol to use for the result polygon.
            SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);

            // Create a solid red fill symbol for the result polygon graphic.
            SimpleFillSymbol resultSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Red, outlineSymbol);

            // Create the result polygon graphic and add it to the graphics overlay.
            _resultGraphic = new Graphic(resultPolygon, resultSymbol);
            _polygonsOverlay.Graphics.Add(_resultGraphic);
        }
        private void OperationsPicker_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            // If an operation hasn't been selected, return.
            if (_operationPicker.SelectedItem.ToString() == "")
            {
                return;
            }

            // Remove any currently displayed result.
            _polygonsOverlay.Graphics.Remove(_resultGraphic);

            // Polygon geometry from the input graphics.
            Geometry polygonOne = _graphicOne.Geometry;
            Geometry polygonTwo = _graphicTwo.Geometry;

            // Result polygon for spatial operations.
            Geometry resultPolygon = null;

            // Run the selected spatial operation on the polygon graphics and get the result geometry.
            string selectedOperation = _operationPicker.SelectedItem.ToString();

            switch (selectedOperation)
            {
            case "Union":
                resultPolygon = GeometryEngine.Union(polygonOne, polygonTwo);
                break;

            case "Difference":
                resultPolygon = GeometryEngine.Difference(polygonOne, polygonTwo);
                break;

            case "Symmetric difference":
                resultPolygon = GeometryEngine.SymmetricDifference(polygonOne, polygonTwo);
                break;

            case "Intersection":
                resultPolygon = GeometryEngine.Intersection(polygonOne, polygonTwo);
                break;
            }

            // Create a black outline symbol to use for the result polygon.
            SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);

            // Create a solid red fill symbol for the result polygon graphic.
            SimpleFillSymbol resultSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Red, outlineSymbol);

            // Create the result polygon graphic and add it to the graphics overlay.
            _resultGraphic = new Graphic(resultPolygon, resultSymbol);
            _polygonsOverlay.Graphics.Add(_resultGraphic);
        }
Esempio n. 13
0
        // Handle the spatial operation selection by performing the operation and showing the result polygon.
        private void SpatialOperationComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            // If an operation hasn't been selected, return.
            if (SpatialOperationComboBox.SelectedItem == null)
            {
                return;
            }

            // Remove any currently displayed result.
            _polygonsOverlay.Graphics.Remove(_resultGraphic);

            // Polygon geometry from the input graphics.
            Geometry polygonOne = _graphicOne.Geometry;
            Geometry polygonTwo = _graphicTwo.Geometry;

            // Result polygon for spatial operations.
            Geometry resultPolygon = null;

            // Run the selected spatial operation on the polygon graphics and get the result geometry.
            string operation = (string)SpatialOperationComboBox.SelectedItem;

            switch (operation)
            {
            case "Union":
                resultPolygon = GeometryEngine.Union(polygonOne, polygonTwo);
                break;

            case "Difference":
                resultPolygon = GeometryEngine.Difference(polygonOne, polygonTwo);
                break;

            case "Symmetric difference":
                resultPolygon = GeometryEngine.SymmetricDifference(polygonOne, polygonTwo);
                break;

            case "Intersection":
                resultPolygon = GeometryEngine.Intersection(polygonOne, polygonTwo);
                break;
            }

            // Create a black outline symbol to use for the result polygon.
            SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Black, 1);

            // Create a solid red fill symbol for the result polygon graphic.
            SimpleFillSymbol resultSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.Red, outlineSymbol);

            // Create the result polygon graphic and add it to the graphics overlay.
            _resultGraphic = new Graphic(resultPolygon, resultSymbol);
            _polygonsOverlay.Graphics.Add(_resultGraphic);
        }
Esempio n. 14
0
        private async void AsyncInitProcesses()
        {
            await _redlandsBoundary.LoadAsync();

            await _mapView.SetViewpointAsync(new Viewpoint(_redlandsBoundary.FullExtent.Extent));

            // await _water.LoadAsync();

            await _parks.LoadAsync();

            // Holds locations of hospitals around San Diego.

            _parkPolygons = new List <Polygon>();
            // Create query parameters to select all features.
            QueryParameters queryParams = new QueryParameters()
            {
                WhereClause = "1=1"
            };

            FeatureQueryResult redlandsResult = await _redlandsBoundary.FeatureTable.QueryFeaturesAsync(queryParams);

            List <Polygon> redlandsBound = redlandsResult.ToList().Select(feature => (Polygon)feature.Geometry).ToList();
            //GeometryEngine.Union()
            await _mapView.SetViewpointAsync(new Viewpoint(GeometryEngine.Union(redlandsBound).Extent));

            // Query all features in the facility table.
            FeatureQueryResult facilityResult = await _parks.FeatureTable.QueryFeaturesAsync(queryParams);

            // Add all of the query results to facilities as new Facility objects.
            _parkPolygons.AddRange(facilityResult.ToList().Select(feature => (Polygon)feature.Geometry));

            //await _mapView.SetViewpointAsync(new Viewpoint(_parkPolygons[0].Extent));

            FeatureQueryResult buildingsResult = await _buildings.FeatureTable.QueryFeaturesAsync(queryParams);

            _buildingGeometry = buildingsResult.ToList().Select(feature => (Polygon)feature.Geometry).ToList();

            /*
             * foreach(Polygon building in _buildingGeometry)
             * {
             *  Graphic bgraphic = new Graphic(building, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Gray, 3.0)));
             *  _barrierOverlay.Graphics.Add(bgraphic);
             * }
             */
        }
        void _operationChoiceButton_ValueChanged(object sender, EventArgs e)
        {
            // Remove any currently displayed result.
            _polygonsOverlay.Graphics.Remove(_resultGraphic);

            // Polygon geometry from the input graphics.
            Geometry polygonOne = _graphicOne.Geometry;
            Geometry polygonTwo = _graphicTwo.Geometry;

            // Result polygon for spatial operations.
            Geometry resultPolygon = null;

            // Run the selected spatial operation on the polygon graphics and get the result geometry.
            switch (_operationChoiceButton.SelectedSegment)
            {
            case 0:
                resultPolygon = GeometryEngine.Difference(polygonOne, polygonTwo);
                break;

            case 1:
                resultPolygon = GeometryEngine.Intersection(polygonOne, polygonTwo);
                break;

            case 2:
                resultPolygon = GeometryEngine.SymmetricDifference(polygonOne, polygonTwo);
                break;

            case 3:
                resultPolygon = GeometryEngine.Union(polygonOne, polygonTwo);
                break;
            }

            // Create a black outline symbol to use for the result polygon.
            SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);

            // Create a solid red fill symbol for the result polygon graphic.
            SimpleFillSymbol resultSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Red, outlineSymbol);

            // Create the result polygon graphic and add it to the graphics overlay.
            _resultGraphic = new Graphic(resultPolygon, resultSymbol);
            _polygonsOverlay.Graphics.Add(_resultGraphic);
        }
Esempio n. 16
0
        private async void UpdateIntersections()
        {
            try
            {
                Logging.LogMethodCall(ClassName);
                var qf        = new QueryParameters();
                var gemStreet = GeometryEngine.Union(_selectedStreet.Value);
                qf.Geometry            = gemStreet;
                qf.SpatialRelationship = SpatialRelationship.Touches;
                var results = await FeatureSource.QueryFeaturesAsync(qf);

                Intersections.Clear();
                foreach (var result in results)
                {
                    var streetName = result.Attributes[StreetNameField].ToString();
                    if (SelectedStreet.Key == streetName)
                    {
                        continue;
                    }
                    var loc = GeometryEngine.Intersections(result.Geometry, gemStreet);
                    if (loc[0] is MapPoint)
                    {
                        Intersections.Add(new Tuple <string, Geometry>(streetName, loc[0]));
                    }
                    else if (loc[0] is Multipoint)
                    {
                        Intersections.Add(new Tuple <String, Geometry>(streetName, ((Multipoint)loc[0]).Points[0]));
                    }
                    else if (loc[0] is Multipart)
                    {
                        var geom = ((Multipart)loc[0]).Parts[0].Points[0];
                        Intersections.Add(new Tuple <string, Geometry>(streetName, geom));
                    }
                }
            }
            catch (Exception ex)
            {
                var message = "Error updating intersections";
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, message, ex);
                Logging.LogMessage(Logging.LogType.Error, message, ex);
            }
        }
Esempio n. 17
0
        private GraphicsLayer Difference(GraphicsLayer firstGrLayer, GraphicsLayer secondGrLayer, Color color)
        {
            var differenceGrLayer = new GraphicsLayer()
            {
                ID          = firstGrLayer.ID + secondGrLayer.ID + "Difference",
                DisplayName = firstGrLayer.DisplayName + secondGrLayer.DisplayName + "Difference"
            };

            MyMapView.Map.Layers.Add(differenceGrLayer);
            AddItemToListBox(differenceGrLayer.DisplayName);
            var    geometries1        = firstGrLayer.Graphics.Select(graphic => graphic.Geometry);
            var    unionGeometry1     = GeometryEngine.Union(geometries1);
            var    geometries2        = secondGrLayer.Graphics.Select(graphic => graphic.Geometry);
            var    unionGeometry2     = GeometryEngine.Union(geometries2);
            var    differenceGeometry = GeometryEngine.Difference(unionGeometry1, unionGeometry2);
            Symbol bufferSymbol       = GetGraphicStyle(color);

            differenceGrLayer.Graphics.Add(new Graphic(differenceGeometry, bufferSymbol));
            return(differenceGrLayer);
        }
Esempio n. 18
0
        private GraphicsLayer Union(GraphicsLayer firstGrLayer, GraphicsLayer secondGrLayer, Color color)
        {
            var unionGrLayer = new GraphicsLayer()
            {
                ID          = firstGrLayer.ID + secondGrLayer.ID + "Union",
                DisplayName = firstGrLayer.DisplayName + secondGrLayer.DisplayName + "Union"
            };

            MyMapView.Map.Layers.Add(unionGrLayer);
            AddItemToListBox(unionGrLayer.DisplayName);
            var geometries1 = firstGrLayer.Graphics.Select(graphic => graphic.Geometry);
            var geometries2 = secondGrLayer.Graphics.Select(graphic => graphic.Geometry);
            var geometries  = geometries1.Concat(geometries2);

            Esri.ArcGISRuntime.Geometry.Geometry unionGeometry = GeometryEngine.Union(geometries);
            Symbol bufferSymbol = GetGraphicStyle(color);

            unionGrLayer.Graphics.Add(new Graphic(unionGeometry, bufferSymbol));
            return(unionGrLayer);
        }
Esempio n. 19
0
        private async Task CreateSubRegionLayerGraphics(IEnumerable <Graphic> statistics)
        {
            QueryTask queryTask = new QueryTask(new Uri(LAYER_URL));
            Query     query     = new Query("1=1")
            {
                ReturnGeometry      = true,
                OutSpatialReference = MyMapView.SpatialReference,
                OutFields           = new OutFields(new List <string> {
                    "sub_region"
                })
            };

            var states = await queryTask.ExecuteAsync(query);

            // Create unioned graphics from state geometries for each region
            var regions = states.FeatureSet.Features
                          .GroupBy(g => g.Attributes["sub_region"], g => g.Geometry)
                          .Select(grp => new Graphic(GeometryEngine.Union(grp), statistics.First(stat => grp.Key.Equals(stat.Attributes["sub_region"])).Attributes));

            _graphicsOverlay.Graphics.Clear();
            _graphicsOverlay.Graphics.AddRange(regions);
        }
Esempio n. 20
0
        public static MapPoint GetRandomPointInGraphicsCollection(IList <Graphic> graphics)
        {
            Random   random   = new Random();
            Graphic  graphic1 = graphics[random.Next(0, graphics.Count)];
            Graphic  graphic2 = graphics[random.Next(0, graphics.Count)];
            Geometry geom1    = graphic1.Geometry;
            Geometry geom2    = graphic2.Geometry;

            if (geom1 is MapPoint)
            {
                return(geom1 as MapPoint);
            }

            Envelope mbr            = GeometryEngine.Union(geom1, geom2).Extent;
            double   x              = random.NextDouble() * (mbr.XMax - mbr.XMin) + mbr.XMin;
            double   y              = random.NextDouble() * (mbr.YMax - mbr.YMin) + mbr.YMin;
            MapPoint randomLocation = new MapPoint(x, y, SpatialReferences.Wgs84);

            return(GetNearestCoordinateInGraphicsCollection(randomLocation, new List <Graphic> {
                graphic1,                                                                                 /* graphic2 */
            }));
        }
Esempio n. 21
0
        private async void unionBtn_Click(object sender, RoutedEventArgs e)
        {
            FeatureQueryResult r = await layer.GetSelectedFeaturesAsync();

            IEnumerator <Feature> resultFeatures = r.GetEnumerator();
            List <Feature>        features       = new List <Feature>();

            while (resultFeatures.MoveNext())
            {
                features.Add(resultFeatures.Current);
            }


            for (int i = 0; i < features.Count - 1; i++)
            {
                resultGeometry = GeometryEngine.Union(features[i].Geometry, features[i + 1].Geometry.Extent);
            }
            try
            {
                if (featureStyle == 1)
                {
                    graphic = new Graphic(resultGeometry, simplePointSymbol);
                }
                else if (featureStyle == 2)
                {
                    graphic = new Graphic(resultGeometry, simpleLineSymbol);
                }
                else if (featureStyle == 3)
                {
                    graphic = new Graphic(resultGeometry, simpleFillSymbol);
                }
                MainWindow.graphicsOverlay.Graphics.Add(graphic);
            }
            catch
            {
            }
        }
Esempio n. 22
0
        internal async void ZoomToStreet()
        {
            if (StreetLayer != null && StreetLayer is FeatureLayer)
            {
                if (Type == "INTERSECTS")
                {
                    QueryParameters _query = new QueryParameters();
                    _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'";

                    var prifeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    _query.WhereClause = $"REGISTEREDNAME = '{SelectedIntersectingStreet.name}' and STREETTYPE = '{SelectedIntersectingStreet.type}' and QUADRANT = '{SelectedIntersectingStreet.quad}'";
                    var intfeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    var showfeatures = new List <Feature>();
                    foreach (var prifeature in prifeatures)
                    {
                        foreach (var intfeature in intfeatures)
                        {
                            if (GeometryEngine.Touches(prifeature.Geometry, intfeature.Geometry))
                            {
                                showfeatures.Add(prifeature);
                                showfeatures.Add(intfeature);
                            }
                        }
                    }
                    var strings = showfeatures.Select(feature => $"OBJECTID = {feature.Attributes["OBJECTID"]?.ToString()}");


                    _query.WhereClause = String.Join(" or ", strings.ToArray());

                    var features = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    if (features.Count() > 0)
                    {
                        try
                        {
                            var newGeometry = GeometryEngine.Union(features.Select(ft => ft.Geometry));

                            MapVM.MapView?.SetViewpointGeometryAsync(newGeometry, 2);
                        }catch (Exception e)
                        {
                            MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
                else
                {
                    QueryParameters _query = new QueryParameters();
                    _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'";
                    _query.WhereClause = _query.WhereClause + $" and  FROMLEFTTHEORETICRANGE = '{SelectedRange.leftLower}' and TOLEFTTHEORETICRANGE = '{SelectedRange.leftUpper}' and FROMRIGHTTHEORETICRANGE = '{SelectedRange.rightLower}' and TORIGHTTHEORETICRANGE = '{SelectedRange.rightUpper}'";
                    var features = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query);

                    if (features.Count() > 0)
                    {
                        try
                        {
                            var newGeometry = GeometryEngine.Union(features.Select(ft => ft.Geometry));

                            MapVM.MapView?.SetViewpointGeometryAsync(newGeometry, 2);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        private Task <bool> createFunnyGarden(Geometry geometry)
        {
            if (geometry == null)
            {
                return(Task.FromResult(false));
            }

            // get the point layer from the active map
            var pointLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>()
                             .Where(lyr => lyr.ShapeType == ArcGIS.Core.CIM.esriGeometryType.esriGeometryPoint).FirstOrDefault();

            if (pointLayer == null)
            {
                return(Task.FromResult(false));
            }

            // get the polygon layer from the active map
            var polygonLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>()
                               .Where(lyr => lyr.ShapeType == ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolygon).FirstOrDefault();

            if (polygonLayer == null)
            {
                return(Task.FromResult(false));
            }

            // Create an edit operation
            var createOperation = new EditOperation();

            createOperation.Name = string.Format("Create green");

            // we'll use the sketch geometry to create a spatial filter
            SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter();

            spatialQueryFilter.FilterGeometry      = geometry;
            spatialQueryFilter.SpatialRelationship = SpatialRelationship.Contains;

            // retrieve the point features that are inside the sketch geometry
            var searchCursor = pointLayer.Search(spatialQueryFilter);

            // Construct a polygon placeholder for the point buffers
            var treeBuffers = PolygonBuilder.CreatePolygon(geometry.SpatialReference);

            // TODO
            // 1. for each point geometry
            //     2. buffer the geometry  (Hint : use the MapView.Active.Extent.Width/50 as the buffer distance)
            //     3. union this result with the existing treeBuffers
            // 4. subtract the collection of buffers from the sketch geometry
            // HINT: use the GeometryEngine to buffer, union and subtract (difference) the geometries
            // Polygon greenGeometry = null;

            // for each found feature
            while (searchCursor.MoveNext())
            {
                // retrieve the geometry
                var treeFeature = searchCursor.Current as Feature;
                var treePoint   = treeFeature.GetShape() as MapPoint;

                // buffer the the location
                var treeBuffer = GeometryEngine.Buffer(treePoint, MapView.Active.Extent.Width / 50);

                // and union the new buffer to the existing buffer polygons
                treeBuffers = GeometryEngine.Union(treeBuffer, treeBuffers) as Polygon;
            }

            // ensure the sketch geometry is simple
            if (!GeometryEngine.IsSimpleAsFeature(geometry, true))
            {
                geometry = GeometryEngine.SimplifyAsFeature(geometry);
            }

            // construct the difference geometry between the sketch geometry and the buffered point polygons
            var greenGeometry = GeometryEngine.Difference(geometry, treeBuffers);

            // cue the create
            createOperation.Create(polygonLayer, greenGeometry);

            // execute the operation
            return(createOperation.ExecuteAsync());
        }
Esempio n. 24
0
        private void Initialize()
        {
            // Configure the basemap
            _myMapView.Map = new Map(Basemap.CreateTopographic());

            // Create the graphics overlay
            _graphicsOverlay = new GraphicsOverlay();

            // Add the overlay to the MapView
            _myMapView.GraphicsOverlays.Add(_graphicsOverlay);

            // Update the selection color
            _myMapView.SelectionProperties.Color = Color.Yellow;

            // Create the point collection that defines the polygon
            PointCollection polygonPoints = new PointCollection(SpatialReferences.WebMercator)
            {
                new MapPoint(-5991501.677830, 5599295.131468),
                new MapPoint(-6928550.398185, 2087936.739807),
                new MapPoint(-3149463.800709, 1840803.011362),
                new MapPoint(-1563689.043184, 3714900.452072),
                new MapPoint(-3180355.516764, 5619889.608838)
            };

            // Create the polygon
            Polygon polygonGeometry = new Polygon(polygonPoints);

            // Define the symbology of the polygon
            SimpleLineSymbol polygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Green, 2);
            SimpleFillSymbol polygonFillSymbol    = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, polygonOutlineSymbol);

            // Create the polygon graphic and add it to the graphics overlay
            _polygonGraphic = new Graphic(polygonGeometry, polygonFillSymbol);
            _graphicsOverlay.Graphics.Add(_polygonGraphic);

            // Create the point collection that defines the polyline
            PointCollection polylinePoints = new PointCollection(SpatialReferences.WebMercator)
            {
                new MapPoint(-4354240.726880, -609939.795721),
                new MapPoint(-3427489.245210, 2139422.933233),
                new MapPoint(-2109442.693501, 4301843.057130),
                new MapPoint(-1810822.771630, 7205664.366363)
            };

            // Create the polyline
            Polyline polylineGeometry = new Polyline(polylinePoints);

            // Create the polyline graphic and add it to the graphics overlay
            _polylineGraphic = new Graphic(polylineGeometry, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Red, 4));
            _graphicsOverlay.Graphics.Add(_polylineGraphic);

            // Create the point geometry that defines the point graphic
            MapPoint pointGeometry = new MapPoint(-4487263.495911, 3699176.480377, SpatialReferences.WebMercator);

            // Define the symbology for the point
            SimpleMarkerSymbol locationMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10);

            // Create the point graphic and add it to the graphics overlay
            _pointGraphic = new Graphic(pointGeometry, locationMarker);
            _graphicsOverlay.Graphics.Add(_pointGraphic);

            // Listen for taps; the spatial relationships will be updated in the handler
            _myMapView.GeoViewTapped += myMapView_GeoViewTapped;

            // Set the viewpoint to center on the point
            _myMapView.SetViewpointGeometryAsync(GeometryEngine.Union(polygonGeometry, polylineGeometry), 50);
        }
Esempio n. 25
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;
            }
        }