Пример #1
0
        // Accepts two user shapes and adds them to the graphics layer
        private async Task AcceptShapeAsync()
        {
            // Shape One
            Geometry shapeOne = await mapView.Editor.RequestShapeAsync(
                (DrawShape)comboShapeOne.SelectedValue, _symbols[comboShapeOne.SelectedIndex]);

            _graphicsLayer.Graphics.Add(new Graphic(shapeOne, _symbols[comboShapeOne.SelectedIndex]));

            // Shape Two
            Geometry shapeTwo = await mapView.Editor.RequestShapeAsync(
                (DrawShape)comboShapeTwo.SelectedValue, _symbols[comboShapeTwo.SelectedIndex]);

            _graphicsLayer.Graphics.Add(new Graphic(shapeTwo, _symbols[comboShapeTwo.SelectedIndex]));

            var relations = new List <Tuple <string, bool> >();

            relations.Add(new Tuple <string, bool>("Contains", GeometryEngine.Contains(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Crosses", GeometryEngine.Crosses(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Disjoint", GeometryEngine.Disjoint(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Equals", GeometryEngine.Equals(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Intersects", GeometryEngine.Intersects(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Overlaps", GeometryEngine.Overlaps(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Touches", GeometryEngine.Touches(shapeOne, shapeTwo)));
            relations.Add(new Tuple <string, bool>("Within", GeometryEngine.Within(shapeOne, shapeTwo)));
            resultsListView.ItemsSource = relations;

            resultsPanel.Visibility = Visibility.Visible;
        }
Пример #2
0
        /// <summary>
        /// Returns a list of spatial relationships between two geometries
        /// </summary>
        /// <param name="a">The 'a' in "a contains b"</param>
        /// <param name="b">The 'b' in "a contains b"</param>
        /// <returns>A list of spatial relationships that are true for a and b.</returns>
        private static List <SpatialRelationship> GetSpatialRelationships(Geometry a, Geometry b)
        {
            List <SpatialRelationship> relationships = new List <SpatialRelationship>();

            if (GeometryEngine.Crosses(a, b))
            {
                relationships.Add(SpatialRelationship.Crosses);
            }
            if (GeometryEngine.Contains(a, b))
            {
                relationships.Add(SpatialRelationship.Contains);
            }
            if (GeometryEngine.Disjoint(a, b))
            {
                relationships.Add(SpatialRelationship.Disjoint);
            }
            if (GeometryEngine.Intersects(a, b))
            {
                relationships.Add(SpatialRelationship.Intersects);
            }
            if (GeometryEngine.Overlaps(a, b))
            {
                relationships.Add(SpatialRelationship.Overlaps);
            }
            if (GeometryEngine.Touches(a, b))
            {
                relationships.Add(SpatialRelationship.Touches);
            }
            if (GeometryEngine.Within(a, b))
            {
                relationships.Add(SpatialRelationship.Within);
            }
            return(relationships);
        }
Пример #3
0
        // Accepts two user shapes and adds them to the graphics layer
        private async Task AcceptShapeAsync()
        {
            // Shape One
            DrawShape drawShape1 = (DrawShape)comboShapeOne.SelectedItem;
            Geometry  shapeOne   = null;

            if (drawShape1 == DrawShape.Point)
            {
                shapeOne = await mapView.Editor.RequestPointAsync();
            }
            else
            {
                shapeOne = await mapView.Editor.RequestShapeAsync(drawShape1, _symbols[comboShapeOne.SelectedIndex]);
            }

            graphicsLayer.Graphics.Add(new Graphic(shapeOne, _symbols[comboShapeOne.SelectedIndex]));

            // Shape Two
            Geometry shapeTwo = await mapView.Editor.RequestShapeAsync(
                (DrawShape)comboShapeTwo.SelectedItem, _symbols[comboShapeTwo.SelectedIndex]);

            graphicsLayer.Graphics.Add(new Graphic(shapeTwo, _symbols[comboShapeTwo.SelectedIndex]));

            Dictionary <string, bool> relations = new Dictionary <string, bool>();

            relations["Contains"]   = GeometryEngine.Contains(shapeOne, shapeTwo);
            relations["Crosses"]    = GeometryEngine.Crosses(shapeOne, shapeTwo);
            relations["Disjoint"]   = GeometryEngine.Disjoint(shapeOne, shapeTwo);
            relations["Equals"]     = GeometryEngine.Equals(shapeOne, shapeTwo);
            relations["Intersects"] = GeometryEngine.Intersects(shapeOne, shapeTwo);
            relations["Overlaps"]   = GeometryEngine.Overlaps(shapeOne, shapeTwo);
            relations["Touches"]    = GeometryEngine.Touches(shapeOne, shapeTwo);
            relations["Within"]     = GeometryEngine.Within(shapeOne, shapeTwo);

            resultsPanel.Visibility     = Visibility.Visible;
            resultsListView.ItemsSource = relations;
        }
Пример #4
0
        private void Geometry_OnviewTap(Graphic _graphic)
        {
            //var ree1 = graphic_collection.SelectMany(graphic => graphic.Attributes, (gr_key, gr_value) => new { gr_key, gr_value });
            var ere = _graphic.Geometry.GeometryType.ToString();
            List <GraphicsOverlay> grc = new List <GraphicsOverlay>();

            // GraphicCollection tempgrc=
            //  GraphicsOverlayCollection grc=new GraphicsOverlayCollection() ;
            foreach (var item in MyMapView.GraphicsOverlays)
            {
                if (item.Id != "seven")
                {
                    grc.Add(item);
                }
            }
            //var ree1 = grc.SelectMany(graphic => graphic.Attributes, (gr_key, gr_value) => new { gr_key, gr_value });

            if (ere == "Polyline")
            {
                foreach (var ter in grc)
                {
                    foreach (var item in ter.Graphics)
                    {
                        var textsymline = item.Symbol.ToString();
                        if (textsymline != "Esri.ArcGISRuntime.Symbology.TextSymbol")
                        {
                            if ((GeometryEngine.Intersects(item.Geometry, _graphic.Geometry) || GeometryEngine.Within(item.Geometry, _graphic.Geometry) || GeometryEngine.Overlaps(item.Geometry, _graphic.Geometry)))
                            {
                                item.IsSelected = true;
                            }
                        }
                        else
                        {
                            var se = item.Geometry;
                        }
                    }
                }
            }
            if (ere == "Polygon")
            {
                foreach (var ter in grc)
                {
                    foreach (var item in ter.Graphics)
                    {
                        var textsympolygon = item.Symbol.ToString();
                        if (textsympolygon != "Esri.ArcGISRuntime.Symbology.TextSymbol")
                        {
                            if ((GeometryEngine.Intersects(item.Geometry, _graphic.Geometry) || GeometryEngine.Within(item.Geometry, _graphic.Geometry) || GeometryEngine.Overlaps(item.Geometry, _graphic.Geometry)))
                            {
                                item.IsSelected = true;
                            }
                        }
                        else
                        {
                            var ett = item.Geometry;
                        }
                    }
                }
            }
        }